WebGoat——盲注

工具介绍:盲注可以通过人工去做,但是成本太高,Webgoat提供一个工具Simple JHijack(下载地址),通过与Tamper Data(使用方法)的结合使用,能够完成部分盲注。

界面介绍:

WebGoat——盲注_第1张图片

具体的实施

1、Webgoat——Blind Numeric SQL Injection

The form below allows a user to enter an account number and determine if it is valid or not. Use this form to develop a true / false test check other entries in the database.The goal is to find the value of the fieldpinin table pins for the row with the cc_number of 1111222233334444. The field is of type int, which is an integer.

题意:页面上存在一个查询框(如下),在查询框中输入员工编号,系统能够返回该编号是否有效。现要求通过盲注,查找出pins表中cc_number为1111222233334444的员工的pin值,提示pin值为整数。

WebGoat——盲注_第2张图片

解法:

(1)通过手动注入

代码:101 AND ((SELECT pin FROM pins WHERE cc_number='1111222233334444') > 10000 );

首先可以看到这个查询语句是由AND连接,AND的左侧是为true(上图中已经给以验证,101的员工编号是存在的),AND的右侧是一个判断语句判断cc_number='1111222233334444'的员工的pin值是否大于10000,若大于则返回真。我们可以通过变化pin值的范围,通过夹逼定理来推导出pin值。

(2)使用工具注入

代码:account_number=101and (select ascii(substr  (pin,1,1))from pins where cc_number=1111222233334444)=$ --
           ........
           account_number=101
and (select ascii(substr  (pin,5,1))from pins where cc_number=1111222233334444)=$ --

打开simple jhijack,目标主机、端口、URL都直接填入,grep掉“Account number is valid.”,simple jhijack就是根据grep中的语句来判断查询结果中是否有这句话的出现,sessionid可以用tamperdata获取,range应该就是数字变化的范围(0~9),注意要用asicii表示即48~57。其实上述的每段代码simple jhijack都是用一个循环去跑的,循环范围是range值,而参数即是代码中的$表示,代码后的“--”是用来注释后面的字符的(下图中有体现)。

注意:substr(a,n,m)函数的意思是取a的值,第n位开始,取m个。
WebGoat——盲注_第3张图片
WebGoat——盲注_第4张图片


配置好后,点击hijack,右侧的结果标注有==><==的就是我们的结果,第一次是50,第二次51,第三次是54,第四次是52,而第五次会出现如下图

WebGoat——盲注_第5张图片

result为空,说明pin值只有四位,分别为50,51,54,52即2364.验证结果正确。

WebGoat——盲注_第6张图片


2、Webgoat——Blind String SQL Injection

The form below allows a user to enter an account number and determine if it is valid or not. Use this form to develop a true / false test check other entries in the database.Reference Ascii Values: 'A' = 65 'Z' = 90 'a' = 97 'z' = 122. 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.Put the discovered name in the form to pass the lesson. Only the discovered name should be put into the form field, paying close attention to the spelling and capitalization.

题意:与上题类似,只是猜测cc_number为4321432143214321的name,name为varchar。

解题:猜测范围a~zA~Z,范围为65-122

代码:

        account_number=101 and (select ascii(substr  (name,1,1))from pins where cc_number=4321432143214321)=$ --
        ...
        account_number=101 and (select ascii(substr  (name,4,1))from pins where cc_number=4321432143214321)=$ --

配置hijack

WebGoat——盲注_第7张图片

猜测的第一个为74,其余依次类推105,108,108。即Jill。验证如下

WebGoat——盲注_第8张图片

你可能感兴趣的:(WebGoat——盲注)