Files
metasploit-gs/modules/post/windows/manage/delete_user.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.6 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::Windows::Accounts
2013-08-30 16:28:54 -05:00
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Windows Manage Local User Account Deletion',
'Description' => %q{
This module deletes a local user account from the specified server,
2023-02-08 13:47:34 +00:00
or the local machine if no server is given.
},
'License' => MSF_LICENSE,
'Author' => [ 'chao-mu'],
'Platform' => [ 'win' ],
'SessionTypes' => [ 'meterpreter' ]
)
)
2013-08-30 16:28:54 -05:00
register_options(
[
OptString.new('USERNAME', [ true, 'The username of the user to delete (not-qualified, e.g. BOB)' ]),
OptString.new('SERVER_NAME', [ false, ' DNS or NetBIOS name of remote server on which to delete user' ]),
2023-02-08 13:47:34 +00:00
]
)
end
2013-08-30 16:28:54 -05:00
def run
2023-02-08 13:47:34 +00:00
username = datastore['USERNAME']
target_server = datastore['SERVER_NAME']
2013-08-30 16:28:54 -05:00
2023-02-08 13:47:34 +00:00
status = delete_user(username, target_server || nil)
2013-08-30 16:28:54 -05:00
case status
when :success
2023-02-08 13:47:34 +00:00
print_status 'User was deleted!'
when :invalid_server
2023-02-08 13:47:34 +00:00
print_error 'The server you specified was invalid'
when :not_on_primary
2023-02-08 13:47:34 +00:00
print_error 'You must be on the primary domain controller to do that'
when :user_not_found
2023-02-08 13:47:34 +00:00
print_error 'User did not exist!'
when :access_denied
print_error 'Sorry, you do not have permission to delete that user'
when nil
print_error 'Something horrible just happened. Sorry.'
else
print_error 'This module is out of date'
end
end
end