FLAG{printable}
的字串id
看身份、ls
及 cat
看檔案../%2e%2e/.%2e/etc/passwd
字樣<script>alert(1);</script>
驗證後面是 3 個最基本的 Path Traversal 漏洞
以及 1 個 unzip 的特殊用法
如果正課講完有時間就帶大家玩玩看
Path Traversal / CVE-2021-43798
CVSS Score: 7.5 (High)
請參考 "grafana/grafana@c798c0e9
"
用 "filepath.Join()
" 處理使用者輸入會出問題
Rel()
"?func Rel(basepath, targpath)
/* Join(basepath, Rel(basepath, targpath)) == targpath */
回傳一個當 basepath
與結果 Join()
時,
會等價於 targpath
的相對路徑
當 targpath
無法轉換為相對於 basepath
的相對路徑時,會回傳錯誤
在 Join()
前,先用 Rel()
排除相對路徑
Hint: 請用 "curl --path-as-is
",否則 "../
" 會被瀏覽器吃掉
Path Traversal / CVE-2021-41773
CVSS Score: 7.5 (High)
他叫我們不要用 "%2e
" 或 "%2E
"
Path Traversal / CVE-2021-42013
CVSS Score: 9.8 (Critical)
讓我們再看一次之前的 patch
現在 "%
" 後面只能接兩個 "[0-9a-f]
" 字元了
使用 "%%32%65
" 來做 double encoding
Command Injection / CVE-2021-32682
CVSS Score: 9.8 (Critical)
zip
command$ zip -r9 -q 'target.zip' './source.txt'
-q, --quiet
Quiet mode; eliminate informational messages and
comment prompts. (Useful, for example, in shell
scripts and background tasks).
-r, --recurse-paths
Travel the directory structure recursively;
for example: `zip -r archive.zip folder/`
-# (-0, -1, -2, -3, -4, -5, -6, -7, -8, -9)
The speed of compression.
-0 means no compression.
-1 indicates the fastest compression speed.
-9 uses the optimal compression.
-v, --verbose
Verbose mode or print diagnostic version info.
-T, --test
Test the integrity of the new zip file.
-TT, --unzip-command
Use custom command to test an archive
when the -T option is used.
對檔名加上 ./
前綴
我們可以善用 zip -TT
選項
$ zip -T -TT 'echo' file.zip