Last active
June 14, 2023 02:16
-
-
Save scarf005/81241e36e0a2a2b84306f23933ba652a to your computer and use it in GitHub Desktop.
Bash in a jar
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
| #!/usr/bin/env bash | |
| readonly GREEN='\033[32m' | |
| readonly NC='\033[0m' | |
| header() { printf "${GREEN}$@${NC}"; } | |
| readonly LOCATION=$(pwd)/bash-in-a-jar | |
| header "installation location:\n" | |
| echo ${LOCATION} | |
| header "\ncreating directories:\n" | |
| echo ${LOCATION}/{bin,lib,lib64} | |
| mkdir -p ${LOCATION}/{bin,lib,lib64} | |
| cd ${LOCATION} | |
| for NAME in /bin/{bash,echo,ls} | |
| do | |
| header '\ncopying binary: ' | |
| cp -v ${NAME} ${LOCATION}/bin | |
| header '\ncopying shared object:\n' | |
| ldd ${NAME} | egrep -o '/lib.*\.[0-9]' | xargs -i cp -v --parents {} . | |
| echo | |
| done | |
| header 'now run: ' | |
| echo 'sudo chroot .' /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment