Skip to content

Commit fcfce9e

Browse files
David MaloneyDavid Maloney
authored andcommitted
Merge branch 'staging/electro-release' into feature/MSP-10992/scanner-dry
2 parents ab71111 + 1d430db commit fcfce9e

File tree

134 files changed

+2321
-679
lines changed

Some content is hidden

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

134 files changed

+2321
-679
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Gemfile.local.lock
77
.sublime-project
88
# RVM control file, keep this to avoid backdooring Metasploit
99
.rvmrc
10-
.ruby-version
11-
.ruby-gemset
1210
# YARD cache directory
1311
.yardoc
1412
# Mac OS X files

.rubocop.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
LineLength:
2+
Enabled: true
3+
Max: 180
4+
5+
MethodLength:
6+
Enabled: true
7+
Max: 100
8+
9+
Style/ClassLength:
10+
Exclude:
11+
# Most modules are quite large and all contained in one class. This is OK.
12+
- 'modules/**/*'
13+
14+
Style/NumericLiterals:
15+
Enabled: false
16+
17+
Documentation:
18+
Exclude:
19+
- 'modules/**/*'

.ruby-gemset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
metasploit-framework

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.9.3-p547

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and Metasploit's [Common Coding Mistakes](https://github.com/rapid7/metasploit-f
3333
## Code Contributions
3434

3535
* **Do** stick to the [Ruby style guide](https://github.com/bbatsov/ruby-style-guide).
36+
* Similarly, **try** to get Rubocop passing or at least relatively quiet against the files added/modified as part of your contribution
3637
* **Do** follow the [50/72 rule](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for Git commit messages.
3738
* **Do** create a [topic branch](http://git-scm.com/book/en/Git-Branching-Branching-Workflows#Topic-Branches) to work on instead of working directly on `master`.
3839

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ group :db do
77
# Needed for Msf::DbManager
88
gem 'activerecord', '>= 3.0.0', '< 4.0.0'
99
# Metasploit::Credential database models
10-
gem 'metasploit-credential', '~>0.8.2'
10+
gem 'metasploit-credential', '>= 0.8.6', '< 0.9'
1111
# Database models shared between framework and Pro.
1212
gem 'metasploit_data_models', '~> 0.19'
1313
# Needed for module caching in Mdm::ModuleDetails
1414
gem 'pg', '>= 0.11'
1515
end
1616

1717
group :development do
18+
# Style/sanity checking Ruby code
19+
gem 'rubocop'
1820
# Markdown formatting for yard
1921
gem 'redcarpet'
2022
# generating documentation

Gemfile.lock

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PATH
22
remote: .
33
specs:
44
metasploit-framework (4.10.0.pre.dev)
5+
actionpack (< 4.0.0)
56
activesupport (>= 3.0.0, < 4.0.0)
67
bcrypt
78
json
@@ -44,6 +45,7 @@ GEM
4445
arel (3.0.3)
4546
arel-helpers (2.0.1)
4647
activerecord (>= 3.1.0, < 5)
48+
ast (2.0.0)
4749
bcrypt (3.1.7)
4850
builder (3.0.4)
4951
coderay (1.1.0)
@@ -61,7 +63,7 @@ GEM
6163
json (1.8.1)
6264
metasploit-concern (0.1.1)
6365
activesupport (~> 3.0, >= 3.0.0)
64-
metasploit-credential (0.8.3)
66+
metasploit-credential (0.8.6)
6567
metasploit-concern (~> 0.1.0)
6668
metasploit-model (~> 0.26.1)
6769
metasploit_data_models (~> 0.19.4)
@@ -86,8 +88,12 @@ GEM
8688
nokogiri (1.6.3.1)
8789
mini_portile (= 0.6.0)
8890
packetfu (1.1.9)
91+
parser (2.1.9)
92+
ast (>= 1.1, < 3.0)
93+
slop (~> 3.4, >= 3.4.5)
8994
pcaprub (0.11.3)
9095
pg (0.17.1)
96+
powerpack (0.0.9)
9197
pry (0.10.0)
9298
coderay (~> 1.1.0)
9399
method_source (~> 0.8.1)
@@ -106,6 +112,7 @@ GEM
106112
rake (>= 0.8.7)
107113
rdoc (~> 3.4)
108114
thor (>= 0.14.6, < 2.0)
115+
rainbow (2.0.0)
109116
rake (10.3.2)
110117
rdoc (3.12.2)
111118
json (~> 1.4)
@@ -131,10 +138,17 @@ GEM
131138
rspec-core (~> 2.99.0)
132139
rspec-expectations (~> 2.99.0)
133140
rspec-mocks (~> 2.99.0)
141+
rubocop (0.23.0)
142+
json (>= 1.7.7, < 2)
143+
parser (~> 2.1.9)
144+
powerpack (~> 0.0.6)
145+
rainbow (>= 1.99.1, < 3.0)
146+
ruby-progressbar (~> 1.4)
147+
ruby-progressbar (1.5.1)
148+
activesupport (>= 3.0.0)
134149
rubyntlm (0.4.0)
135150
rubyzip (1.1.6)
136151
shoulda-matchers (2.6.2)
137-
activesupport (>= 3.0.0)
138152
simplecov (0.5.4)
139153
multi_json (~> 1.0.3)
140154
simplecov-html (~> 0.5.3)
@@ -160,7 +174,7 @@ DEPENDENCIES
160174
factory_girl (>= 4.1.0)
161175
factory_girl_rails
162176
fivemat (= 1.2.1)
163-
metasploit-credential (~> 0.8.2)
177+
metasploit-credential (>= 0.8.6, < 0.9)
164178
metasploit-framework!
165179
metasploit_data_models (~> 0.19)
166180
network_interface (~> 0.0.1)
@@ -171,6 +185,7 @@ DEPENDENCIES
171185
redcarpet
172186
rspec (>= 2.12, < 3.0.0)
173187
rspec-rails (>= 2.12, < 3.0.0)
188+
rubocop
174189
shoulda-matchers
175190
simplecov (= 0.5.4)
176191
timecop

app/concerns/metasploit/credential/core/to_credential.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def to_credential
1313
private: private.try(:data),
1414
private_type: private.try(:type).try(:demodulize).try(:underscore).try(:to_sym),
1515
realm: realm.try(:value),
16-
realm_key: realm.try(:key)
16+
realm_key: realm.try(:key),
17+
parent: self
1718
)
1819
end
1920

config/application.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
)
1515
)
1616

