Skip to content

Commit 91bb0b6

Browse files
committed
Merge tag '2014072301' into staging/electro-release
Conflicts: Gemfile.lock modules/post/windows/gather/credentials/gpp.rb This removes the active flag in the gpp.rb module. According to Lance, the active flag is no longer used.
2 parents 69e8edf + 6048f21 commit 91bb0b6

File tree

109 files changed

+2079
-574
lines changed

Some content is hidden

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

109 files changed

+2079
-574
lines changed

.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/**/*'

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ group :db do
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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ GEM
4545
arel (3.0.3)
4646
arel-helpers (2.0.1)
4747
activerecord (>= 3.1.0, < 5)
48+
ast (2.0.0)
4849
bcrypt (3.1.7)
4950
builder (3.0.4)
5051
coderay (1.1.0)
@@ -87,8 +88,12 @@ GEM
8788
nokogiri (1.6.3.1)
8889
mini_portile (= 0.6.0)
8990
packetfu (1.1.9)
91+
parser (2.1.9)
92+
ast (>= 1.1, < 3.0)
93+
slop (~> 3.4, >= 3.4.5)
9094
pcaprub (0.11.3)
9195
pg (0.17.1)
96+
powerpack (0.0.9)
9297
pry (0.10.0)
9398
coderay (~> 1.1.0)
9499
method_source (~> 0.8.1)
@@ -107,6 +112,7 @@ GEM
107112
rake (>= 0.8.7)
108113
rdoc (~> 3.4)
109114
thor (>= 0.14.6, < 2.0)
115+
rainbow (2.0.0)
110116
rake (10.3.2)
111117
rdoc (3.12.2)
112118
json (~> 1.4)
@@ -132,10 +138,17 @@ GEM
132138
rspec-core (~> 2.99.0)
133139
rspec-expectations (~> 2.99.0)
134140
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)
135149
rubyntlm (0.4.0)
136150
rubyzip (1.1.6)
137151
shoulda-matchers (2.6.2)
138-
activesupport (>= 3.0.0)
139152
simplecov (0.5.4)
140153
multi_json (~> 1.0.3)
141154
simplecov-html (~> 0.5.3)
@@ -172,6 +185,7 @@ DEPENDENCIES
172185
redcarpet
173186
rspec (>= 2.12, < 3.0.0)
174187
rspec-rails (>= 2.12, < 3.0.0)
188+
rubocop
175189
shoulda-matchers
176190
simplecov (= 0.5.4)
177191
timecop

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

data/msfcrawler/forms.rb

Lines changed: 11 additions & 30 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 CrawlerForms < BaseParser
@@ -27,49 +27,30 @@ def parse(request,result)
2727
hr = ''
2828
m = ''
2929

30-
doc = Hpricot(result.body.to_s)
31-
doc.search('form').each do |f|
32-
hr = f.attributes['action']
30+
doc = Nokogiri::HTML(result.body.to_s)
31+
doc.css('form').each do |f|
32+
hr = f['action']
3333

34-
fname = f.attributes['name']
35-
if fname.empty?
36-
fname = "NONE"
37-
end
38-
39-
m = "GET"
40-
if !f.attributes['method'].empty?
41-
m = f.attributes['method'].upcase
42-
end
34+
fname = f['name']
35+
fname = "NONE" if fname.empty?
4336

44-
#puts "Parsing form name: #{fname} (#{m})"
37+
m = f['method'].empty? ? 'GET' : f['method'].upcase
4538

46-
htmlform = Hpricot(f.inner_html)
39+
htmlform = Nokogiri::HTML(f.inner_html)
4740

4841
arrdata = []
4942

50-
htmlform.search('input').each do |p|
51-
#puts p.attributes['name']
52-
#puts p.attributes['type']
53-
#puts p.attributes['value']
54-
55-
#raw_request has uri_encoding disabled as it encodes '='.
56-
arrdata << (p.attributes['name'] + "=" + Rex::Text.uri_encode(p.attributes['value']))
43+
htmlform.css('input').each do |p|
44+
arrdata << "#{p['name']}=#{Rex::Text.uri_encode(p['value'])}"
5745
end
5846

5947
data = arrdata.join("&").to_s
6048

61-
6249
begin
63-
hreq = urltohash(m,hr,request['uri'],data)
64-
50+
hreq = urltohash(m, hr, request['uri'], data)
6551
hreq['ctype'] = 'application/x-www-form-urlencoded'
66-
6752
insertnewpath(hreq)
68-
69-
7053
rescue URI::InvalidURIError
71-
#puts "Parse error"
72-
#puts "Error: #{link[0]}"
7354
end
7455
end
7556
end

data/msfcrawler/frames.rb

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,29 @@
99

1010
require 'rubygems'
1111
require 'pathname'
12-
require 'hpricot'
12+
require 'nokogiri'
1313
require 'uri'
1414

1515
class CrawlerFrames < BaseParser
1616

1717
def parse(request,result)
1818

