Skip to content

Instantly share code, notes, and snippets.

@agam
Created September 16, 2023 07:41
Show Gist options
  • Save agam/9a57a9e22f517aa712c6b574602f2ba9 to your computer and use it in GitHub Desktop.
Save agam/9a57a9e22f517aa712c6b574602f2ba9 to your computer and use it in GitHub Desktop.
Simple chroot-er
#/bin/bash
mkdir /home/namespace/box
mkdir /home/namespace/box/bin
mkdir /home/namespace/box/lib
mkdir -p /home/namespace/box/usr/lib
mkdir /home/namespace/box/lib64
mkdir /home/namespace/box/proc
mkdir /home/namespace/box/data
cp -v /bin/kill /home/namespace/box/bin/
cp -v /bin/ps /home/namespace/box/bin
cp -v /bin/bash /home/namespace/box/bin
cp -v /bin/ls /home/namespace/box/bin
cp -r /lib/* /home/namespace/box/lib/
cp -r /usr/lib/* /home/namespace/box/usr/lib/
cp -r /lib64/* /home/namespace/box/lib64/
mount -t proc /proc /home/namespace/box/proc
mount --bind /tmp/ /home/namespace/box/data
chroot /home/namespace/box /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment