Skip to content

Commit

Permalink
Retab lib
Browse files Browse the repository at this point in the history
  • Loading branch information
tabassassin committed Aug 30, 2013
1 parent 5b32c63 commit 7e5e0f7
Show file tree
Hide file tree
Showing 886 changed files with 245,072 additions and 245,072 deletions.
4 changes: 2 additions & 2 deletions lib/anemone/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ def skip_link?(link)
#
# Kills all active threads
#
def shutdown
def shutdown
@tentacles.each {|t| t.kill rescue nil }
@pages = nil
end
end

end
end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/anchors.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Anchors < Anemone::Extractors::Base

def run
doc.search( '//a[@href]' ).map { |a| a['href'] }
end
def run
doc.search( '//a[@href]' ).map { |a| a['href'] }
end

end
14 changes: 7 additions & 7 deletions lib/anemone/extractors/dirbuster.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class Anemone::Extractors::Dirbuster < Anemone::Extractors::Base

def run
return [] if page.code.to_i != 200
def run
return [] if page.code.to_i != 200

@@dirs ||= nil
@@dirs ||= nil

return @@dirs if @@dirs
@@dirs = IO.read( File.dirname( __FILE__ ) + '/dirbuster/directories' ).split( "\n" )
end
return @@dirs if @@dirs
@@dirs = IO.read( File.dirname( __FILE__ ) + '/dirbuster/directories' ).split( "\n" )
end
end
8 changes: 4 additions & 4 deletions lib/anemone/extractors/forms.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Forms < Anemone::Extractors::Base

def run
doc.search( '//form[@action]' ).map { |a| a['action'] }
end
def run
doc.search( '//form[@action]' ).map { |a| a['action'] }
end
end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/frames.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Frames < Anemone::Extractors::Base

def run
doc.css( 'frame', 'iframe' ).map { |a| a.attributes['src'].content rescue next }
end
def run
doc.css( 'frame', 'iframe' ).map { |a| a.attributes['src'].content rescue next }
end

end
86 changes: 43 additions & 43 deletions lib/anemone/extractors/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@

class Anemone::Extractors::Generic < Anemone::Extractors::Base

def run
URI.extract( doc.to_s, %w(http https) ).map do |u|
#
# This extractor needs to be a tiny bit intelligent because
# due to its generic nature it'll inevitably match some garbage.
#
# For example, if some JS code contains:
#
# var = 'http://blah.com?id=1'
#
# or
#
# var = { 'http://blah.com?id=1', 1 }
#
#
# The URI.extract call will match:
#
# http://blah.com?id=1'
#
# and
#
# http://blah.com?id=1',
#
# respectively.
#
if !includes_quotes?( u )
u
else
if html.include?( "'#{u}" )
u.split( '\'' ).first
elsif html.include?( "\"#{u}" )
u.split( '"' ).first
else
u
end
end
end
rescue
[]
end
def run
URI.extract( doc.to_s, %w(http https) ).map do |u|
#
# This extractor needs to be a tiny bit intelligent because
# due to its generic nature it'll inevitably match some garbage.
#
# For example, if some JS code contains:
#
# var = 'http://blah.com?id=1'
#
# or
#
# var = { 'http://blah.com?id=1', 1 }
#
#
# The URI.extract call will match:
#
# http://blah.com?id=1'
#
# and
#
# http://blah.com?id=1',
#
# respectively.
#
if !includes_quotes?( u )
u
else
if html.include?( "'#{u}" )
u.split( '\'' ).first
elsif html.include?( "\"#{u}" )
u.split( '"' ).first
else
u
end
end
end
rescue
[]
end

def includes_quotes?( url )
url.include?( '\'' ) || url.include?( '"' )
end
def includes_quotes?( url )
url.include?( '\'' ) || url.include?( '"' )
end

end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/links.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Links < Anemone::Extractors::Base

def run
doc.search( "//link[@href]" ).map { |a| a['href'] }
end
def run
doc.search( "//link[@href]" ).map { |a| a['href'] }
end

end
38 changes: 19 additions & 19 deletions lib/anemone/extractors/meta_refresh.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
class Anemone::Extractors::MetaRefresh < Anemone::Extractors::Base

def run
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
begin
_, url = url['content'].split( ';', 2 )
next if !url
unquote( url.split( '=', 2 ).last )
rescue
next
end
end
rescue
nil
end
def run
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
begin
_, url = url['content'].split( ';', 2 )
next if !url
unquote( url.split( '=', 2 ).last )
rescue
next
end
end
rescue
nil
end

def unquote( str )
[ '\'', '"' ].each do |q|
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
end
str
end
def unquote( str )
[ '\'', '"' ].each do |q|
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
end
str
end

end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/scripts.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Scripts < Anemone::Extractors::Base

def run
doc.search( '//script[@src]' ).map { |a| a['src'] }
end
def run
doc.search( '//script[@src]' ).map { |a| a['src'] }
end

end
8 changes: 4 additions & 4 deletions lib/anemone/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def self.extractors
def run_extractors
return [] if !doc
self.class.extractors.map do |e|
next if e == Extractors::Dirbuster && !dirbust?
e.new( self ).run rescue next
next if e == Extractors::Dirbuster && !dirbust?
e.new( self ).run rescue next
end.flatten.
compact.map do |p|
abs = to_absolute( URI( p ) ) rescue next
Expand Down Expand Up @@ -186,7 +186,7 @@ def to_absolute(link)
end

def dirbust?
@dirbust
@dirbust
end

#
Expand Down Expand Up @@ -240,7 +240,7 @@ def self.from_hash(hash)
end

def dup
Marshal.load( Marshal.dump( self ) )
Marshal.load( Marshal.dump( self ) )
end

end
Expand Down
46 changes: 23 additions & 23 deletions lib/anemone/rex_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fetch_pages(url, referer = nil, depth = nil)
)
# Store the associated raw HTTP request
page.request = response.request
pages << page
pages << page
end

return pages
Expand Down Expand Up @@ -162,11 +162,11 @@ def get_response(url, referer = nil)
response = nil
request = nil
begin
conn = connection(url)
request = conn.request_raw(opts)
response = conn.send_recv(request, @opts[:timeout] || 10 )
rescue ::Errno::EPIPE, ::Timeout::Error
end
conn = connection(url)
request = conn.request_raw(opts)
response = conn.send_recv(request, @opts[:timeout] || 10 )
rescue ::Errno::EPIPE, ::Timeout::Error
end

finish = Time.now()

Expand All @@ -180,28 +180,28 @@ def get_response(url, referer = nil)
end

def connection(url)
context = { }
context['Msf'] = @opts[:framework] if @opts[:framework]
context['MsfExploit'] = @opts[:module] if @opts[:module]

conn = Rex::Proto::Http::Client.new(
url.host,
url.port.to_i,
context,
url.scheme == "https",
'SSLv23',
@opts[:proxies],
context = { }
context['Msf'] = @opts[:framework] if @opts[:framework]
context['MsfExploit'] = @opts[:module] if @opts[:module]

conn = Rex::Proto::Http::Client.new(
url.host,
url.port.to_i,
context,
url.scheme == "https",
'SSLv23',
@opts[:proxies],
@opts[:username],
@opts[:password]
)
)

conn.set_config(
'vhost' => virtual_host(url),
'agent' => user_agent,
conn.set_config(
'vhost' => virtual_host(url),
'agent' => user_agent,
'domain' => @opts[:domain]
)
)

conn
conn
end

def verbose?
Expand Down
Loading

0 comments on commit 7e5e0f7

Please sign in to comment.