Skip to content

Response, New York. Noah Park: Check Point Patches Actively Exploited Management Server Path Traversal. Detection, Dallas. Ava Okello: Report Finds Nearly Half of Deployed Detections Need Attention Before SOCs Can Trust Them.

SOCtember

Always First. Fast SOC News.

A FortiGuard Labs diagram of the campaign in two stages: an infected Windows host downloads eight supporting files, pulls a target range from site.vietnam852 dot com, scans TCP 1433 with Naabu and brute-forces logins; a compromised SQL Server then runs loaders that fetch an XMRig miner and a Gh0st RAT from an FTP server.
Image: Fortinet FortiGuard Labs (fair use), the infection chain of the MS SQL Server campaign.

Response

Fortinet Says Attackers Are Brute-Forcing Internet-Facing Microsoft SQL Servers and Using the Database's Own T-SQL to Plant a Monero Miner and a Gh0st RAT Behind Tasks Named Like Edge Updates

FortiGuard Labs traced a campaign that scans for TCP port 1433, guesses logins from a list of more than 2,700 passwords, then switches on xp_cmdshell and OLE Automation to drop loaders from inside SQL Server. For defenders the trail runs through SQL configuration changes, odd files in C:\Users\Public and scheduled tasks that only pretend to be Microsoft's.

Noah Park, ResponseAustin6 min read

AUSTIN - A campaign that turns exposed Microsoft SQL Server instances into cryptocurrency miners and remote-control footholds does not need a software flaw to get in. It needs a reachable port 1433, a weak login and a database engine willing to run operating system commands on request, according to Fortinet's FortiGuard Labs.

In an analysis published Nov. 12, FortiGuard researcher Xiaopeng Zhang said the company uncovered the active campaign in early October. Once the malware logs in, it uses T-SQL, SQL Server's own query language, to enable command execution on the server, download or unpack a loader and then pull a Monero miner and a variant of the long-lived Gh0st remote access trojan onto the host.

For security operations teams the case is a reminder that a database left on the internet with password authentication is an endpoint, and that the evidence of compromise often sits in the database's configuration rather than in a network alert.

Scanning, then guessing

The first stage runs on a machine the operators already control. The payload, named dllhost.exe, is a UPX-packed Go binary that embeds Naabu, an open-source port scanner. It asks a server at site.vietnam852[.]com for a target address, widens it to a /16 range and probes random hosts in that range for TCP port 1433, the SQL Server default, writing every open host to a file called Result.txt. When a range is done it asks for another.

The malware first downloads eight supporting files into the temp folder: 2018.sql, dwm.exe, go.bat, go.vbs, out.bat, user.txt, pass.txt and sqlcmd.exe. go.vbs, launched with cscript.exe, starts go.bat, which checks Result.txt for open hosts and starts dwm.exe, a .NET brute-forcer, against them. Fortinet said the username list includes sa and admin and the password file holds more than 2,700 predefined passwords. The scanner host keeps itself alive with a scheduled task that runs every 30 minutes under a name made to look like a Microsoft Edge updater.

T-SQL as a delivery system

After a successful login, a second instance of dwm.exe runs the batches in 2018.sql against the victim server. According to Fortinet, those batches enable xp_cmdshell, download an executable into C:\Users\Public and run it as Google.exe or payload.exe, schedule a daily task named Microsoft_UPDATES to fetch and run it again, and extract an executable embedded in the script itself.

A FortiGuard Labs screenshot of a T-SQL batch from 2018.sql that turns on advanced options and OLE Automation Procedures, creates a Startup folder path with xp_cmdshell, writes a predefined executable held in a VARBINARY variable to C:\users\public\Secs.exe and the Startup folder through an ADODB.Stream object, and runs it through WScript.Shell.
Image: Fortinet FortiGuard Labs (fair use), a T-SQL batch that writes Secs.exe to disk and runs it.

That last step is the one detection engineers should study. The batch shown by Fortinet holds the executable in a VARBINARY variable, turns on OLE Automation Procedures through sp_configure, uses an ADODB.Stream object to write the bytes to C:\Users\Public\Secs.exe and to the Startup folder, and runs the file through WScript.Shell. No file is downloaded at that stage; the database writes it.

Loaders, a miner and a RAT

Secs.exe is a loader. Fortinet said it pulls further executables one at a time from ftp.vietnam852[.]com, saves them to the temp folder, runs them, registers the host with the operators' backend, and creates a daily task whose name again imitates Microsoft Edge's updater.

A FortiGuard Labs screenshot of Windows Task Scheduler on an infected host, showing a task named MicrosoftEdgeUpdateTaskMachineUA with a long GUID that repeats every 30 minutes and starts E:\dllhost.exe, alongside a task named Microsoft_UPDATES.
Image: Fortinet FortiGuard Labs (fair use), the scheduled task the malware creates to rerun its payload every 30 minutes.

One payload, MicrosoftEdgeUpdate.exe, is packed with Themida and a custom packer and is in fact an XMRig Monero miner that reports to the operators' server with an XMRig Reporter user agent. Another, winlogon.exe, is a Gh0st RAT variant with keylogging, file management, a remote shell, more than 30 control commands and a command that clears Windows event logs. It persists three ways, through the HKLM Run key, a Windows service and a scheduled task that runs every 30 minutes, and it carries two command servers, server.vietnam852[.]com:8000 and www.swordaa[.]com:8000.

A FortiGuard Labs screenshot of a WinSCP session to ftp.vietnam852 dot com listing the files the loader fetches, including dllhost.exe, MicrosoftEdgeUpdate.exe, winlogon.exe and down.exe.
Image: Fortinet FortiGuard Labs (fair use), the campaign's FTP server during analysis.

What responders should check

Fortinet did not say how many servers were compromised. The techniques, though, leave predictable traces on any SQL Server host and in the network around it:

  • Treat any unexplained change to xp_cmdshell or Ole Automation Procedures through sp_configure as an incident, and review the SQL Server error log for those configuration changes and for bursts of failed logins against sa or admin.
  • Hunt for sqlservr.exe spawning cmd.exe, PowerShell or other processes, and for executables written to C:\Users\Public, including Secs.exe, Google.exe and payload.exe, or to the Startup folder.
  • List scheduled tasks named Microsoft_UPDATES or MicrosoftEdgeUpdateTaskMachineUA and MicrosoftEdgeUpdateTaskMachineCore with GUID suffixes, and confirm each points to Microsoft's real updater path rather than a public folder or a drive root.
  • Block and search proxy and DNS logs for vietnam852[.]com, swordaa[.]com and mining pool traffic such as xmr-ru.kryptex.network, and watch for the XMRig Reporter user agent.
  • Because the RAT can clear event logs, look for log-clear events on SQL hosts and treat a log with no history as a finding, not a clean bill of health.

The prevention advice is older than the campaign. Keep SQL Server off the internet or behind a VPN or allowlist, disable the sa login or give it a long unique password, prefer Windows authentication, and leave xp_cmdshell and OLE Automation off unless a documented job needs them. A server that has run these batches should be rebuilt and every credential it stored rotated, since the operators had both a shell and a keylogger on it.

About the Author

Noah Park

Noah Park covers incident response and vulnerability management for SOCtember from Austin.

Related stories

Response desk