Last active
July 7, 2023 10:46
-
-
Save christianarielli/afa8be6407a3f1c90f4940cad80a35a5 to your computer and use it in GitHub Desktop.
This script can be used to create simple chroot environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script can be used to create simple chroot environment | |
# Written by LinuxConfig.org | |
# (c) 2020 LinuxConfig under GNU GPL v3.0+ | |
#!/bin/bash | |
CHROOT='/var/chroot' | |
mkdir -p $CHROOT | |
for i in $( ldd $* | grep -v dynamic | cut -d " " -f 3 | sed 's/://' | sort | uniq ) | |
do | |
cp --parents $i $CHROOT | |
done | |
# ARCH amd64 | |
if [ -f /lib64/ld-linux-x86-64.so.2 ]; then | |
cp --parents /lib64/ld-linux-x86-64.so.2 /$CHROOT | |
fi | |
# ARCH i386 | |
if [ -f /lib/ld-linux.so.2 ]; then | |
cp --parents /lib/ld-linux.so.2 /$CHROOT | |
fi | |
echo "Chroot jail is ready. To access it execute: chroot $CHROOT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using that script, let’s enable some of these commands:
./chroot.sh /bin/{ls,cat,echo,rm,vi,date,mkdir}