|
24 | 24 | # python net.py Administrator:password@targetMachine group -name "Domain Admins"
|
25 | 25 | # python net.py Administrator:password@targetMachine computer -name DC$
|
26 | 26 | # python net.py Administrator:password@targetMachine group -name "Domain Admins" -join EvilUs3r
|
| 27 | +# python net.py Administrator:password@targetMachine user -enable EvilUs3r |
| 28 | +# python net.py Administrator:password@targetMachine user -disable EvilUs3r |
27 | 29 | #
|
28 | 30 | # Author:
|
29 | 31 | # Alex Romero (@NtAlexio2)
|
@@ -215,11 +217,32 @@ def Remove(self, name):
|
215 | 217 | self._close_domain()
|
216 | 218 |
|
217 | 219 | def _hEnableAccount(self, user_handle):
|
| 220 | + user_account_control = samr.hSamrQueryInformationUser2(self._dce, user_handle, samr.USER_INFORMATION_CLASS.UserAllInformation)['Buffer']['All']['UserAccountControl'] |
218 | 221 | buffer = samr.SAMPR_USER_INFO_BUFFER()
|
219 | 222 | buffer['tag'] = samr.USER_INFORMATION_CLASS.UserControlInformation
|
220 |
| - buffer['Control']['UserAccountControl'] = samr.USER_ALL_ADMINCOMMENT |
| 223 | + buffer['Control']['UserAccountControl'] = user_account_control ^ samr.USER_ACCOUNT_DISABLED |
221 | 224 | samr.hSamrSetInformationUser2(self._dce, user_handle, buffer)
|
222 | 225 |
|
| 226 | + def _hDisableAccount(self, user_handle): |
| 227 | + user_account_control = samr.hSamrQueryInformationUser2(self._dce, user_handle, samr.USER_INFORMATION_CLASS.UserAllInformation)['Buffer']['All']['UserAccountControl'] |
| 228 | + buffer = samr.SAMPR_USER_INFO_BUFFER() |
| 229 | + buffer['tag'] = samr.USER_INFORMATION_CLASS.UserControlInformation |
| 230 | + buffer['Control']['UserAccountControl'] = samr.USER_ACCOUNT_DISABLED | user_account_control |
| 231 | + samr.hSamrSetInformationUser2(self._dce, user_handle, buffer) |
| 232 | + |
| 233 | + def SetUserAccountControl(self, name, action): |
| 234 | + info = self.Query(name) |
| 235 | + domain_handle = self._open_domain() |
| 236 | + try: |
| 237 | + user_handle = self._get_user_handle(domain_handle, name) |
| 238 | + if action == 'enable': |
| 239 | + self._hEnableAccount(user_handle) |
| 240 | + else: |
| 241 | + self._hDisableAccount(user_handle) |
| 242 | + finally: |
| 243 | + self._close_domain() |
| 244 | + |
| 245 | + |
223 | 246 |
|
224 | 247 | class Computer(User):
|
225 | 248 | def __init__(self, smbConnection):
|
@@ -358,6 +381,16 @@ def run(self, remoteName, remoteHost):
|
358 | 381 | actionObject.Remove(self.__options.remove)
|
359 | 382 | print("[+] {} account deleted succesfully!".format(self.__action))
|
360 | 383 |
|
| 384 | + elif self.__is_option_present(self.__options, 'enable'): |
| 385 | + print("[*] Enabling {} account '{}'".format(self.__action, self.__options.enable)) |
| 386 | + actionObject.SetUserAccountControl(self.__options.enable, "enable") |
| 387 | + print("[+] {} account enabled succesfully!".format(self.__action)) |
| 388 | + |
| 389 | + elif self.__is_option_present(self.__options, 'disable'): |
| 390 | + print("[*] Disabling {} account '{}'".format(self.__action, self.__options.disable)) |
| 391 | + actionObject.SetUserAccountControl(self.__options.disable, "disable") |
| 392 | + print("[+] {} account disabled succesfully!".format(self.__action)) |
| 393 | + |
361 | 394 | elif self.__is_option_present(self.__options, 'join'):
|
362 | 395 | print("[*] Adding user account '{}' to group '{}'".format(self.__options.join,self.__options.name))
|
363 | 396 | actionObject.Join(self.__options.name, self.__options.join)
|
@@ -466,12 +499,16 @@ def __is_option_present(self, options, option):
|
466 | 499 | user_parser.add_argument('-create', action="store", metavar = "NAME", help='Add new user account to domain/computer.')
|
467 | 500 | user_parser.add_argument('-remove', action="store", metavar = "NAME", help='Remove existing user account from domain/computer.')
|
468 | 501 | user_parser.add_argument('-newPasswd', action="store", metavar = "PASSWORD", help='New password to set for creating account.')
|
| 502 | + user_parser.add_argument('-enable', action="store", metavar = "NAME", help='Enables account.') |
| 503 | + user_parser.add_argument('-disable', action="store", metavar = "NAME", help='Disables account.') |
469 | 504 |
|
470 | 505 | computer_parser = subparsers.add_parser('computer', help='Enumerate all computers in domain level')
|
471 | 506 | computer_parser.add_argument('-name', action="store", metavar = "NAME", help='Display single computer information.')
|
472 | 507 | computer_parser.add_argument('-create', action="store", metavar = "NAME", help='Add new computer account to domain.')
|
473 | 508 | computer_parser.add_argument('-remove', action="store", metavar = "NAME", help='Remove existing computer account from domain.')
|
474 | 509 | computer_parser.add_argument('-newPasswd', action="store", metavar = "PASSWORD", help='New password to set for creating account.')
|
| 510 | + computer_parser.add_argument('-enable', action="store", metavar = "NAME", help='Enables account.') |
| 511 | + computer_parser.add_argument('-disable', action="store", metavar = "NAME", help='Disables account.') |
475 | 512 |
|
476 | 513 | localgroup_parser = subparsers.add_parser('localgroup', help='Enumerate local groups (aliases) of local computer')
|
477 | 514 | localgroup_parser.add_argument('-name', action="store", metavar = "NAME", help='Operate on single specific domain group account.')
|
|
0 commit comments