Skip to content

Commit 8566c1d

Browse files
author
jvazquez-r7
committed
Land rapid7#2330, @todb-r7's retab rumpus war
2 parents cc83840 + 9f3a5dc commit 8566c1d

File tree

3,150 files changed

+524440
-524440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,150 files changed

+524440
-524440
lines changed

lib/anemone/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ def skip_link?(link)
298298
#
299299
# Kills all active threads
300300
#
301-
def shutdown
301+
def shutdown
302302
@tentacles.each {|t| t.kill rescue nil }
303303
@pages = nil
304-
end
304+
end
305305

306306
end
307307
end

lib/anemone/extractors/anchors.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Anemone::Extractors::Anchors < Anemone::Extractors::Base
22

3-
def run
4-
doc.search( '//a[@href]' ).map { |a| a['href'] }
5-
end
3+
def run
4+
doc.search( '//a[@href]' ).map { |a| a['href'] }
5+
end
66

77
end

lib/anemone/extractors/dirbuster.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Anemone::Extractors::Dirbuster < Anemone::Extractors::Base
22

3-
def run
4-
return [] if page.code.to_i != 200
3+
def run
4+
return [] if page.code.to_i != 200
55

6-
@@dirs ||= nil
6+
@@dirs ||= nil
77

8-
return @@dirs if @@dirs
9-
@@dirs = IO.read( File.dirname( __FILE__ ) + '/dirbuster/directories' ).split( "\n" )
10-
end
11-
8+
return @@dirs if @@dirs
9+
@@dirs = IO.read( File.dirname( __FILE__ ) + '/dirbuster/directories' ).split( "\n" )
10+
end
11+
1212
end

lib/anemone/extractors/forms.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Anemone::Extractors::Forms < Anemone::Extractors::Base
22

3-
def run
4-
doc.search( '//form[@action]' ).map { |a| a['action'] }
5-
end
6-
3+
def run
4+
doc.search( '//form[@action]' ).map { |a| a['action'] }
5+
end
6+
77
end

lib/anemone/extractors/frames.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Anemone::Extractors::Frames < Anemone::Extractors::Base
22

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

77
end

lib/anemone/extractors/generic.rb

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@
22

33
class Anemone::Extractors::Generic < Anemone::Extractors::Base
44

5-
def run
6-
URI.extract( doc.to_s, %w(http https) ).map do |u|
7-
#
8-
# This extractor needs to be a tiny bit intelligent because
9-
# due to its generic nature it'll inevitably match some garbage.
10-
#
11-
# For example, if some JS code contains:
12-
#
13-
# var = 'http://blah.com?id=1'
14-
#
15-
# or
16-
#
17-
# var = { 'http://blah.com?id=1', 1 }
18-
#
19-
#
20-
# The URI.extract call will match:
21-
#
22-
# http://blah.com?id=1'
23-
#
24-
# and
25-
#
26-
# http://blah.com?id=1',
27-
#
28-
# respectively.
29-
#
30-
if !includes_quotes?( u )
31-
u
32-
else
33-
if html.include?( "'#{u}" )
34-
u.split( '\'' ).first
35-
elsif html.include?( "\"#{u}" )
36-
u.split( '"' ).first
37-
else
38-
u
39-
end
40-
end
41-
end
42-
rescue
43-
[]
44-
end
5+
def run
6+
URI.extract( doc.to_s, %w(http https) ).map do |u|
7+
#
8+
# This extractor needs to be a tiny bit intelligent because
9+
# due to its generic nature it'll inevitably match some garbage.
10+
#
11+
# For example, if some JS code contains:
12+
#
13+
# var = 'http://blah.com?id=1'
14+
#
15+
# or
16+
#
17+
# var = { 'http://blah.com?id=1', 1 }
18+
#
19+
#
20+
# The URI.extract call will match:
21+
#
22+
# http://blah.com?id=1'
23+
#
24+
# and
25+
#
26+
# http://blah.com?id=1',
27+
#
28+
# respectively.
29+
#
30+
if !includes_quotes?( u )
31+
u
32+
else
33+
if html.include?( "'#{u}" )
34+
u.split( '\'' ).first
35+
elsif html.include?( "\"#{u}" )
36+
u.split( '"' ).first
37+
else
38+
u
39+
end
40+
end
41+
end
42+
rescue
43+
[]
44+
end
4545

46-
def includes_quotes?( url )
47-
url.include?( '\'' ) || url.include?( '"' )
48-
end
46+
def includes_quotes?( url )
47+
url.include?( '\'' ) || url.include?( '"' )
48+
end
4949

5050
end

lib/anemone/extractors/links.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Anemone::Extractors::Links < Anemone::Extractors::Base
22

3-
def run
4-
doc.search( "//link[@href]" ).map { |a| a['href'] }
5-
end
3+
def run
4+
doc.search( "//link[@href]" ).map { |a| a['href'] }
5+
end
66

77
end
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
class Anemone::Extractors::MetaRefresh < Anemone::Extractors::Base
22

3-
def run
4-
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
5-
begin
6-
_, url = url['content'].split( ';', 2 )
7-
next if !url
8-
unquote( url.split( '=', 2 ).last )
9-
rescue
10-
next
11-
end
12-
end
13-
rescue
14-
nil
15-
end
3+
def run
4+
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
5+
begin
6+
_, url = url['content'].split( ';', 2 )
7+
next if !url
8+
unquote( url.split( '=', 2 ).last )
9+
rescue
10+
next
11+
end
12+
end
13+
rescue
14+
nil
15+
end
1616

17-
def unquote( str )
18-
[ '\'', '"' ].each do |q|
19-
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
20-
end
21-
str
22-
end
17+
def unquote( str )
18+
[ '\'', '"' ].each do |q|
19+
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
20+
end
21+
str
22+
end
2323

2424
end

lib/anemone/extractors/scripts.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Anemone::Extractors::Scripts < Anemone::Extractors::Base
22

3-
def run
4-
doc.search( '//script[@src]' ).map { |a| a['src'] }
5-
end
3+
def run
4+
doc.search( '//script[@src]' ).map { |a| a['src'] }
5+
end
66

77
end

lib/anemone/page.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def self.extractors
8585
def run_extractors
8686
return [] if !doc
8787
self.class.extractors.map do |e|
88-
next if e == Extractors::Dirbuster && !dirbust?
89-
e.new( self ).run rescue next
88+
next if e == Extractors::Dirbuster && !dirbust?
89+
e.new( self ).run rescue next
9090
end.flatten.
9191
compact.map do |p|
9292
abs = to_absolute( URI( p ) ) rescue next
@@ -186,7 +186,7 @@ def to_absolute(link)
186186
end
187187

188188
def dirbust?
189-
@dirbust
189+
@dirbust
190190
end
191191

192192
#
@@ -240,7 +240,7 @@ def self.from_hash(hash)
240240
end
241241

242242
def dup
243-
Marshal.load( Marshal.dump( self ) )
243+
Marshal.load( Marshal.dump( self ) )
244244
end
245245

246246
end

0 commit comments

Comments
 (0)