Skip to content

Commit 41567b1

Browse files
committed
Add the DELETE_COMPUTER action
1 parent 084fc19 commit 41567b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

modules/auxiliary/admin/dcerpc/samr_computer.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def initialize(info = {})
3232
},
3333
'Actions' => [
3434
[ 'ADD_COMPUTER', { 'Description' => 'Add a computer account' } ],
35+
[ 'DELETE_COMPUTER', { 'Description' => 'Delete a computer account' } ],
3536
[ 'LOOKUP_COMPUTER', { 'Description' => 'Lookup a computer account' } ]
3637
],
3738
'DefaultAction' => 'ADD_COMPUTER'
@@ -165,6 +166,19 @@ def action_add_computer
165166
report_creds(@domain_name, computer_name, password)
166167
end
167168

169+
def action_delete_computer
170+
fail_with(Failure::BadConfig, 'This action requires COMPUTER_NAME to be specified.') if datastore['COMPUTER_NAME'].blank?
171+
computer_name = datastore['COMPUTER_NAME']
172+
173+
details = @samr.samr_lookup_names_in_domain(domain_handle: @domain_handle, names: [ computer_name ])
174+
fail_with(Failure::BadConfig, 'The specified computer was not found.') if details.nil?
175+
details = details[computer_name]
176+
177+
handle = @samr.samr_open_user(domain_handle: @domain_handle, user_id: details[:rid])
178+
@samr.samr_delete_user(user_handle: handle)
179+
print_good('The specified computer has been deleted.')
180+
end
181+
168182
def action_lookup_computer
169183
fail_with(Failure::BadConfig, 'This action requires COMPUTER_NAME to be specified.') if datastore['COMPUTER_NAME'].blank?
170184
computer_name = datastore['COMPUTER_NAME']

0 commit comments

Comments
 (0)