Skip to content

Commit 80d18fa

Browse files
author
Brent Cook
committed
update example modules to have zero violations
1 parent 6e06d1a commit 80d18fa

File tree

4 files changed

+123
-119
lines changed

4 files changed

+123
-119
lines changed

modules/auxiliary/example.rb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
#
1111
###
1212
class MetasploitModule < Msf::Auxiliary
13-
14-
def initialize(info={})
15-
super(update_info(info,
16-
'Name' => 'Sample Auxiliary Module',
17-
# The description can be multiple lines, but does not preserve formatting.
18-
'Description' => 'Sample Auxiliary Module',
19-
'Author' => ['Joe Module <[email protected]>'],
20-
'License' => MSF_LICENSE,
21-
'Actions' =>
22-
[
23-
['Default Action'],
24-
['Another Action']
13+
def initialize(info = {})
14+
super(
15+
update_info(
16+
info,
17+
'Name' => 'Sample Auxiliary Module',
18+
# The description can be multiple lines, but does not preserve formatting.
19+
'Description' => 'Sample Auxiliary Module',
20+
'Author' => ['Joe Module <[email protected]>'],
21+
'License' => MSF_LICENSE,
22+
'Actions' => [
23+
[ 'Default Action' ],
24+
[ 'Another Action' ]
2525
]
26-
))
27-
26+
)
27+
)
2828
end
2929

3030
def run
@@ -34,11 +34,10 @@ def run
3434
# auxiliary modules can register new commands, they all call cmd_* to
3535
# dispatch them
3636
def auxiliary_commands
37-
return { "aux_extra_command" => "Run this auxiliary test commmand" }
37+
{ "aux_extra_command" => "Run this auxiliary test commmand" }
3838
end
3939

4040
def cmd_aux_extra_command(*args)
41-
print_status("Running inside aux_extra_command(#{args.join(" ")})")
41+
print_status("Running inside aux_extra_command(#{args.join(' ')})")
4242
end
43-
4443
end

modules/auxiliary/scanner/udp/example.rb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@ def initialize(info = {})
2222
'Author' => 'Joe Contributor <joe_contributor[at]example.com>',
2323
'DisclosureDate' => 'Mar 15 2014',
2424
'License' => MSF_LICENSE,
25-
'References' =>
26-
[
27-
['CVE', '0000-0000'], # remove or update if CVE exists
28-
['URL', 'https://SomeURLinCyberspace.local']
29-
]
25+
'References' => [
26+
[ 'CVE', '0000-0000' ], # remove or update if CVE exists
27+
[ 'URL', 'https://SomeURLinCyberspace.local' ]
28+
]
3029
)
3130
)
3231

3332
register_options(
34-
[
35-
# TODO: change to the port you need to scan
36-
Opt::RPORT(12345)
37-
])
33+
[
34+
# TODO: change to the port you need to scan
35+
Opt::RPORT(12345)
36+
]
37+
)
3838

3939
# TODO: add any advanced, special options here, otherwise remove
4040
register_advanced_options(
41-
[
42-
OptBool.new('SPECIAL', [true, 'Try this special thing', false])
43-
])
41+
[
42+
OptBool.new('SPECIAL', [true, 'Try this special thing', false])
43+
]
44+
)
4445
end
4546

4647
def setup

modules/exploits/example.rb

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,50 @@ class MetasploitModule < Msf::Exploit::Remote
2020
include Exploit::Remote::Tcp
2121

