cms_scanner 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dff32b05d6da49f0ad5697263e3a1e0a3d011a7
4
- data.tar.gz: 5373a9c0a91523b45287aa577f07ce53a59fd59e
3
+ metadata.gz: a6741a1ed0e43eb4ee6a3b37a9b61f1299d9446d
4
+ data.tar.gz: 3b43b6dd3e55518d83f4995dd4d7770e41217731
5
5
  SHA512:
6
- metadata.gz: a8c5b0c833ac6514ab85a5a1c5d00a7932eb41c33ad44bfcba544935b84c7405771b06b8ec833d3b211317af4412515db9b075cc88f17a56adcb1a64b2907ed5
7
- data.tar.gz: 1a568813897294b4958f5f3f23ce245b64fa5322698a353bf5504bf599f8ef02a90c5a96dcf52b53dce0e3ccd7acc3225a9feae590cbc6f7b1c7bee41c4f6ba4
6
+ metadata.gz: 1ecfc37f369814a5ffe4e7d9bd7e024555709cc92b4a4775bfbac3040b012b4995f0fb1a4fd35c77a16ce704e6b3549d981f4cf3abe7520ba020528b704582d3
7
+ data.tar.gz: a97daef772ba84ccf58768c38f5705c41da72174fc30f44badea0e0420f97bec73df414bd0c40f065c21609701b621fe56bb0a54f8b9e93633fea6af3e81cf79
@@ -25,6 +25,10 @@ module CMSScanner
25
25
  def cli_browser_options
26
26
  [
27
27
  OptString.new(['--user-agent VALUE', '--ua']),
28
+ OptBoolean.new(['--random-user-agent', '--rua',
29
+ 'Use a random user-agent for each scan']),
30
+ OptFilePath.new(['--user-agents-list FILE-PATH',
31
+ 'List of agents to use with --random-user-agent'], exists: true),
28
32
  OptCredentials.new(['--http-auth login:password']),
29
33
  OptPositiveInteger.new(['--max-threads VALUE', '-t', 'The max threads to use'],
30
34
  default: 5),
@@ -0,0 +1,46 @@
1
+ # Windows
2
+ Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5
3
+ Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/9.0.601.0 Safari/534.14
4
+ Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.27 (KHTML, like Gecko) Chrome/12.0.712.0 Safari/534.27
5
+ Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.24 Safari/535.1
6
+ Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0E)
7
+ Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
8
+ Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
9
+ Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
10
+ Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6
11
+ Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1
12
+ Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120403211507 Firefox/12.0
13
+ Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120427 Firefox/15.0a1
14
+ Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)
15
+ Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
16
+ Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0)
17
+ Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00
18
+ Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5
19
+
20
+ # MAC
21
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.15 Safari/534.13
22
+ Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15
23
+ Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
24
+ Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3
25
+ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3
26
+ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2; rv:10.0.1) Gecko/20100101 Firefox/10.0.1
27
+ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10
28
+
29
+ # Linux
30
+ Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.20 Safari/535.1
31
+ Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Ubuntu/10.10 Chromium/12.0.703.0 Chrome/12.0.703.0 Safari/534.24
32
+ Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100915 Gentoo Firefox/3.6.9
33
+ Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20120421 Gecko Firefox/11.0
34
+ Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0
35
+ Opera/9.80 (X11; Linux x86_64; U; pl) Presto/2.7.62 Version/11.00
36
+ Mozilla/5.0 (X11; U; Linux x86_64; us; rv:1.9.1.19) Gecko/20110430 shadowfox/7.0 (like Firefox/7.0
37
+
38
+ # iPad
39
+ Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53
40
+ Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53
41
+ Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25
42
+
43
+ # iPhone
44
+ Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53
45
+ Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53
46
+ Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53
@@ -8,10 +8,12 @@ module CMSScanner
8
8
  :connect_timeout,
9
9
  :http_auth,
10
10
  :max_threads,
11
+ :user_agent,
12
+ :user_agents_list,
11
13
  :proxy,
12
14
  :proxy_auth,
13
- :request_timeout,
14
- :user_agent
15
+ :random_user_agent,
16
+ :request_timeout
15
17
  ]
16
18
 
17
19
  attr_accessor(*OPTIONS)
@@ -36,9 +38,33 @@ module CMSScanner
36
38
  hydra.max_concurrency = @max_threads
37
39
  end
38
40
 
