15. Privileged Access

Once we're in the domain, goal shifts to advance our position horizontally or vertically. There's several ways to move laterally. If we have an account with local admin rights over a host/set of hosts, we can Pass-The-Hash [[10. PassTheHash]] to authenticate via SMB.

Various ways to enumerate. Easiest is bloodhound.

In the module we'll swap between win and nix hosts.

Recommend we try all methods shown in the section

RDP even with low priv is useful to:

Powerview allows us to Get-NetLocalGroupMember function to begin enumerating members of the Remote Desktop Users group on a given host.

PS C:\htb> Get-NetLocalGroupMember -ComputerName ACADEMY-EA-MS01 -GroupName "Remote Desktop Users"

In our env, All domain users can rdp. can be common. this type of server is usually heavily used

First thing to check after importing bloodhound: Does the Domain Users group have local admin rights or execution rights (RDP, WinRM) over one or more hosts?

If we have a foothold with llmnr/nbt-ns or kerberoasting we can search for the username in bloodhound and check what access rights they have directly or via group membership under execution rights on node info tab.

WinRM privileged access

Like RDP we may find a specific user or entire group with winrm access. Again, same rules above apply. Pillage, sensitive info, or privesc. Powerview Get-NetLocalGroupMember and to Remote Management Users group to check.

PS C:\htb> Get-NetLocalGroupMember -ComputerName ACADEMY-EA-MS01 -GroupName "Remote Management Users"

Custom cypher query for hunting this kind of access.

MATCH p1=shortestPath((u1:User)-[r1:MemberOf*1..]->(g1:Group)) MATCH p2=(u1)-[:CanPSRemote*1..]->(c:Computer) RETURN p2

Establishing WinRM session from windows

$password = ConvertTo-SecureString "Klmcargo2" -AsPlainText -Force

$cred = new-object System.Management.Automation.PSCredential ("INLANEFREIGHT\forend", $password)

Enter-PSSession -ComputerName ACADEMY-EA-MS01 -Credential $cred

Use Exit-PSSession to leave that context.

Linux evil-winrm equivalent:

evil-winrm -i 10.129.201.234 -u forend

Privileged access with SQL Server admin

Common to have user/svc accounts set up with sysadmin priv Obtaining creds for an account with this access via kerberoasting or llmnr/nbt-ns / password spraying is also common

potentially pillagable with Snaffler to find web.config or other conf files that contain SQL server connection strings.

Bloodhound - again - is great for finding this kind of access via SqlAdmin edge - check for Sql Admin rights in node info tab - custom cypher query

MATCH p1=shortestPath((u1:User)-[r1:MemberOf*1..]->(g1:Group)) MATCH p2=(u1)-[:SQLAdmin*1..]->(c:Computer) RETURN p2

In our scenario example there's an image demonstrating damundsen has SQLAdmin rights over host Academy-EA-DB01

Use ACL rights to auth with wley, change password for damundsen like we did in the previous sections, and authenticate with the target using a tool like PowerUpSQL which has a command cheatsheet: https://github.com/NetSPI/PowerUpSQL/wiki/PowerUpSQL-Cheat-Sheet

Assume you changed damundsen password to SQL1234! using ACL rights - and we can now auth, run OS commands.

Hunting for SQL server instances

cd .\PowerUpSQL\
Import-Module .\PowerUpSQL.ps1
Get-SQLInstanceDomain

We're then able to auth against remote SQL server host and run custom queries / OS commands. Worth experimenting with this tool but extensive enumeration/attack tactics against MSSQL are outside module scope.

Get-SQLQuery -Verbose -Instance "172.16.5.150,1433" -username "inlanefreight\damundsen" -password "SQL1234!" -query 'Select @@version'

Could also auth via linux using mssqlclient.py from impacket.

mssqlclient.py INLANEFREIGHT/DAMUNDSEN@172.16.5.150 -windows-auth

Since we're admin we can enable_xp_cmdshell and yada yada; shell access.

Running whoami /priv we see: On that machine in this scenario we have SeImpersonatePrivilege.

https://github.com/ohpe/juicy-potato https://github.com/itm4n/PrintSpoofer https://github.com/antonioCoco/RoguePotato