Skip to content

Commit edc187a

Browse files
committed
Init
1 parent 951a330 commit edc187a

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Randomness itself is a give away of exploitation
2+
class MetasploitModule < Msf::Exploit::Local
3+
Rank = NormalRanking
4+
5+
# TODO get exact apport version after setting up a test environment
6+
# TODO targets in the initialize method and how they work
7+
# TODO other priv esc vectors, startup folders, periodic scripts
8+
# The vunerable version of apport may be available on other systems, distros and versions
9+
10+
def initialize(info = {})
11+
super(
12+
update_info(
13+
info,
14+
'Name' => 'Ubuntu Xenial Xerus Apport Symlink Hijacking Privilege Escalation ',
15+
'Description' => %q{
16+
On the Ubuntu Xenial Xerus 16.04.7 release the Apport 2.20 crash handler is vulnerable
17+
to symlink injection. Following a crash Apport will write reports to /var/lock/apport/lock,
18+
an attacker who can create a symlink to a privileged directory via /var/lock/apport will be
19+
able to create files with global 0777 permissions. This module exploits this weaknes by writing
20+
payloads to /etc/crontab/ as the root user.
21+
22+
},
23+
'License' => MSF_LICENSE,
24+
'Author' => [
25+
'gardnerapp' # mirageinfosec.cloud
26+
],
27+
'References' => [
28+
[
29+
'URL', 'https://nostarch.com/zero-day' # pg. 59
30+
]
31+
],
32+
'Platform' => 'linux',
33+
'Targets' => [
34+
[
35+
36+
]
37+
],
38+
'Payload' => {
39+
'BadChars' => "\x00"
40+
},
41+
'Privileged' => false,
42+
'DisclosureDate' => '',
43+
'DefaultTarget' => 0,
44+
'Notes' => {
45+
'Stability' => [CRASH_SAFE],
46+
'Reliability' => [REPEATABLE_SESSION],
47+
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]
48+
},
49+
)
50+
register_options [
51+
OptString.new('Cron Name', [true, 'Name of the Crontab file', Rex::Text.rand_text_alpha(rand(8..12))])
52+
]
53+
)
54+
end
55+
56+
def check
57+
# Check Ubuntu
58+
# Check Release
59+
# Check Apport presence and version
60+
return CheckCode::Safe unless session.platform == 'linux'
61+
62+
return CheckCode::Safe unless kernel_version =~ /[uU]buntu/
63+
64+
# Check apport version
65+
if !command_exists?('apport-cli')
66+
return CheckCode::Safe('apport-cli does not appear to be installed or in the $PATH')
67+
end
68+
69+
apport = cmd_exec('apport-cli --version').to_s
70+
71+
return CheckCode::Detected('Unable to determine apport version') if apport.blank?
72+
73+
version = Rex::Version.new(apport.split('-').first)
74+
75+
vulnerable = Rex::Version.new '2.20'
76+
# Were there prior versions of apport which are NOT vulnerableii
77+
# if version < vulnerable return bad
78+
79+
end
80+
81+
def exploit
82+
# Methods for
83+
# symlinking /var/lock/apport to /etc/crontab
84+
# Touching a file to this
85+
# verifying the permissions on the file (root ownership)
86+
# writing payloads
87+
# what type of payloads
88+
end
89+
90+
end

0 commit comments

Comments
 (0)