Merge pull request #779 from Dfte/add_taskkill

Add the taskkill option
This commit is contained in:
Alex
2025-07-05 18:05:04 +02:00
committed by GitHub
3 changed files with 31 additions and 0 deletions
+26
View File
@@ -978,6 +978,32 @@ class smb(connection):
except SessionError:
self.logger.fail("RDP is probably not enabled, cannot list remote IPv4 addresses.")
@requires_admin
def taskkill(self):
with TSTS.LegacyAPI(self.conn, self.host, self.kerberos) as legacy:
handle = legacy.hRpcWinStationOpenServer()
if self.args.taskkill.isdigit():
pidList = [int(self.args.taskkill)]
else:
res = legacy.hRpcWinStationGetAllProcesses(handle)
if not res:
self.logger.error("Could not get process list")
return
pidList = [i["UniqueProcessId"] for i in res if i["ImageName"].lower() == self.args.taskkill.lower()]
if not pidList:
self.logger.fail(f"Could not find process named {self.args.taskkill}")
return
for pid in pidList:
try:
if legacy.hRpcWinStationTerminateProcess(handle, pid)["ErrorCode"]:
self.logger.highlight(f"Terminated PID {pid} ({self.args.taskkill})")
else:
self.logger.fail(f"Failed terminating PID {pid}")
except Exception as e:
self.logger.exception(f"Error terminating PID {pid}: {e}")
@requires_admin
def qwinsta(self):
desktop_states = {
+1
View File
@@ -55,6 +55,7 @@ def proto_args(parser, parents):
mapping_enum_group.add_argument("--rid-brute", nargs="?", type=int, const=4000, metavar="MAX_RID", help="Enumerate users by bruteforcing RIDs")
mapping_enum_group.add_argument("--qwinsta", action="store_true", help="Enumerate RDP connections")
mapping_enum_group.add_argument("--tasklist", action="store_true", help="Enumerate running processes")
mapping_enum_group.add_argument("--taskkill", type=str, help="Kills a specific PID or a proces name's PID's")
wmi_group = smb_parser.add_argument_group("WMI", "Options for WMI Queries")
wmi_group.add_argument("--wmi", metavar="QUERY", type=str, help="issues the specified WMI query")
+4
View File
@@ -17,6 +17,10 @@ netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --users-exp
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --computers
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --rid-brute
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --local-groups
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --qwinsta
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --tasklist
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --taskkill PID
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --taskkill PROCESS_NAME
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --gen-relay-list /tmp/relaylistOutputFilename.txt
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --local-auth
netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS --delegate LOGIN_USERNAME