Skip to content

Instantly share code, notes, and snippets.

@sr229
Created December 3, 2018 17:26
Show Gist options
  • Save sr229/c431a26e5d98e7ec6b4880861ff0c25a to your computer and use it in GitHub Desktop.
Save sr229/c431a26e5d98e7ec6b4880861ff0c25a to your computer and use it in GitHub Desktop.
Script to access a Specific Chroot in Android
#!/system/bin/sh
#
# This will attempt to mount /proc, /sys, and /dev.
#
# Make sure your directory has sufficient permissions.
set -o errexit -o nounset
if [ ! -d "$1" ] || [ ! -n "$1" ]; then
echo "Directory not found!";
exit 2;
else
echo "entering chroot..."
if [ -z "$(ls -A $1/proc)" ] && [ -z "$(ls -A $1/sys) " ] && [ -z "$(ls -A $1/dev)" ]; then
mount -t proc /proc "$1/proc"
mount -t sysfs /sys "$1/sys"
mount -o bind /dev "$1/dev"
chroot "$1" /bin/sh -l
elif [ -z "$(ls -A $1/dev)" ]; then
mount -t proc /proc "$1/proc"
mount -t sysfs /sys "$1/sys"
mount -o bind /dev "$1/dev"
chroot "$1" /bin/sh -l
elif [ -z "$(ls -A $1/proc)" ]; then
mount -t proc /proc "$1/proc"
mount -t sysfs /sys "$1/sys"
mount -o bind /dev "$1/dev"
chroot "$1" /bin/sh -l
else
chroot "$1" /bin/sh -l
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment