CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/windows/manage/delete_user.rb
Views: 11784
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
include Msf::Post::Windows::Accounts
8
9
def initialize(info = {})
10
super(
11
update_info(
12
info,
13
'Name' => 'Windows Manage Local User Account Deletion',
14
'Description' => %q{
15
This module deletes a local user account from the specified server,
16
or the local machine if no server is given.
17
},
18
'License' => MSF_LICENSE,
19
'Author' => [ 'chao-mu'],
20
'Platform' => [ 'win' ],
21
'SessionTypes' => [ 'meterpreter' ]
22
)
23
)
24
25
register_options(
26
[
27
OptString.new('USERNAME', [ true, 'The username of the user to delete (not-qualified, e.g. BOB)' ]),
28
OptString.new('SERVER_NAME', [ false, ' DNS or NetBIOS name of remote server on which to delete user' ]),
29
]
30
)
31
end
32
33
def run
34
username = datastore['USERNAME']
35
target_server = datastore['SERVER_NAME']
36
37
status = delete_user(username, target_server || nil)
38
39
case status
40
when :success
41
print_status 'User was deleted!'
42
when :invalid_server
43
print_error 'The server you specified was invalid'
44
when :not_on_primary
45
print_error 'You must be on the primary domain controller to do that'
46
when :user_not_found
47
print_error 'User did not exist!'
48
when :access_denied
49
print_error 'Sorry, you do not have permission to delete that user'
50
when nil
51
print_error 'Something horrible just happened. Sorry.'
52
else
53
print_error 'This module is out of date'
54
end
55
end
56
end
57
58