Skip to content

Commit 0baaf98

Browse files
author
jvazquez-r7
committed
Delete on_new_session cleanup, as discusses with @jlee-r7
1 parent bf89c95 commit 0baaf98

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

modules/exploits/osx/local/sudo_password_bypass.rb

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def initialize(info={})
5858
],
5959
'Platform' => 'osx',
6060
'Arch' => [ ARCH_X86, ARCH_X86_64, ARCH_CMD ],
61-
'SessionTypes' => [ 'shell' ],
61+
'SessionTypes' => [ 'shell', 'meterpreter' ],
6262
'Targets' => [
6363
[ 'Mac OS X x86 (Native Payload)',
6464
{
@@ -145,13 +145,19 @@ def exploit
145145
end
146146

147147
def cleanup
148-
do_cleanup_once(session)
149-
super
150-
end
148+
print_status("Resetting system clock to original values") if @time
149+
cmd_exec("#{SYSTEMSETUP_PATH} -settimezone #{[@zone].shelljoin}") unless @zone.nil?
150+
cmd_exec("#{SYSTEMSETUP_PATH} -setdate #{[@date].shelljoin}") unless @date.nil?
151+
cmd_exec("#{SYSTEMSETUP_PATH} -settime #{[@time].shelljoin}") unless @time.nil?
152+
153+
if @networked
154+
cmd_exec("#{SYSTEMSETUP_PATH} -setusingnetworktime On")
155+
unless @network_server.nil?
156+
cmd_exec("#{SYSTEMSETUP_PATH} -setnetworktimeserver #{[@network_server].shelljoin}")
157+
end
158+
end
151159

152-
def on_new_session(session)
153-
do_cleanup_once(session)
154-
super
160+
print_good("Completed clock reset.") if @time
155161
end
156162

157163
private
@@ -196,27 +202,6 @@ def run_sudo_cmd
196202

197203
end
198204

199-
# cmd_exec doesn't allow to get a session, so there is no way to make the cleanup
200-
# from the new privileged session, when called from the on_new_session callback.
201-
def do_cleanup_once(session)
202-
return if @_cleaned_up
203-
@_cleaned_up = true
204-
205-
print_status("Resetting system clock to original values") if @time
206-
session.shell_command_token("#{SYSTEMSETUP_PATH} -settimezone #{[@zone].shelljoin}") unless @zone.nil?
207-
session.shell_command_token("#{SYSTEMSETUP_PATH} -setdate #{[@date].shelljoin}") unless @date.nil?
208-
session.shell_command_token("#{SYSTEMSETUP_PATH} -settime #{[@time].shelljoin}") unless @time.nil?
209-
210-
if @networked
211-
session.shell_command_token("#{SYSTEMSETUP_PATH} -setusingnetworktime On")
212-
unless @network_server.nil?
213-
session.shell_command_token("#{SYSTEMSETUP_PATH} -setnetworktimeserver #{[@network_server].shelljoin}")
214-
end
215-
end
216-
217-
print_good("Completed clock reset.") if @time
218-
end
219-
220205
# helper methods for accessing datastore
221206
def using_native_target?; target.name =~ /native/i; end
222207
def using_cmd_target?; target.name =~ /cmd/i; end

0 commit comments

Comments
 (0)