Skip to content
SOC FluentSpeak SIEM and EDR

For Sophos Central Live Discover and Data Lake

Sophos SQL cheat sheet

Sophos Live Discover uses osquery SQL. Ask online devices about their processes, ports, users and files right now, or search the Data Lake for what happened earlier.

Checked against Sophos documentation and osquery’s table definitions in November 2026.

Live Discover on devices

These run on the devices you pick, and only answer if the device is online.

To do thisWrite this
Running processes
SELECT pid, name, path, cmdline FROM processes;
Exact match, case matters
SELECT pid, path FROM processes WHERE name = 'powershell.exe';
Match, ignore caseLIKE ignores case for plain letters.
SELECT pid, path FROM processes WHERE name LIKE 'powershell.exe';
Contains text% is any text and _ is one character.
SELECT name, cmdline FROM processes WHERE cmdline LIKE '%-enc%';
One of several
SELECT pid, name FROM processes WHERE name IN ('cmd.exe', 'powershell.exe');
Process and its parent
SELECT p.name, pp.name AS parent
FROM processes p
JOIN processes pp ON p.parent = pp.pid;
Listening ports and their process
SELECT lp.port, lp.address, p.name
FROM listening_ports lp
JOIN processes p ON lp.pid = p.pid;
Local user accounts
SELECT username, description, directory FROM users;
Startup items
SELECT name, path, username FROM startup_items;
Enabled scheduled tasks (Windows)
SELECT name, action, path FROM scheduled_tasks WHERE enabled = 1;
Services that start automatically (Windows)
SELECT name, path, user_account FROM services WHERE start_type = 'AUTO_START';
Files in a folder
SELECT path, size, mtime FROM file WHERE path LIKE 'C:\Users\Public\%';
Hash a filehash and file need a path or directory.
SELECT path, sha256 FROM hash WHERE path = 'C:\Windows\Temp\update.exe';
Count and sort
SELECT name, COUNT(*) AS n FROM processes
GROUP BY name ORDER BY n DESC LIMIT 10;
Pull text out with a regex
SELECT regex_match(cmdline, 'https?://[^ ]+', 0) AS url
FROM processes WHERE cmdline LIKE '%http%';
Ask for a value when the query runsA Live Discover variable. The name goes between $$ signs.
SELECT pid, path FROM processes WHERE name = $$Process name$$;

Data Lake

Data Lake rows come from queries Sophos runs on a schedule. Filter on query_name first. Set the time range in the console, up to 30 days per query.

To do thisWrite this
Windows processes
SELECT meta_hostname, name, cmdline, username
FROM xdr_data
WHERE query_name = 'running_processes_windows_sophos';
One process, ignore case
AND LOWER(name) = 'powershell.exe'
Started by a given parent
AND LOWER(parent_name) = 'winword.exe'
Find a file hash
AND sha256 = '<sha256 here>'
Count by device
SELECT meta_hostname, COUNT(*) AS runs
FROM xdr_data
WHERE query_name = 'running_processes_windows_sophos'
GROUP BY meta_hostname ORDER BY runs DESC;
See which data you have
SELECT DISTINCT query_name FROM xdr_data;

Watch out for

  • = and IN compare exactly, so case matters. In Live Discover, LIKE ignores case for plain letters. In the Data Lake, use LOWER() to be safe.
  • Live Discover only answers for devices that are online now. Use the Data Lake to look back.
  • The file and hash tables need a path or directory in the WHERE, or they return nothing.
  • The Data Lake column is cmdline, not cmd_line or command_line.
  • In Live Discover, Windows paths need no escaping. 'C:\Windows\Temp' works as written.
  • A query must be at least 15 characters long before Live Discover will run it.

Keep going

Practise these in real exercises

A cheat sheet tells you the syntax. SOC Fluent gives you exercises to solve with it, on realistic lab data, and shows you what your query missed. Join the waitlist and we’ll email you once, on launch day.

Free to join. Students get 50% off at launch.