Misc Powershell Playground
Powershell with Metasploit + psh payload + Meterpreter
Step 1: Multi Handler in Metasploit
On Kali:
Step 2: Generate PS Script payload using Msfvenom
On Kali:
Step 3: Serve the payload
On Kali:
Step 4: Download and Run on victim
Now the handler should get a reverse shell
Note that in Meterpreter, we can use load powershell
to get us a powershell session / execute powershell command / import powershell script.
Empire Agent shell to Metasploit Meterpreter
Assume we now have a Active agent in Empire.
Step 1: Metasploit multi script
Then a command will appear, as well as the payload location.
Step 2:
On Empire:
Now on Metasploit, a new session should spawn!
UAC Bypass
To view UAC settings on Powershell:
To bypass UAC, at least you fulfill all of the following:
Local Admin
Current UAC setting is
Default
In fact, it depends on the Integrity level of the program.
Medium integrity process cannot perform admin work without passing UAC
Some integrity process has built-in high integrity!
msconfig.exe
msconfig.exe
is by default in High Integrity and you do not need to pass UAC. This is because it is set when compiled.
To check, we can use pestudio to inspect:
Note <autoElevate>true</autoElevate>
But this process cannot help us to bypass UAC. Instead use Computer Management!
compmgmtlauncher.exe (mmc.exe)
Launching compmgmtlauncher.exe
, eventually you will see this pair:
Parent Process:
mmc.exe
Process:
compmgmt.msc
In fact the mmc.exe
command line is:
In the middle of the launching process, compmgmtlauncher.exe
opens a Registry HKCU\Software\Classes\mscfile\shell\open\command
, which can be modified by the current user! This can be leveraged to bypass UAC!
If you go to HKEY_CURRENT_USER\Software\Classes\
, you will see there is no mscfile
. Create according to the behavior:
HKEY_CURRENT_USER\Software\Classes\mscfile\shell\open\command
and configure the default value of command
to be the program you want!
UAC_Bypass.ps1 (Not work anymore)
WMI for Persistence
Get-WmiObject
Show all namespaces objects:
To be simple ...
To get all classes (Overwhelming!!!):
For example, we see a class name Win32_Service. Let's try:
Many times, we will query the Win32_Process
class:
To create process:
Invoke-WmiMethod
Also there is another cmdlet to do the same:
We can also perform remote WMI jobs:
PowerLurk
Last updated