39
- # Default user agent
41
+ # @return [ String ] The path to the user agents list
42
+ def user_agents_list
43
+ @user_agents_list ||= File.join(APP_DIR, 'user_agents.txt')
44
+ end
45
+
46
+ # @return [ Array<String> ]
47
+ def user_agents
48
+ return @user_agents if @user_agents
49
+
50
+ @user_agents = []
51
+
52
+ File.open(user_agents_list).each do |line|
53
+ next if line == "\n" || line[0, 1] == '#'
54
+ @user_agents << line.chomp
55
+ end
56
+
57
+ @user_agents
58
+ end
59
+
60
+ # @return [ String ]
61
+ def default_user_agent
62
+ "CMSScanner v#{VERSION}"
63
+ end
64
+
65
+ # @return [ String ] The user agent
40
66
  def user_agent
41
- @user_agent ||= "CMSScanner v#{VERSION}"
67
+ @user_agent ||= random_user_agent ? user_agents.sample : default_user_agent
42
68
  end
43
69
  end
44
70
  end
@@ -15,8 +15,10 @@ module CMSScanner
15
15
  #
16
16
  # @return [ Findings ]
17
17
  def run(opts = {})
18
+ methods = symbols_from_mode(opts[:mode])
19
+
18
20
  each do |finder|
19
- symbols_from_mode(opts[:mode]).each do |symbol|
21
+ methods.each do |symbol|
20
22
  [*finder.send(symbol, opts.merge(found: findings))].compact.each do |found|
21
23
  findings << found
22
24
  end
@@ -1,3 +1,4 @@
1
1
  require 'cms_scanner/target/server/generic'
2
2
  require 'cms_scanner/target/server/apache'
3
3
  require 'cms_scanner/target/server/iis'
4
+ require 'cms_scanner/target/server/nginx'
@@ -6,37 +6,18 @@ module CMSScanner
6
6
  # @param [ String ] path
7
7
  # @param [ Hash ] params The request params
8
8
  #
9
- # @return [ Symbol ] :apache
9
+ # @return [ Symbol ] :Apache
10
10
  def server(_path = nil, _params = {})
11
11
  :Apache
12
12
  end
13
13
 
14
- # @param [ String ] path
15
- # @param [ Hash ] params The request params
16
- #
17
- # @return [ Boolean ] true if url(path) has the directory
18
- # listing enabled, false otherwise
19
- def directory_listing?(path = nil, params = {})
20
- res = NS::Browser.get(url(path), params)
21
-
22
- res.code == 200 && res.body =~ /<h1>Index of/ ? true : false
23
- end
24
-
25
14
  # @param [ String ] path
26
15
  # @param [ Hash ] params The request params
27
16
  #
28
17
  # @return [ Array<String> ] The first level of directories/files listed,
29
18
  # or an empty array if none
30
19
  def directory_listing_entries(path = nil, params = {})
31
- return [] unless directory_listing?(path, params)
32
-
33
- found = []
34
-
35
- NS::Browser.get(url(path), params).html.css('td a').each do |node|
36
- found << node.text.to_s
37
- end
38
-
39
- found[1..-1] # returns the array w/o the first element 'Parent Directory'
20
+ super(path, params, 'td a')
40
21
  end
41
22
  end
42
23
  end
@@ -1,12 +1,12 @@
1
1
  module CMSScanner
2
2
  class Target < WebSite
3
3
  module Server
4
- # Some Apche specific implementation
4
+ # Generic Server methods
5
5
  module Generic
6
6
  # @param [ String ] path
7
7
  # @param [ Hash ] params The request params
8
8
  #
9
- # @return [ Symbol ] The detected remote server (:Apache, :IIS)
9
+ # @return [ Symbol ] The detected remote server (:Apache, :IIS, :Nginx)
10
10
  def server(path = nil, params = {})
11
11
  headers = headers(path, params)
12
12
 
@@ -17,6 +17,8 @@ module CMSScanner
17
17
  :Apache
18
18
  when /\AMicrosoft-IIS/i
19
19
  :IIS
20
+ when /\Anginx/
21
+ :Nginx
20
22
  end
21
23
  end
22
24
 
@@ -28,6 +30,42 @@ module CMSScanner
28
30
  # The HEAD method might be rejected by some servers ... maybe switch to GET ?
29
31
  NS::Browser.head(url(path), params).headers
30
32
  end
