CTF

hackmd-github-sync-badge

tags: Information Security

參考資料: https://ithelp.ithome.com.tw/m/articles/10265748



「億」些指令

命令 說明 用法
cat 查看檔案內容 cat 檔案名
wget 下載檔案 wget 網址
--help 查看命令使用說明 命令 help
grep 在檔案中尋找符合條件的關鍵字或正規表示法 grep 關鍵字 檔案名
unzip 解壓縮 unzip '檔案名'
nc(netcat) 讓你直接連接一個遠方主機,它向你送訊息、你也向它送訊息,這樣一個溝通工具 超級無敵多用法
man 查詢指令用法 man 指令

picoCTF例題

Obedient Cat

Description
This file has a flag in plain sight (aka "in-the-clear"). Download flag).

解法


Python Wrangling

Description
Python scripts are invoked kind of like programs in the Terminal Can you run this Python script using this password to get the flag?

解法

step1.


cat flag.txt.enpw.txt
step2.

執行ende.py
Usage: ende.py (-e/-d) [file]表示需要輸入一個檔案,參數選項 -e, -d,基本上就是encode和decode。
接著按照提示輸入指令python3 ende.py -d flag.txt.en(記得一定要python3!只打python不給過:D),會跑出Please enter the password:,此時輸入剛剛cat pw.txt的內容,就會跑出flag了。


Wave a flag

Description
Can you invoke help flags for a tool or binary? This program has extraordinarily helpful information

解法

step1.
wget後,檔案為warm
step2.


無法執行(權限不足)
step3.

輸入chmod +x ./warm,幫warm加上執行權限
(此處注意是./warm而非warm./warm 代表「目前目錄下的warm檔案」)
step4.

執行warm後,出現提示字!
按照提示,使用-h查詢warm的說明
step5.

輸入./warm -h,即出現flag!


Nice netcat

Description
There is a nice program that you can talk to by using this command in a shell: $ nc mercury.picoctf.net 49039, but it doesn't speak English

解法

step1.


按照題目輸入$ nc mercury.picoctf.net 49039後,出現一大串數字
step2.

將其丟到十進制轉ASCII,轉換結果為flag


Static ain't always noise

Description
Can you look at the data in this binary: static? This BASH script might help!

解法

step1.


執行兩個下載下來的檔案,其中輸入./ltdis.sh時,輸出寫到disassembly(反組譯),它會將執行檔的二進位檔案內容,轉換成對應組合語言。

wiki: 反組譯器(disassembler)是一種將機器語言轉換為組合語言的電腦程式——這與組譯器的目的相反。反組譯器與反編譯器不同,反編譯器的目標是高階語言而非組合語言。反組譯器的反組譯輸出通常格式化為適合人類閱讀,而非用作組譯器的輸入源,因此它主要是一個逆向工程工具。

step2.


再來,看到執行ltdis.sh出現的ltdis.sh <program-file>,因此輸入./ltdis.sh ./static
出現Any strings found in ./static have been written to ./static.ltdis.strings.txt with file offset,代表flag在static.ltdis.strings.txt裡。
step3.

接著,因為要找到在static.ltdis.strings.txt的flag,所以輸入grep 'picoCTF' ./static.ltdis.strings.txt(表示要在static.ltdis.strings.txt裡找到picoCTF關鍵字)。最終找到flag。


Tab, Tab, Attack

Description
Using tabcomplete in the Terminal will add years to your life, esp. when dealing with long rambling directory structures and filenames: Addadshashanammu.zip

解法

step1.


先解壓縮檔案。
解壓縮出來的檔案路徑檔名很長,目錄也很多層。
step2.

先進去Addadshashanammu資料夾之後,打./後爆按Tab,shell自動幫你補上所有路徑,最後到達fang-of-haynekhtnamet這個檔案,接著按Enter執行,即跑出flag。


what's a net cat?

Description
Using netcat (nc) is going to be pretty important. Can you connect to jupiter.challenges.picoctf.org at port 25103 to get the flag?

解法


輸入netcat(or nc) jupiter.challenges.picoctf.org 25103即可。


strings it

Description
Can you find the flag in file without running it?

解法

step1.



題目提示你要用strings指令,那就先查查看strings要怎麼用。
輸入man strings查看用法,按q離開。
step2.

輸入strings strings(指令 檔名)後,跑出來一大串東西。
step3.

此時使用大絕招strings strings | grep "pico"(grep),成功找到flag。