2222
def initialize(info = {})
23-
super(update_info(info,
24-
# The Name should be just like the line of a Git commit - software name,
25-
# vuln type, class. It needs to fit in 50 chars ideally. Preferably apply
26-
# some search optimization so people can actually find the module.
27-
# We encourage consistency between module name and file name.
28-
'Name' => 'Sample Exploit',
29-
'Description' => %q{
30-
This exploit module illustrates how a vulnerability could be exploited
31-
in an TCP server that has a parsing bug.
32-
},
33-
'License' => MSF_LICENSE,
34-
'Author' => ['skape'],
35-
'References' =>
36-
[
37-
[ 'OSVDB', '12345' ],
38-
[ 'EDB', '12345' ],
39-
[ 'URL', 'http://www.example.com'],
40-
[ 'CVE', '1978-1234'],
41-
],
42-
'Payload' =>
43-
{
44-
'Space' => 1000,
45-
'BadChars' => "\x00",
46-
},
47-
'Targets' =>
48-
[
49-
# Target 0: Windows All
23+
super(
24+
update_info(
25+
info,
26+
# The Name should be just like the line of a Git commit - software name,
27+
# vuln type, class. It needs to fit in 50 chars ideally. Preferably apply
28+
# some search optimization so people can actually find the module.
29+
# We encourage consistency between module name and file name.
30+
'Name' => 'Sample Exploit',
31+
'Description' => %q(
32+
This exploit module illustrates how a vulnerability could be exploited
33+
in an TCP server that has a parsing bug.
34+
),
35+
'License' => MSF_LICENSE,
36+
'Author' => ['skape'],
37+
'References' =>
5038
[
51-
'Windows XP/Vista/7/8',
52-
{
53-
'Platform' => 'win',
54-
'Ret' => 0x41424344
55-
}
39+
[ 'OSVDB', '12345' ],
40+
[ 'EDB', '12345' ],
41+
[ 'URL', 'http://www.example.com'],
42+
[ 'CVE', '1978-1234']
5643
],
57-
],
58-
'DisclosureDate' => "Apr 1 2013",
59-
# Note that this is by index, rather than name. It's generally easiest
60-
# just to put the default at the beginning of the list and skip this
61-
# entirely.
62-
'DefaultTarget' => 0))
44+
'Payload' =>
45+
{
46+
'Space' => 1000,
47+
'BadChars' => "\x00"
48+
},
49+
'Targets' =>
50+
[
51+
# Target 0: Windows All
52+
[
53+
'Windows XP/Vista/7/8',
54+
{
55+
'Platform' => 'win',
56+
'Ret' => 0x41424344
57+
}
58+
]
59+
],
60+
'DisclosureDate' => "Apr 1 2013",
61+
# Note that this is by index, rather than name. It's generally easiest
62+
# just to put the default at the beginning of the list and skip this
63+
# entirely.
64+
'DefaultTarget' => 0
65+
)
66+
)
6367
end
6468

6569
#
@@ -80,7 +84,7 @@ def exploit
8084
print_status("Sending #{payload.encoded.length} byte payload...")
8185

8286
# Build the buffer for transmission
83-
buf = rand_text_alpha(1024)
87+
buf = rand_text_alpha(1024)
8488
buf << [ target.ret ].pack('V')
8589
buf << payload.encoded
8690

@@ -90,6 +94,4 @@ def exploit
9094

9195
handler
9296
end
93-
9497
end
95-

