Last active
December 19, 2015 01:09
-
-
Save claudijd/5873527 to your computer and use it in GitHub Desktop.
A quick and dirty DNS/HTTP/HTTPS Bruterforcer for my home boy Barry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Low-down DNS/HTTP/HTTPS Bruteforcing Script for Barry | |
require 'resolv' | |
require 'rest_client' | |
# SETUP ############## | |
# | |
# You need two gems 'resolv' and 'rest_client' | |
# | |
# gem install resolv (may be a default in ruby, can't remember) | |
# gem install rest-client (definately need to install this guy) | |
# | |
##################### | |
# CONFIGURATION #### | |
# The number of threads you want to run (more threads equal faster and maybe less accurate results) | |
num_threads = 30 | |
################### | |
## MAGIC SAUCE - DON'T TOUCH #### | |
def load_domain_file(name) | |
File.open(name, "r") | |
end | |
def resolve_ip(domain) | |
begin | |
Resolv.getaddress "#{domain}" | |
rescue Resolv::ResolvError | |
return "resolve_error" | |
end | |
end | |
def get_http(domain, scheme) | |
begin | |
RestClient::Request.execute( | |
:method => :get, | |
:url => "#{scheme}://#{domain}", | |
:timeout => 5, | |
:open_timeout => 5 | |
).code.to_s | |
rescue RestClient::RequestTimeout | |
return "timeout" | |
rescue SocketError | |
return "socket_error" | |
rescue RestClient::ResourceNotFound | |
return "404" | |
rescue RestClient::BadGateway | |
return "502" | |
rescue Errno::ECONNREFUSED | |
return "connection_refused" | |
end | |
end | |
def phase_1(domain) | |
resolve_response = resolve_ip(domain) | |
if resolve_response == "resolve_error" | |
puts "down" + "," + domain + "," + "nil" + "," + "nil" + "," + "nil" | |
else | |
http_response = get_http(domain, "http") || "nil" | |
https_response = get_http(domain, "https") || "nil" | |
if http_response == "200" || | |
https_response == "200" | |
puts "up" + "," + domain + "," + resolve_response + "," + http_response + "," + https_response | |
else | |
puts "down" + "," + domain + "," + resolve_response + "," + http_response + "," + https_response | |
end | |
end | |
end | |
start_time = Time.now | |
puts "STATUS,DOMAIN,IP,HTTP_RESPONSE,HTTPS_RESPONSE" | |
file = load_domain_file(ARGV[0]) | |
bq = SizedQueue.new(num_threads) | |
producer_thread = Thread.new(bq) do |queue| | |
file.each_line do |domain| | |
queue << domain.chomp | |
end | |
num_threads.times do | |
queue << :end_of_producer | |
end | |
end | |
consumer_threads = [] | |
num_threads.times do | |
consumer_threads << Thread.new(bq) do |queue| | |
until (domain = queue.pop) === :end_of_producer | |
phase_1(domain) | |
end | |
end | |
end | |
consumer_threads.each {|t| t.join} | |
end_time = Time.now | |
time_lapsed = end_time - start_time | |
puts "Completed in #{time_lapsed} seconds" | |
############# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment