GSocket Malware Abuse: Stealthy C2 and Remote Access
Detection stack
- AIDR
- Alert
- ETL
- Query
Summary
Threat actors are increasingly abusing GSocket, an open-source remote access tool, to establish stealthy command and control (C2) on compromised Linux servers. By using the Global Socket Relay Network, attackers can avoid dedicated and easily identifiable C2 infrastructure, reducing the effectiveness of traditional IP and domain blocking. This approach enables persistent access even after the original web application vulnerability is remediated.
Investigation
Microsoft Defender for Endpoint telemetry showed a 356.2% increase in GSocket-related detections between March and August 2026. The investigation found that most incidents affected web applications and hosting environments, particularly PHP-based applications and Apache servers. Attackers followed a multi-stage process involving RCE, host profiling, and GSocket deployment with masqueraded process names and multiple persistence mechanisms.
Mitigation
Defenders should patch and harden internet-facing web applications and CMS platforms to prevent initial compromise. It is equally important to remediate affected hosts by removing GSocket clients, related persistence mechanisms such as cron jobs and systemd services, and staging files. Strict egress filtering and monitoring of outbound connections to relay infrastructure are also recommended.
Response
When GSocket activity is detected, responders should investigate web-service process ancestry to determine the initial access vector. Response efforts should remove all GSocket-related artifacts, including hidden files under /dev/shm or /tmp, and audit cron jobs and systemd services for unauthorized entries. Full remediation requires both patching the exploited vulnerability and cleaning the underlying operating system.
Attack Flow
Detections
Suspicious Shell via Web Server [Linux] (via process_creation)
Possible PHP Worker Spawning Unusual Process (via cmdline)
Suspicious Chmod Execution Pointing To Suspicious Directories (via cmdline)
Remote File Upload / Download via Standard Tools (via cmdline)
Service File Creation In Systemd Folder (via file_event)
Hidden File Was Created On Linux Host (via file_event)
Suspicious Persistence Activity by Execution Of Shell Commands From Web Service Users And Groups (via auditd)
IOCs (HashSha256) to detect: The global socket: how threat actors are weaponizing GSocket for stealthy C2
Detect Remote Code Execution and GSocket Deployment on PHP Web Applications [Webserver]
Detection of GSocket Deployment via gs-netcat and curl [Linux Process Creation]
Simulation Execution
-
Attack Narrative & Commands: An adversary has gained initial access to a Linux web server. To establish a persistent, stealthy reverse shell that bypasses traditional firewall restrictions, they decide to deploy
gs-netcat. They will usecurlto pull the installer from a remote repository. To evade casual inspection, they create a directory named/usr/bin/defunct(mimicking zombie processes) to hide their toolkit and execution scripts. The goal is to trigger the specific keyword match defined in the security rule to validate if the SOC is alerted to this specific deployment pattern. -
Regression Test Script:
#!/bin/bash # Simulation script for GSocket Deployment via gs-netcat and curl # 1. Setup deceptive directory echo "[+] Creating deceptive directory /usr/bin/defunct" sudo mkdir -p /usr/bin/defunct # 2. Simulate downloading via curl (using a dummy file to avoid actual malware risk) echo "[+] Simulating download of gs-netcat via curl" echo "#!/bin/bash" | sudo tee /usr/bin/defunct/gs-netcat > /dev/null sudo chmod +x /usr/bin/defunct/gs-netcat # 3. Execute the 'payload' to trigger the keyword detection echo "[+] Executing payload from /usr/bin/defunct" sudo /usr/bin/defunct/gs-netcat --help > /dev/null 2>&1 echo "[+] Simulation complete. Check SIEM for keywords: gs-netcat, curl, /usr/bin/defunct" -
Cleanup Commands:
#!/bin/bash # Cleanup script to remove simulation artifacts echo "[+] Removing deceptive directory and files" sudo rm -rf /usr/bin/defunct echo "[+] Cleanup complete."