Skip to content

Commit 2971e50

Browse files
author
Tod Beardsley
committed
Land rapid7#1949, make dirbusting optional for crawler
2 parents d2df323 + b509ac8 commit 2971e50

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

lib/anemone/core.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class Core
5353
# accept cookies from the server and send them back?
5454
:accept_cookies => false,
5555
# skip any link with a query string? e.g. http://foo.com/?u=user
56-
:skip_query_strings => false
56+
:skip_query_strings => false,
57+
:dirbust => true
5758
}
5859

5960
# Create setter methods for all options to be called from the crawl block

lib/anemone/page.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(url, params = {})
5555
@url = url
5656
@data = OpenStruct.new
5757

58+
@dirbust = params[:dirbust]
5859
@code = params[:code]
5960
@headers = params[:headers] || {}
6061
@headers['content-type'] ||= ['']
@@ -83,7 +84,10 @@ def self.extractors
8384

8485
def run_extractors
8586
return [] if !doc
86-
self.class.extractors.map { |e| e.new( self ).run rescue next }.flatten.
87+
self.class.extractors.map do |e|
88+
next if e == Extractors::Dirbuster && !dirbust?
89+
e.new( self ).run rescue next
90+
end.flatten.
8791
compact.map do |p|
8892
abs = to_absolute( URI( p ) ) rescue next
8993
!in_domain?( abs ) ? nil : abs
@@ -181,6 +185,10 @@ def to_absolute(link)
181185
return absolute
182186
end
183187

188+
def dirbust?
189+
@dirbust
190+
end
191+
184192
#
185193
# Returns +true+ if *uri* is in the same domain as the page, returns
186194
# +false+ otherwise

lib/anemone/rex_http.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def fetch_pages(url, referer = nil, depth = nil)
4646
:referer => referer,
4747
:depth => depth,
4848
:redirect_to => redirect_to,
49-
:response_time => response_time)
49+
:response_time => response_time,
50+
:dirbust => @opts[:dirbust]
51+
)
5052
# Store the associated raw HTTP request
5153
page.request = response.request
5254
pages << page

lib/msf/core/auxiliary/crawler.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def initialize(info = {})
3232

3333
register_advanced_options(
3434
[
35+
OptBool.new('RUN_DIRBUSTER', [ false, 'The maximum number of pages to crawl per URL', true]),
3536
OptInt.new('RequestTimeout', [false, 'The maximum number of seconds to wait for a reply', 15]),
3637
OptInt.new('RedirectLimit', [false, 'The maximum number of redirects for a single request', 5]),
3738
OptInt.new('RetryLimit', [false, 'The maximum number of attempts for a single request', 5]),
@@ -173,6 +174,10 @@ def max_crawl_threads
173174
datastore['MAX_THREADS']
174175
end
175176

177+
def dirbust?
178+
datastore['RUN_DIRBUSTER']
179+
end
180+
176181
# Scrub links that end in these extensions. If more or less is
177182
# desired by a particular module, this should get redefined.
178183
def get_link_filter
@@ -275,6 +280,7 @@ def crawler_options(t)
275280
opts[:framework] = framework
276281
opts[:module] = self
277282
opts[:timeout] = get_connection_timeout
283+
opts[:dirbust] = dirbust?
278284

279285
if (t[:headers] and t[:headers].length > 0)
280286
opts[:inject_headers] = t[:headers]

0 commit comments

Comments
 (0)