3. Processes

Very good place to look for privesc is processes running on system. Common example: Webserver IIS / XAMPP running - Placing an aspx/php shell on box and gaining shell as webserver user. Often that user has SeImpersonate token allowing Rogue/Juicy/Lonely potato privesc providing SYSTEM privs

Access Tokens https://docs.microsoft.com/en-us/windows/win32/secauthz/access-tokens

Interpreting netstat Primarily look at entries listening on loopback addresses (127.0.0.1 and ::1) that are not listening on the IP Address (10.129.43.8) or broadcast (0.0.0.0, ::/0)

Examples of svc privesc: Splunk Universal Forwarder installed on endpoints to send logs to Splunk. Default conf of splunk does not have auth on software + allowed anyone to deploy apps - leading to code exec. Splunk default conf run as SYSTEM$ / not low priv. https://airman604.medium.com/splunk-universal-forwarder-hijacking-5899c3e0e6b2 https://clement.notin.org/blog/2019/02/25/Splunk-Universal-Forwarder-Hijacking-2-SplunkWhisperer2/

Erlang Port (25672) Proglang designed around distributed computing and will have network port that allows other Erlang nodes to join cluster. Secret to join this cluster is called a cookie. Many apps that utilize erland will use a weak cookie (RabbitMQ uses rabbit by default) or place cookie in conf file that is not well protected.

Named Pipes Processes can communicate with each other through Named Pipes

Example workflow:

  1. Beacon starts a named pipe of .\pipe\msagent_12
  2. Beacon starts a new process and injects command into that process directing output to .\pipe\msagent_12
  3. Server displays what was written into .\pipe\msagent_12

Cobalt strike used above because if command being ran got flagged by AV/crashed, it would not affect the beacon process which is running the command. CobStr users will change named pipes to masquerade as another program - common example is mojo instead of msagent above

Pipes are used for communication between two applications or processes using shared memory https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipes

Use tool PipeList https://docs.microsoft.com/en-us/sysinternals/downloads/pipelist from SysInternals Suite to enumerate instances of named pipes pipelist.exe /accepteula

Powershell version using gci (Get-ChildItem)

PS C:\htb>  gci \\.\pipe\


    Directory: \\.\pipe


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
------       12/31/1600   4:00 PM              3 InitShutdown
------       12/31/1600   4:00 PM              4 lsass
------       12/31/1600   4:00 PM              3 ntsvcs
------       12/31/1600   4:00 PM              3 scerpc

After obtaining list of namedpipes we can use AccessChk to enumerate permissions assigned to a specific pipe by reviewing DACL list https://docs.microsoft.com/en-us/sysinternals/downloads/accesschk

C:\htb> accesschk.exe /accepteula \\.\Pipe\lsass -v

Accesschk v6.12 - Reports effective permissions for securable objects
Copyright (C) 2006-2017 Mark Russinovich
Sysinternals - www.sysinternals.com

\\.\Pipe\lsass
  Untrusted Mandatory Level [No-Write-Up]
  RW Everyone
        FILE_READ_ATTRIBUTES
        FILE_READ_DATA
        FILE_READ_EA
        FILE_WRITE_ATTRIBUTES
  RW BUILTIN\Administrators
        FILE_ALL_ACCESS
[....]

Above demonstrates only admins have full access to LSASS


Named Pipe attack example https://www.exploit-db.com/exploits/48021 WindscribeService Named Pipe Privilege Escalation

Using accesschk , search for all named pipes that allow write access weith a command like: accesschk.exe -w \pipe\* -v

From here we can leverage these permissions to escalate privs on a host to SYSTEM.