Skip to content

Commit 84966f0

Browse files
[Tuning] Update DPRK ByBit Hunting Queries (#4645)
* fix * markdown generate * adding missing streamlit hunting query --------- Co-authored-by: terrancedejesus <[email protected]> Co-authored-by: Terrance DeJesus <[email protected]>
1 parent 80c4f7e commit 84966f0

4 files changed

+111
-30
lines changed

hunting/macos/docs/command_and_control_suspicious_executable_file_creation_via_python.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
1-
# Unsigned or Untrusted Binary Execution via Python
1+
# Suspcious Executable File Creation via Python
22

33
---
44

55
## Metadata
66

77
- **Author:** Elastic
8-
- **Description:** Detects the execution of unsigned or untrusted binaries where the parent process is a Python interpreter. Adversaries often use Python as a launcher to run untrusted payloads, typically dropped to locations like `/tmp`, `/Users/Shared`, or public directories. This behavior is indicative of custom loaders, malware staging, or post-exploitation actions.
8+
- **Description:** Detects suspicious creation of executable files by Python processes in commonly abused directories
9+
on macOS systems. These locations, such as /Users/Shared, /tmp, or /private/tmp, are frequently used by adversaries
10+
and post-exploitation frameworks to stage or drop payloads. The detection leverages the ELF or Mach-O magic bytes
11+
to confirm executables are written to disk.
912

1013
- **UUID:** `9aaf1113-cf7a-4fd7-b796-f6456fdaffb5`
1114
- **Integration:** [endpoint](https://docs.elastic.co/integrations/endpoint)
1215
- **Language:** `[EQL]`
13-
- **Source File:** [Unsigned or Untrusted Binary Execution via Python](../queries/command_and_control_suspicious_executable_file_creation_via_python.toml)
16+
- **Source File:** [Suspcious Executable File Creation via Python](../queries/command_and_control_suspicious_executable_file_creation_via_python.toml)
1417

1518
## Query
1619

1720
```sql
18-
process where event.type == "start" and event.action == "exec" and
19-
(process.code_signature.trusted == false or process.code_signature.exists == false) and
20-
process.parent.name like~ "python*" and
21-
(
22-
process.executable like "/Users/Shared/*" or
23-
process.executable like "/tmp/*" or
24-
process.executable like "/private/tmp/*" or
25-
process.executable like "/Users/*/Public/*" or
26-
process.name like ".*"
27-
)
21+
file where event.action == "modification" and
22+
process.name like~ "python*" and
23+
file.Ext.header_bytes like~ ("cffaedfe*", "cafebabe*") and
24+
file.path like ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/Users/*/Public/*") and
25+
not file.extension in ("dylib", "so")
2826
```
2927

3028
## Notes
3129

32-
- Execution of untrusted binaries from Python in shared or temporary directories is rare in normal operations.
30+
- Creation or modification of executable binaries in these directories is odd and rare in normal operations.
3331
- This hunt is useful for detecting dropper-style behavior during post-exploitation or initial access.
34-
- You may wish to enrich with file.hash or process.args to gain more triage context.
3532

3633
## MITRE ATT&CK Techniques
3734

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Self-Deleted Python Script Outbound Network Connection
2+
3+
---
4+
5+
## Metadata
6+
7+
- **Author:** Elastic
8+
- **Description:** Detects an outbound network connection by a Python script that was executed and deleted from disk. A recent DPRK
9+
initial access campaign used a Python script that self
10+
deletes and continues operating in memory.
11+
- **UUID:** `04d4b300-bf2f-4e86-8fab-c51502a1db32`
12+
- **Integration:** [endpoint](https://docs.elastic.co/integrations/endpoint)
13+
- **Language:** `[EQL]`
14+
- **Source File:** [Self-Deleted Python Script Outbound Network Connection](../queries/defense_evasion_self_deleted_python_script_outbound_network_connection.toml)
15+
16+
## Query
17+
18+
```sql
19+
sequence by process.entity_id with maxspan=10s
20+
[file where event.action == "deletion" and file.extension in ("py", "pyc") and process.name like~ "python*"]
21+
[network where event.type == "start" and
22+
not cidrmatch(destination.ip,
23+
"240.0.0.0/4", "233.252.0.0/24", "224.0.0.0/4", "198.19.0.0/16", "192.18.0.0/15",
24+
"192.0.0.0/24", "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12",
25+
"192.0.2.0/24", "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24",
26+
"100.64.0.0/10", "192.175.48.0/24", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24",
27+
"::1", "FE80::/10", "FF00::/8")]
28+
```
29+
30+
## Notes
31+
32+
- This hunt identifies a deleted Python script followed immediately followed by external network activity from the same process.
33+
- Outbound connection filtering avoids internal IPs and infrastructure — can be tuned to your network space.
34+
35+
## MITRE ATT&CK Techniques
36+
37+
- [T1059.006](https://attack.mitre.org/techniques/T1059/006)
38+
- [T1105](https://attack.mitre.org/techniques/T1105)
39+
- [T1070.004](https://attack.mitre.org/techniques/T1070/004)
40+
41+
## References
42+
43+
- https://www.elastic.co/security-labs/dprk-code-of-conduct
44+
- https://unit42.paloaltonetworks.com/slow-pisces-new-custom-malware/
45+
- https://slowmist.medium.com/cryptocurrency-apt-intelligence-unveiling-lazarus-groups-intrusion-techniques-a1a6efda7d34
46+
- https://x.com/safe/status/1897663514975649938
47+
- https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/
48+
49+
## License
50+
51+
- `Elastic License v2`

hunting/macos/queries/command_and_control_suspicious_executable_file_creation_via_python.toml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
[hunt]
22
author = "Elastic"
3-
name = "Unsigned or Untrusted Binary Execution via Python"
3+
name = "Suspcious Executable File Creation via Python"
44
uuid = "9aaf1113-cf7a-4fd7-b796-f6456fdaffb5"
55
description = """
6-
Detects the execution of unsigned or untrusted binaries where the parent process is a Python interpreter. Adversaries often use Python as a launcher to run untrusted payloads, typically dropped to locations like `/tmp`, `/Users/Shared`, or public directories. This behavior is indicative of custom loaders, malware staging, or post-exploitation actions.
6+
Detects suspicious creation of executable files by Python processes in commonly abused directories
7+
on macOS systems. These locations, such as /Users/Shared, /tmp, or /private/tmp, are frequently used by adversaries
8+
and post-exploitation frameworks to stage or drop payloads. The detection leverages the ELF or Mach-O magic bytes
9+
to confirm executables are written to disk.
710
"""
811
integration = ["endpoint"]
912
language = ["EQL"]
1013
license = "Elastic License v2"
1114
mitre = ["T1059.006", "T1105"]
1215
notes = [
13-
"Execution of untrusted binaries from Python in shared or temporary directories is rare in normal operations.",
14-
"This hunt is useful for detecting dropper-style behavior during post-exploitation or initial access.",
15-
"You may wish to enrich with file.hash or process.args to gain more triage context."
16+
"Creation or modification of executable binaries in these directories is odd and rare in normal operations.",
17+
"This hunt is useful for detecting dropper-style behavior during post-exploitation or initial access."
1618
]
1719
query = [
1820
'''
19-
process where event.type == "start" and event.action == "exec" and
20-
(process.code_signature.trusted == false or process.code_signature.exists == false) and
21-
process.parent.name like~ "python*" and
22-
(
23-
process.executable like "/Users/Shared/*" or
24-
process.executable like "/tmp/*" or
25-
process.executable like "/private/tmp/*" or
26-
process.executable like "/Users/*/Public/*" or
27-
process.name like ".*"
28-
)
21+
file where event.action == "modification" and
22+
process.name like~ "python*" and
23+
file.Ext.header_bytes like~ ("cffaedfe*", "cafebabe*") and
24+
file.path like ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/Users/*/Public/*") and
25+
not file.extension in ("dylib", "so")
2926
'''
3027
]
3128
references = [
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[hunt]
2+
author = "Elastic"
3+
name = "Self-Deleted Python Script Outbound Network Connection"
4+
uuid = "04d4b300-bf2f-4e86-8fab-c51502a1db32"
5+
description = """
6+
Detects an outbound network connection by a Python script that was executed and deleted from disk. A recent DPRK
7+
initial access campaign used a Python script that self
8+
deletes and continues operating in memory."""
9+
integration = ["endpoint"]
10+
language = ["EQL"]
11+
license = "Elastic License v2"
12+
mitre = ["T1059.006", "T1105", "T1070.004"]
13+
notes = [
14+
"This hunt identifies a deleted Python script followed immediately followed by external network activity from the same process.",
15+
"Outbound connection filtering avoids internal IPs and infrastructure — can be tuned to your network space."
16+
]
17+
query = [
18+
'''
19+
sequence by process.entity_id with maxspan=10s
20+
[file where event.action == "deletion" and file.extension in ("py", "pyc") and process.name like~ "python*"]
21+
[network where event.type == "start" and
22+
not cidrmatch(destination.ip,
23+
"240.0.0.0/4", "233.252.0.0/24", "224.0.0.0/4", "198.19.0.0/16", "192.18.0.0/15",
24+
"192.0.0.0/24", "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12",
25+
"192.0.2.0/24", "192.31.196.0/24", "192.52.193.0/24", "192.168.0.0/16", "192.88.99.0/24",
26+
"100.64.0.0/10", "192.175.48.0/24", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24",
27+
"::1", "FE80::/10", "FF00::/8")]
28+
'''
29+
]
30+
references = [
31+
"https://www.elastic.co/security-labs/dprk-code-of-conduct",
32+
"https://unit42.paloaltonetworks.com/slow-pisces-new-custom-malware/",
33+
"https://slowmist.medium.com/cryptocurrency-apt-intelligence-unveiling-lazarus-groups-intrusion-techniques-a1a6efda7d34",
34+
"https://x.com/safe/status/1897663514975649938",
35+
"https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/"
36+
]

0 commit comments

Comments
 (0)