CmdID

CmdID / Programs / Linux and Unix

sg

Ast-grep is a tool for code structural search, lint, and rewriting. tldr-pages

GTFOBins shell 1 ATT&CK technique 1 documented command

Opens CmdID with your command. It is read in your browser and sent nowhere.

How sg is abused

documented by GTFOBins

shell T1059.004 Command and Scripting Interpreter: Unix Shell

-ng

Each abuse is GTFOBins's category and the options and words it uses; the full write-up is on GTFOBins's page for sg.

1 documented command

from GTFOBins, each read by CmdID

shell unprivileged, with sudo

Commands can be run if the current user's group is specified, therefore no additional permissions are needed.

sg $(id -ng)
Identify

With sudo:

sg root

Trips 2 Sigma rules: lowLocal System Accounts Discovery - MacOs by Alejandro Ortuno, oscd.community; lowLocal System Accounts Discovery Attempt - Linux by Alejandro Ortuno, oscd.community, CheraghiMilad

The command CmdID reads trips a Sigma process-creation rule. This command is, with GTFOBins’ notes, from GTFOBins, at commit acd524623f9c of 2026-05-27, under the GPL-3.0, with no warranty. Changed: Markdown is shown formatted. The source is in lolbas-gtfobins-commands.json.gz, and the full entry is on GTFOBins’s page for sg. CmdID reads the line that runs sg.

What detects it

Sigma process creation rules
T1059.004Command and Scripting Interpreter: Unix Shell

Everyday use

from tldr-pages, CC BY 4.0

Scan for possible queries using interactive mode

sg scan --interactiveIdentify

Rewrite code in the current directory using patterns

sg run --pattern 'pattern' --rewrite 'replacement' --lang pythonIdentify

Visualize possible changes without applying them

sg run --pattern 'useState<number>($A)' --rewrite 'useState($A)' --lang typescriptIdentify

None of the 3 examples CmdID reads matches GTFOBins abuse or trips a Sigma process-creation rule.