Last active
June 18, 2021 19:57
-
-
Save tytydraco/38b20d1606b62d76a7f4740424c58df5 to your computer and use it in GitHub Desktop.
Open an ADB shell session on an Android system via netcat
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
#!/system/bin/sh | |
LOCAL=false | |
PORT=65432 | |
usage() { | |
echo "Usage: $0 [-h] [-l] [-k] [-p PORT] | |
-h Show this screen | |
-l Only allow localhost connections | |
-k Kill any open netcat sessions | |
-p PORT Port to listen for connections on (default: $PORT)" | |
} | |
while getopts ":lhkp:" opt | |
do | |
case "$opt" in | |
h) | |
usage | |
exit 0 | |
;; | |
l) | |
LOCAL=true | |
;; | |
k) | |
pkill netcat | |
exit 0 | |
;; | |
p) | |
PORT="$OPTARG" | |
;; | |
*) | |
usage | |
exit 1 | |
;; | |
esac | |
done | |
ARGS=() | |
[[ "$LOCAL" == true ]] && ARGS+=("-s localhost") | |
# shellcheck disable=SC2068 | |
setsid netcat -p "$PORT" -L ${ARGS[@]} sh & | |
echo -e "Done! Use: \e[1mnc localhost $PORT\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment