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.
- RDP
- Powershell remoting (PSRemoting, Windows Remote Management (WINRM) )
- MSSQL Server
- An account with sysadmin priv on a sql server instance can login to the instance remotely and execute queries against the DB. This access can be used to run OS cmds in the context of the sql server service account.
Various ways to enumerate. Easiest is bloodhound.
- https://bloodhound.readthedocs.io/en/latest/data-analysis/edges.html#canrdp - CanRDP
- https://bloodhound.readthedocs.io/en/latest/data-analysis/edges.html#canpsremote - CanPSRemote
- https://bloodhound.readthedocs.io/en/latest/data-analysis/edges.html#sqladmin - SQLAdmin
In the module we'll swap between win and nix hosts.
- MS01 - win
Recommend we try all methods shown in the section
Enter-PSSession- WindowsPowerUpSQL- Windowsevil-winrm- Nixmssqlclient.py- nix
RDP even with low priv is useful to:
- launch further attacks
- escalate priv
- pillage host for sensitive data or credentials
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.
- check analysis tab aswell - Workstations where users can RDP, or domain users can rdp
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.
- This can be leveraged with
JuicyPotato,PrintSpoofer, andRoguePotatoto escalate to SYSTEM privileges - depending on target host. - Will be covered in the windows privesc module.
https://github.com/ohpe/juicy-potato https://github.com/itm4n/PrintSpoofer https://github.com/antonioCoco/RoguePotato