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
- Describe security context of process or thread
- Token describes:
- user acct identity + privs related to specific proc/thread
- When user auths to system password is verified against a security database + if properly auth'd - assigned access token. Every time user interacts with process a copy of this token presented to determine privilege level.
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)
- Network sockets on localhost often insecure due to thought that "they arent accessible to network"
- Immediately sticks out in our example:
14147used for FileZilla's admin interface. - Connecting to this port we may be able to extract FTP pws in addition to creating FTP share at
C:\as filezilla server user. (potentially admin!)
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.
- SolarWinds, RabbitMQ, CouchDB https://malicious.link/post/2018/erlang-arce/
Named Pipes Processes can communicate with each other through Named Pipes
- Essentially files stored in memory that are cleared out after being read.
- Cobalt strike uses Named Pipes for every command (excluding BOF https://www.cobaltstrike.com/help-beacon-object-files)
Example workflow:
- Beacon starts a named pipe of .\pipe\msagent_12
- Beacon starts a new process and injects command into that process directing output to .\pipe\msagent_12
- 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
- Win systems use client-server implementation for pipe communication. In this implementation - process that CREATES named pipe is
server; process communicating with named pipe isclient - half-duplex named pipes are ONE-WAY channel - with client only being able to write data to server
- duplex refers to two-way communication channel using named pipes. Server responds back.
- Every active connection to a named pipe server results in creation of a new named pipe
- These all share the same pipe name, but communicate using a different data buffer
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
- Shows who has perms to modify/write/read/exec a resource.
.\accesschk.exe /accepteula \pipe\.Example of looking at lsass pipe
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
- Notice
WindscribeServicenamed pipe allows READ and WRITE access toEveryonegroup - all authenticated users accesschk.exe -accepteula -w \pipe\WindscribeService -v
From here we can leverage these permissions to escalate privs on a host to SYSTEM.