CTF【每日一題20160615】
阿新 • • 發佈:2019-02-06
分析
1. 看頁面中右側有“提示在這裡”似乎可以點選,但沒有響應
2. 檢視網頁原始碼(老套路),發現點選連結tip/nozend.php被註釋了
<div class="lvl_tip" id="lvl2tip">
<span class="icon warning_icon"></span>
<p>逆向解密</p><p>提示在 <b class="stress">這裡<!-- tip/nozend.php --></b> </p>
</div >
<?php
highlight_file( __FILE__ );
function notrealmd5code($string,$operation='ENCODE') {
if ($operation=='ENCODE'){
$OutTxt = "";
for ($x=0;$x<strlen($string);$x++) {
$nr = ord($string[$x]);
if ($nr < 128) {
$nr += 128;
}
elseif ($nr > 127) {
$nr -= 128;
}
$nr = 255 - $nr;
$OutTxt .= sprintf("%02x", $nr);
}
return $OutTxt;
} else {
/* DECODE MISS
* ord Return ASCII value of character
*/
return '';
}
}
echo notrealmd5code('1c10121a181e121a0f1016110b4d4d4d' ,'DECODE');
?>
顯然該頁面要輸出:echo notrealmd5code('1c10121a181e121a0f1016110b4d4d4d','DECODE');
但notrealmd5code函式中的decode部分沒有實現,那麼我們需要將字串1c10121a181e121a0f1016110b4d4d4d進行decode。這裡的encode是對密碼進行了一種16進位制字元轉換,是種簡單的加密(古典替換類的),那麼decode自然是反推了。如果要編php又不想搭環境解釋環境,可以線上測試。例如http://www.shucunwang.com/RunCode/php/提供了測試環境。如果想用其他語言編解碼函式,也可以把'1c10121a181e121a0f1016110b4d4d4d'拷貝出來。例如下面的python解碼:
'''
解密演算法python版(醜陋但能用)
'''
str = '1c10121a181e121a0f1016110b4d4d4d'
ctable = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,
'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
out = ''
i = 0
while i < len(str):
a = str[i].upper()
b = str[i+1].upper()
c = ctable[a]*16 + ctable[b]
i += 2
c = 255 - c
if c >= 128:
c -= 128
elif c <=127:
c += 128
out += chr(c)
print out
#輸出為:comegamepoint222
將comegamepoint222輸入提交框,答案正確。