modules/exploits/windows/browser/example.rb

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,52 @@ class MetasploitModule < Msf::Exploit::Remote
1919
# Set :classid and :method for ActiveX exploits. For example:
2020
# :classid => "{C3B92104-B5A7-11D0-A37F-00A0248F0AF1}",
2121
# :method => "SetShapeNodeType",
22-
autopwn_info({
23-
:ua_name => HttpClients::IE,
24-
:ua_minver => "8.0",
25-
:ua_maxver => "10.0",
26-
:javascript => true,
27-
:os_name => OperatingSystems::Match::WINDOWS,
28-
:rank => NormalRanking
29-
})
30-
31-
def initialize(info={})
32-
super(update_info(info,
33-
'Name' => "Module Name",
34-
'Description' => %q{
35-
This template covers IE8/9/10, and uses the user-agent HTTP header to detect
36-
the browser version. Please note IE8 and newer may emulate an older IE version
37-
in compatibility mode, in that case the module won't be able to detect the
38-
browser correctly.
39-
},
40-
'License' => MSF_LICENSE,
41-
'Author' => [ 'sinn3r' ],
42-
'References' =>
43-
[
44-
[ 'URL', 'http://metasploit.com' ]
45-
],
46-
'Platform' => 'win',
47-
'Targets' =>
48-
[
49-
[ 'Automatic', {} ],
50-
[ 'IE 8 on Windows XP SP3', { 'Rop' => :jre } ],
51-
[ 'IE 8 on Windows Vista', { 'Rop' => :jre } ],
52-
[ 'IE 8 on Windows 7', { 'Rop' => :jre } ],
53-
[ 'IE 9 on Windows 7', { 'Rop' => :jre } ],
54-
[ 'IE 10 on Windows 8', { 'Rop' => :jre } ]
55-
],
56-
'Payload' =>
57-
{
58-
'BadChars' => "\x00", # js_property_spray
59-
'StackAdjustment' => -3500
60-
},
61-
'Privileged' => false,
62-
'DisclosureDate' => "Apr 1 2013",
63-
'DefaultTarget' => 0))
22+
autopwn_info(
23+
ua_name: HttpClients::IE,
24+
ua_minver: "8.0",
25+
ua_maxver: "10.0",
26+
javascript: true,
27+
os_name: OperatingSystems::Match::WINDOWS,
28+
rank: NormalRanking
29+
)
30+
31+
def initialize(info = {})
32+
super(
33+
update_info(
34+
info,
35+
'Name' => "Module Name",
36+
'Description' => %q(
37+
This template covers IE8/9/10, and uses the user-agent HTTP header to detect
38+
the browser version. Please note IE8 and newer may emulate an older IE version
39+
in compatibility mode, in that case the module won't be able to detect the
40+
browser correctly.
41+
),
42+
'License' => MSF_LICENSE,
43+
'Author' => [ 'sinn3r' ],
44+
'References' =>
45+
[
46+
[ 'URL', 'http://metasploit.com' ]
47+
],
48+
'Platform' => 'win',
49+
'Targets' =>
50+
[
51+
[ 'Automatic', {} ],
52+
[ 'IE 8 on Windows XP SP3', { 'Rop' => :jre } ],
53+
[ 'IE 8 on Windows Vista', { 'Rop' => :jre } ],
54+
[ 'IE 8 on Windows 7', { 'Rop' => :jre } ],
55+
[ 'IE 9 on Windows 7', { 'Rop' => :jre } ],
56+
[ 'IE 10 on Windows 8', { 'Rop' => :jre } ]
57+
],
58+
'Payload' =>
59+
{
60+
'BadChars' => "\x00", # js_property_spray
61+
'StackAdjustment' => -3500
62+
},
63+
'Privileged' => false,
64+
'DisclosureDate' => "Apr 1 2013",
65+
'DefaultTarget' => 0
66+
)
67+
)
6468
end
6569

6670
def get_target(agent)
@@ -85,7 +89,7 @@ def get_target(agent)
8589
end
8690

8791
targets.each do |t|
88-
if (!ie.empty? and t.name.include?(ie_name)) and (!nt.empty? and t.name.include?(os_name))
92+
if (!ie.empty? && t.name.include?(ie_name)) && (!nt.empty? && t.name.include?(os_name))
8993
return t
9094
end
9195
end
@@ -100,20 +104,19 @@ def get_payload(t)
100104
case t['Rop']
101105
when :msvcrt
102106
print_status("Using msvcrt ROP")
103-
rop_payload = generate_rop_payload('msvcrt', code, {'pivot'=>stack_pivot, 'target'=>'xp'})
107+
rop_payload = generate_rop_payload('msvcrt', code, 'pivot' => stack_pivot, 'target' => 'xp')
104108

105109
else
106110
print_status("Using JRE ROP")
107-
rop_payload = generate_rop_payload('java', code, {'pivot'=>stack_pivot})
111+
rop_payload = generate_rop_payload('java', code, 'pivot' => stack_pivot)
108112
end
109113

110114
rop_payload
111115
end
112116

113-
114117
def get_html(t)
115118
js_p = ::Rex::Text.to_unescape(get_payload(t), ::Rex::Arch.endian(t.arch))
116-
html = %Q|
119+
html = %|
117120
<script>
118121
#{js_property_spray}
119122
@@ -125,7 +128,6 @@ def get_html(t)
125128
html.gsub(/^\t\t/, '')
126129
end
127130

128-
129131
def on_request_uri(cli, request)
130132
agent = request.headers['User-Agent']
131133
print_status("Requesting: #{request.uri}")
@@ -139,6 +141,6 @@ def on_request_uri(cli, request)
139141

140142
print_status("Target selected as: #{target.name}")
141143
html = get_html(target)
142-
send_response(cli, html, { 'Content-Type'=>'text/html', 'Cache-Control'=>'no-cache' })
144+
send_response(cli, html, 'Content-Type' => 'text/html', 'Cache-Control' => 'no-cache')
143145
end
144146
end

0 commit comments

Comments
 (0)