2016-04-02 18 views
0

Savunmasız web sitelerini tarayan bir program yazıyordum, Zayıf noktaları olan bir çift site olduğunu ve bir SQL sözdizimi hatası döndürdüğümü biliyorum, ancak programı çalıştırdığımda, atlar Bu siteler, bir dosyaya nerede kaydedildiklerini veya çıktılarını buldular. Bu program pentesting için kullanılıyor ve sitelerin tüm sahipleri güvenlik açığından haberdar ediliyor.Webcrawler URL'leri atlıyor

Kaynak:

[22:49:29 INFO]Checking if sites are vulnerable. 
[22:49:53 WARNING]URL: http://www.police.bd/content.php?id=275' failed with error: [execution expired] dumped to non_exploitable.txt 

Dosya içeren URL'ler:

http://www.bible.com/subcat.php?id=2' 
http://www.cidko.com/pro_con.php?id=3' 
http://www.slavsandtat.com/about.php?id=25' 
http://www.police.bd/content.php?id=275' 
http://www.icdcprage.org/index.php?id=10' 
http://huawei.com/en/plugin.php?id=hwdownload' 
https://huawei.com/en/plugin.php?id=unlock' 
https://facebook.com/profile.php?id' 
http://www.footballclub.com.au/index.php?id=43' 
http://www.mesrs.qc.ca/index.php?id=1525' 

Program 3 URL'lerin aşmakta ve düz gider görebileceğiniz gibi kullanım

def get_urls 
    info("Searching for possible SQL vulnerable sites.") 
    @agent = Mechanize.new 
    page = @agent.get('http://www.google.com/') 
    google_form = page.form('f') 
    google_form.q = "#{SEARCH}" 
    url = @agent.submit(google_form, google_form.buttons.first) 
    url.links.each do |link| 
    if link.href.to_s =~ /url.q/ 
     str = link.href.to_s 
     str_list = str.split(%r{=|&}) 
     urls = str_list[1] 
     next if str_list[1].split('/')[2] == "webcache.googleusercontent.com" 
     urls_to_log = urls.gsub("%3F", '?').gsub("%3D", '=') 
     success("Site found: #{urls_to_log}") 
     File.open("#{PATH}/temp/SQL_sites_to_check.txt", "a+") {|s| s.puts("#{urls_to_log}'")} 
    end 
    end 
    info("Possible vulnerable sites dumped into #{PATH}/temp/SQL_sites_to_check.txt") 
end 

def check_if_vulnerable 
    info("Checking if sites are vulnerable.") 
    IO.read("#{PATH}/temp/SQL_sites_to_check.txt").each_line do |parse| 
    begin 
     Timeout::timeout(5) do 
     parsing = Nokogiri::HTML(RestClient.get("#{parse.chomp}")) 
     end 
    rescue Timeout::Error, RestClient::ResourceNotFound, RestClient::SSLCertificateNotVerified, Errno::ECONNABORTED, Mechanize::ResponseCodeError, RestClient::InternalServerError => e 
     if e 
     warn("URL: #{parse.chomp} failed with error: [#{e}] dumped to non_exploitable.txt") 
     File.open("#{PATH}/lib/non_exploitable.txt", "a+"){|s| s.puts(parse)} 
     else 
     success("SQL syntax error discovered in URL: #{parse.chomp} dumped to SQL_VULN.txt") 
     File.open("#{PATH}/lib/SQL_VULN.txt", "a+"){|vuln| vuln.puts(parse)} 
     end 
    end 
    end 
end 

Örnek dördüncü, neden?

Bunun nerede olacağı konusunda yanlış bir şey yapıyorum?

+0

Yığın Taşması'na Hoş Geldiniz. Lütfen "[mcve]" yi okuyun. Kodunuz olduğu gibi çalışmayacak. Çalışmak için değiştirmemiz gerekmeden çalışmasının tutarlı olması önemlidir. Tanımlanmayan sabitler ve hiç çağrılmayan iki yönteme sahipsiniz. –

cevap

1

rescue bloğunun olması gereken yerde olduğundan emin değilim. parsing = Nokogiri::HTML(RestClient.get("#{parse.chomp}"))'da getirdiğiniz içerikle hiçbir şey yapmıyorsunuz ve ilk üç için belki de hiçbir istisna ve hata çıkışı çalışmıyor. Getirildiklerini görmek için bu satırdan sonra biraz çıkış ekleyin.

+0

Bu yüzden getirilen HTML'yi görüntülemek için bazı "puts" eklemeliyim, temel olarak ne diyorsunuz? – 13aal

+0

Bu, herhangi bir istisnayı yükseltmeyen ayrıştırılmış içerikle ne yapacağınızı düşünün. –

+0

Bu sizin için çalıştın mı @ 13aal? –

İlgili konular