Skip to content

Commit

Permalink
change baseurl and ip to instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
matugm committed May 12, 2012
1 parent a82ca08 commit 2498a61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions dirfuzz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class String
puts banner + "Please use -h for help."
exit()
else
$baseurl = ARGV[0].sub("http://","")
$baseurl.chop! if $baseurl[-1] == "/"
@baseurl = ARGV[0].sub("http://","")
@baseurl.chop! if @baseurl[-1] == "/"
end

@options = {}
Expand Down Expand Up @@ -189,13 +189,13 @@ class String

puts "\e[H\e[2J" if $stdout.isatty

$ip = Http.resolv($baseurl) # Resolve name or just return the ip
@ip = Http.resolv(@baseurl) # Resolve name or just return the ip


print_output("%green %yellow","[+] Starting fuzz for:",$baseurl)
print_output("%green %yellow","[+] Starting fuzz for:",@baseurl)

begin
get = Http.get($baseurl,$ip,@options[:path],headers)
get = Http.get(@baseurl,@ip,@options[:path],headers)
rescue Timeout::Error
puts "[-] Connection timed out - the host isn't responding.\n\n"
exit
Expand All @@ -217,7 +217,7 @@ class String
elsif get.headers['Location'].include? "http://"
get = Http.open(get.headers['Location'])
else
get = Http.open($baseurl + get.headers['Location'])
get = Http.open(@baseurl + get.headers['Location'])
end
end

Expand All @@ -236,7 +236,7 @@ class String
level = @options[:links].to_i
print_output("%blue","\n[+] Links: ")
print "Crawling..." if level == 1
crawler = Crawler.new($baseurl,html)
crawler = Crawler.new(@baseurl,html)
crawler.run(level)
puts "#{reset}"
crawler.print_links @ofile
Expand Down Expand Up @@ -268,15 +268,15 @@ def redir_do(location,output)
end

if relative
host = $baseurl
host = @baseurl
if location[1] == nil
lpath = @options[:path] + location[0]
else
lpath = "/" + location[1]
end
end

fredirect = Http.get(host,$ip,lpath,"") # Send request to find out more about the redirect...
fredirect = Http.get(host,@ip,lpath,"") # Send request to find out more about the redirect...

print "#{@reset}" if $stdout.isatty
print_output(output[0] + " [ -> " + orig_loc + " " + fredirect.code.to_s + "]",output[1])
Expand All @@ -290,8 +290,8 @@ def redir_do(location,output)
req = url.chomp
path = @options[:path] + req + ext # Add together the start path, the dir/file to test and the extension

get = Http.get($baseurl,$ip,path,headers) if @options[:get] == true # Send a get request (default)
get = Http.head($baseurl,$ip,path,headers) if @options[:get] == false # Send a head request
get = Http.get(@baseurl,@ip,path,headers) if @options[:get] == true # Send a get request (default)
get = Http.head(@baseurl,@ip,path,headers) if @options[:get] == false # Send a head request
code = Code.new(get)

path.chomp!
Expand Down
2 changes: 1 addition & 1 deletion lib/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def self.request (host,ip,path,method,headers = "",data = "")
end

def self.send_request (ip, port, buff)
# TO DO: Add SSL and proxy support
# TO DO: Add proxy support
sc = timeout 5 do # Throw an exception Timeout::Error if we can't connect in 5 seconds
connection(ip, port)
end
Expand Down

0 comments on commit 2498a61

Please sign in to comment.