33
+
34
+ # @param [ String ] path
35
+ # @param [ Hash ] params The request params
36
+ #
37
+ # @return [ Boolean ] true if url(path) has the directory
38
+ # listing enabled, false otherwise
39
+ def directory_listing?(path = nil, params = {})
40
+ res = NS::Browser.get(url(path), params)
41
+
42
+ res.code == 200 && res.body =~ /<h1>Index of/ ? true : false
43
+ end
44
+
45
+ # @param [ String ] path
46
+ # @param [ Hash ] params The request params
47
+ # @param [ String ] selector
48
+ # @param [ Regexp ] ignore
49
+ #
50
+ # @return [ Array<String> ] The first level of directories/files listed,
51
+ # or an empty array if none
52
+ def directory_listing_entries(
53
+ path = nil, params = {},
54
+ selector = 'pre a', ignore = /parent directory/i
55
+ )
56
+ return [] unless directory_listing?(path, params)
57
+
58
+ found = []
59
+
60
+ NS::Browser.get(url(path), params).html.css(selector).each do |node|
61
+ entry = node.text.to_s
62
+
63
+ next if entry =~ ignore
64
+ found << entry
65
+ end
66
+
67
+ found
68
+ end
31
69
  end
32
70
  end
33
71
  end
@@ -6,7 +6,7 @@ module CMSScanner
6
6
  # @param [ String ] path
7
7
  # @param [ Hash ] params The request params
8
8
  #
9
- # @return [ Symbol ] :iis
9
+ # @return [ Symbol ] :IIS
10
10
  def server(_path = nil, _params = {})
11
11
  :IIS
12
12
  end
@@ -21,26 +21,6 @@ module CMSScanner
21
21
 
22
22
  res.code == 200 && res.body =~ /<H1>#{uri.host} - \// ? true : false
23
23
  end
24
-
25
- # @param [ String ] path
26
- # @param [ Hash ] params The request params
27
- #
28
- # @return [ Array<String> ] The first level of directories/files listed,
29
- # or an empty array if none
30
- def directory_listing_entries(path = nil, params = {})
31
- return [] unless directory_listing?(path, params)
32
-
33
- found = []
34
-
35
- NS::Browser.get(url(path), params).html.css('pre a').each do |node|
36
- entry = node.text.to_s
37
-
38
- next if entry == '[To Parent Directory]'
39
- found << entry
40
- end
41
-
42
- found
43
- end
44
24
  end
45
25
  end
46
26
  end
@@ -0,0 +1,25 @@
1
+ module CMSScanner
2
+ class Target < WebSite
3
+ module Server
4
+ # Some Nginx specific implementation
5
+ module Nginx
6
+ # @param [ String ] path
7
+ # @param [ Hash ] params The request params
8
+ #
9
+ # @return [ Symbol ] :Nginx
10
+ def server(_path = nil, _params = {})
11
+ :Nginx
12
+ end
13
+
14
+ # @param [ String ] path
15
+ # @param [ Hash ] params The request params
16
+ #
17
+ # @return [ Array<String> ] The first level of directories/files listed,
18
+ # or an empty array if none
19
+ def directory_listing_entries(path = nil, params = {})
20
+ super(path, params, 'pre a', /\A\.\./i)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,4 +1,4 @@
1
1
  # Version
2
2
  module CMSScanner
3
- VERSION = '0.0.20'
3
+ VERSION = '0.0.21'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cms_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - WPScanTeam - Erwan Le Rousseau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-13 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opt_parse_validator
@@ -238,6 +238,7 @@ files:
238
238
  - app/models/robots_txt.rb
239
239
  - app/models/version.rb
240
240
  - app/models/xml_rpc.rb
241
+ - app/user_agents.txt
241
242
  - app/views/cli/core/banner.erb
242
243
  - app/views/cli/core/finished.erb
243
244
  - app/views/cli/core/started.erb
@@ -285,6 +286,7 @@ files:
285
286
  - lib/cms_scanner/target/server/apache.rb
286
287
  - lib/cms_scanner/target/server/generic.rb
287
288
  - lib/cms_scanner/target/server/iis.rb
289
+ - lib/cms_scanner/target/server/nginx.rb
288
290
  - lib/cms_scanner/typhoeus/hydra.rb
289
291
  - lib/cms_scanner/typhoeus/response.rb
290
292
  - lib/cms_scanner/version.rb