17+
#
18+
# Railties
19+
#
20+
21+
# For compatibility with jquery-rails (and other engines that need action_view) in pro
22+
require 'action_view/railtie'
23+
1724
#
1825
# Project
1926
#
@@ -26,11 +33,22 @@ module Framework
2633
class Application < Rails::Application
2734
include Metasploit::Framework::CommonEngine
2835

29-
user_config_root = Pathname.new(Msf::Config.get_config_root)
30-
user_database_yaml = user_config_root.join('database.yml')
31-
32-
if user_database_yaml.exist?
33-
config.paths['config/database'] = [user_database_yaml.to_path]
36+
environment_database_yaml = ENV['MSF_DATABASE_CONFIG']
37+
38+
if environment_database_yaml
39+
# DO NOT check if the path exists: if the environment variable is set, then the user meant to use this path
40+
# and if it doesn't exist then an error should occur so the user knows the environment variable points to a
41+
# non-existent file.
42+
config.paths['config/database'] = environment_database_yaml
43+
else
44+
user_config_root = Pathname.new(Msf::Config.get_config_root)
45+
user_database_yaml = user_config_root.join('database.yml')
46+
47+
# DO check if the path exists as in test environments there may be no config root, in which case the normal
48+
# rails location, `config/database.yml`, should contain the database config.
49+
if user_database_yaml.exist?
50+
config.paths['config/database'] = [user_database_yaml.to_path]
51+
end
3452
end
3553
end
3654
end

data/msfcrawler/basic.rb

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
require 'rubygems'
1515
require 'pathname'
16-
require 'hpricot'
16+
require 'nokogiri'
1717
require 'uri'
1818

1919
class CrawlerSimple < BaseParser
@@ -24,23 +24,20 @@ def parse(request,result)
2424
return
2525
end
2626

27-
doc = Hpricot(result.body.to_s)
28-
doc.search('a').each do |link|
29-
30-
hr = link.attributes['href']
31-
32-
if hr and !hr.match(/^(\#|javascript\:)/)
33-
begin
34-
hreq = urltohash('GET',hr,request['uri'],nil)
35-
36-
insertnewpath(hreq)
37-
38-
rescue URI::InvalidURIError
39-
#puts "Parse error"
40-
#puts "Error: #{link[0]}"
27+
# doc = Hpricot(result.body.to_s)
28+
doc = Nokogiri::HTML(result.body.to_s)
29+
doc.css('a').each do |anchor_tag|
30+
hr = anchor_tag['href']
31+
if hr && !hr.match(/^(\#|javascript\:)/)
32+
begin
33+
hreq = urltohash('GET', hr, request['uri'], nil)
34+
insertnewpath(hreq)
35+
rescue URI::InvalidURIError
36+
#puts "Parse error"
37+
#puts "Error: #{link[0]}"
38+
end
4139
end
4240
end
43-
end
4441
end
4542
end
4643

0 commit comments

Comments
 (0)