19-
if !result['Content-Type'].include? "text/html"
20-
return
21-
end
22-
23-
doc = Hpricot(result.body.to_s)
24-
doc.search('iframe').each do |ifra|
25-
26-
ir = ifra.attributes['src']
27-
28-
if ir and !ir.match(/^(\#|javascript\:)/)
29-
begin
30-
hreq = urltohash('GET',ir,request['uri'],nil)
19+
return unless result['Content-Type'].include?('text/html')
3120

32-
insertnewpath(hreq)
21+
doc = Nokogiri::HTML(result.body.to_s)
22+
doc.css('iframe').each do |ifra|
23+
ir = ifra['src']
3324

34-
rescue URI::InvalidURIError
35-
#puts "Error"
25+
if ir && !ir.match(/^(\#|javascript\:)/)
26+
begin
27+
hreq = urltohash('GET', ir, request['uri'], nil)
28+
insertnewpath(hreq)
29+
rescue URI::InvalidURIError
30+
end
3631
end
37-
end
32+
3833
end
3934
end
35+
4036
end
4137

data/msfcrawler/image.rb

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,26 @@
1010

1111
require 'rubygems'
1212
require 'pathname'
13-
require 'hpricot'
13+
require 'nokogiri'
1414
require 'uri'
1515

1616
class CrawlerImage < BaseParser
1717

1818
def parse(request,result)
1919

20-
if !result['Content-Type'].include? "text/html"
21-
return
22-
end
23-
24-
doc = Hpricot(result.body.to_s)
25-
doc.search('img').each do |i|
26-
27-
im = i.attributes['src']
28-
29-
if im and !im.match(/^(\#|javascript\:)/)
30-
begin
31-
hreq = urltohash('GET',im,request['uri'],nil)
32-
33-
insertnewpath(hreq)
34-
35-
rescue URI::InvalidURIError
36-
#puts "Parse error"
37-
#puts "Error: #{i[0]}"
20+
return unless result['Content-Type'].include?('text/html')
21+
22+
doc = Nokogiri::HTML(result.body.to_s)
23+
doc.css('img').each do |i|
24+
im = i['src']
25+
if im && !im.match(/^(\#|javascript\:)/)
26+
begin
27+
hreq = urltohash('GET', im, request['uri'], nil)
28+
insertnewpath(hreq)
29+
rescue URI::InvalidURIError
30+
end
3831
end
39-
end
32+
4033
end
4134
end
4235
end

data/msfcrawler/link.rb

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,25 @@
1010

1111
require 'rubygems'
1212
require 'pathname'
13-
require 'hpricot'
13+
require 'nokogiri'
1414
require 'uri'
1515

1616
class CrawlerLink < BaseParser
1717

1818
def parse(request,result)
19-
20-
if !result['Content-Type'].include? "text/html"
21-
return
22-
end
23-
24-
doc = Hpricot(result.body.to_s)
25-
doc.search('link').each do |link|
26-
27-
hr = link.attributes['href']
28-
29-
if hr and !hr.match(/^(\#|javascript\:)/)
30-
begin
31-
hreq = urltohash('GET',hr,request['uri'],nil)
32-
33-
insertnewpath(hreq)
34-
35-
rescue URI::InvalidURIError
36-
#puts "Parse error"
37-
#puts "Error: #{link[0]}"
19+
return unless result['Content-Type'].include?('text/html')
20+
21+
doc = Nokogiri::HTML(result.body.to_s)
22+
doc.css('link').each do |link|
23+
hr = link['href']
24+
if hr && !hr.match(/^(\#|javascript\:)/)
25+
begin
26+
hreq = urltohash('GET', hr, request['uri'], nil)
27+
insertnewpath(hreq)
28+
rescue URI::InvalidURIError
29+
end
3830
end
39-
end
31+
4032
end
4133
end
4234
end

data/msfcrawler/objects.rb

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,25 @@
1313

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

1919
class CrawlerObjects < BaseParser
2020

2121
def parse(request,result)
22-
23-
if !result['Content-Type'].include? "text/html"
24-
return
25-
end
26-
22+
return unless result['Content-Type'].include?('text/html') # TOOD: use MIXIN
2723
hr = ''
2824
m = ''
29-
30-
doc = Hpricot(result.body.to_s)
31-
doc.search("//object/embed").each do |obj|
32-
25+
doc = Nokogiri::HTML(result.body.to_s)
26+
doc.xpath("//object/embed").each do |obj|
3327
s = obj['src']
34-
3528
begin
36-
hreq = urltohash('GET',s,request['uri'],nil)
37-
29+
hreq = urltohash('GET', s, request['uri'], nil)
3830
insertnewpath(hreq)
39-
40-
4131
rescue URI::InvalidURIError
42-
#puts "Parse error"
43-
#puts "Error: #{link[0]}"
4432
end
4533
end
4634
end
35+
4736
end
4837

0 commit comments

Comments
 (0)