Skip to main content
edited tags
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473
deleted 60 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

I have the following code that will skip certain URLs if needed:

SEARCH = "inurl:index.php?id="

def get_urls
  puts "Searching for possible SQL vulnerable sites, using search query #{SEARCH}"
  agent = Mechanize.new
  agent.user_agent = @user_agent
  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'
          next if str_list[1].split('/')[2] == 'search.clearch.org'
          next if str_list[1].split('/')[2] == 'duckfm.net'
          next if str_list[1].split('/')[2] == 'search1.speedbit.com'
          next if str_list[1].split('/')[2] == 'yoursearch.me'
          next if str_list[1].split('/')[2] == 'search.speedbit.com'
          next if str_list[1].split('/')[1] == 'ads/preferences?hl=en'
          next if str_list[1].split('/')[2] == 'www.sa-k.net'
          next if str_list[1].split('/')[2] == 'github.com'
          next if str_list[1].split('/')[2] == 'stackoverflow.com'
          urls_to_log = URI.decode(urls)
          puts "Site found: #{urls_to_log}"
          sleep(1)
          File.open("#{PATH}/SQL_sites_to_check.txt", 'a+') { |s| s.puts("#{urls_to_log}'") }
        end
      end
  puts "Possible vulnerable sites dumped into #{PATH}/SQL_sites_to_check.txt"
end

Is there a better more readable, less smellsomesmelly, way to write the next if's? I mean this just looks terrible... Thanks ahead of time!

I have the following code that will skip certain URLs if needed:

SEARCH = "inurl:index.php?id="

def get_urls
  puts "Searching for possible SQL vulnerable sites, using search query #{SEARCH}"
  agent = Mechanize.new
  agent.user_agent = @user_agent
  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'
          next if str_list[1].split('/')[2] == 'search.clearch.org'
          next if str_list[1].split('/')[2] == 'duckfm.net'
          next if str_list[1].split('/')[2] == 'search1.speedbit.com'
          next if str_list[1].split('/')[2] == 'yoursearch.me'
          next if str_list[1].split('/')[2] == 'search.speedbit.com'
          next if str_list[1].split('/')[1] == 'ads/preferences?hl=en'
          next if str_list[1].split('/')[2] == 'www.sa-k.net'
          next if str_list[1].split('/')[2] == 'github.com'
          next if str_list[1].split('/')[2] == 'stackoverflow.com'
          urls_to_log = URI.decode(urls)
          puts "Site found: #{urls_to_log}"
          sleep(1)
          File.open("#{PATH}/SQL_sites_to_check.txt", 'a+') { |s| s.puts("#{urls_to_log}'") }
        end
      end
  puts "Possible vulnerable sites dumped into #{PATH}/SQL_sites_to_check.txt"
end

Is there a better more readable, less smellsome, way to write the next if's? I mean this just looks terrible... Thanks ahead of time!

I have the following code that will skip certain URLs if needed:

SEARCH = "inurl:index.php?id="

def get_urls
  puts "Searching for possible SQL vulnerable sites, using search query #{SEARCH}"
  agent = Mechanize.new
  agent.user_agent = @user_agent
  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'
          next if str_list[1].split('/')[2] == 'search.clearch.org'
          next if str_list[1].split('/')[2] == 'duckfm.net'
          next if str_list[1].split('/')[2] == 'search1.speedbit.com'
          next if str_list[1].split('/')[2] == 'yoursearch.me'
          next if str_list[1].split('/')[2] == 'search.speedbit.com'
          next if str_list[1].split('/')[1] == 'ads/preferences?hl=en'
          next if str_list[1].split('/')[2] == 'www.sa-k.net'
          next if str_list[1].split('/')[2] == 'github.com'
          next if str_list[1].split('/')[2] == 'stackoverflow.com'
          urls_to_log = URI.decode(urls)
          puts "Site found: #{urls_to_log}"
          sleep(1)
          File.open("#{PATH}/SQL_sites_to_check.txt", 'a+') { |s| s.puts("#{urls_to_log}'") }
        end
      end
  puts "Possible vulnerable sites dumped into #{PATH}/SQL_sites_to_check.txt"
end

Is there a better more readable, less smelly, way to write the next if's?

edited title; edited tags
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Better way Skipping Google search results that point to skip the URLS?certain sites

Source Link
13aal
  • 832
  • 1
  • 9
  • 30
Loading