Spaces:
Runtime error
Runtime error
Miguel
commited on
Commit
·
dd8af64
1
Parent(s):
b1c435f
fix: rodrigo's laziness second try
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ from tdagent.tools.lookup_company_cloud_account_information import (
|
|
15 |
)
|
16 |
from tdagent.tools.query_abuse_ip_db import gr_query_abuseipdb
|
17 |
from tdagent.tools.rdap import gr_query_rdap
|
|
|
18 |
from tdagent.tools.send_email import gr_send_email
|
19 |
from tdagent.tools.virus_total import gr_virus_total_url_info
|
20 |
|
@@ -43,6 +44,7 @@ TOOLS = (
|
|
43 |
ToolInfo("DNS Enumerator", dns_enumeration_tool),
|
44 |
ToolInfo("Subdomain Retriever", scrap_subdomains_tool),
|
45 |
ToolInfo("Extractor of IoCs", extractor_of_ioc_from_threatfox_tool),
|
|
|
46 |
## Fake tools
|
47 |
ToolInfo("Fake company directory", gr_internal_company),
|
48 |
ToolInfo(
|
|
|
15 |
)
|
16 |
from tdagent.tools.query_abuse_ip_db import gr_query_abuseipdb
|
17 |
from tdagent.tools.rdap import gr_query_rdap
|
18 |
+
from tdagent.tools.retrieve_from_mitre_attack import gr_get_stix_of_attack_id
|
19 |
from tdagent.tools.send_email import gr_send_email
|
20 |
from tdagent.tools.virus_total import gr_virus_total_url_info
|
21 |
|
|
|
44 |
ToolInfo("DNS Enumerator", dns_enumeration_tool),
|
45 |
ToolInfo("Subdomain Retriever", scrap_subdomains_tool),
|
46 |
ToolInfo("Extractor of IoCs", extractor_of_ioc_from_threatfox_tool),
|
47 |
+
ToolInfo("ATT&CK STIX information", gr_get_stix_of_attack_id),
|
48 |
## Fake tools
|
49 |
ToolInfo("Fake company directory", gr_internal_company),
|
50 |
ToolInfo(
|
tdagent/tools/get_domain_information.py
CHANGED
@@ -71,7 +71,7 @@ def get_geolocation(ip: str) -> dict[str, Any] | str:
|
|
71 |
return str(e)
|
72 |
|
73 |
|
74 |
-
def _request_dns_record(domain: str, record_type: str) -> str:
|
75 |
"""Utility to build dns resolve requests that do not use port 53.
|
76 |
|
77 |
Args:
|
@@ -164,7 +164,7 @@ def enumerate_dns(domain_name: str) -> dict[str, Any] | None:
|
|
164 |
if record:
|
165 |
enumeration[record_type] = record
|
166 |
except Exception as e: # noqa: BLE001, PERF203
|
167 |
-
enumeration[record_type] = str(e)
|
168 |
return enumeration if enumeration else None
|
169 |
|
170 |
|
|
|
71 |
return str(e)
|
72 |
|
73 |
|
74 |
+
def _request_dns_record(domain: str, record_type: str) -> list[str]:
|
75 |
"""Utility to build dns resolve requests that do not use port 53.
|
76 |
|
77 |
Args:
|
|
|
164 |
if record:
|
165 |
enumeration[record_type] = record
|
166 |
except Exception as e: # noqa: BLE001, PERF203
|
167 |
+
enumeration[record_type] = [str(e)]
|
168 |
return enumeration if enumeration else None
|
169 |
|
170 |
|
tdagent/tools/retrieve_from_mitre_attack.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from attackcti import attack_client
|
5 |
+
|
6 |
+
|
7 |
+
def get_stix_object_of_attack_id(
|
8 |
+
attack_id: str,
|
9 |
+
object_type: str = "attack-pattern",
|
10 |
+
) -> dict[str, Any]:
|
11 |
+
"""Retrieves a STIX object identified by an ATT&CK ID in all ATT&CK matrices.
|
12 |
+
|
13 |
+
Args:
|
14 |
+
attack_id (str): The ATT&CK ID (e.g., 'T1234') of the STIX object to retrieve.
|
15 |
+
object_type (str): The type of STIX object to retrieve, such as
|
16 |
+
'attack-pattern', 'course-of-action', 'intrusion-set',
|
17 |
+
'malware', 'tool', or 'x-mitre-data-component'. Default is 'attack-pattern'
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
A list containing the matched STIX object, either in its raw STIX format
|
21 |
+
or as a custom dictionary following the structure defined by the relevant
|
22 |
+
Pydantic model, depending on the 'stix_format' flag.
|
23 |
+
"""
|
24 |
+
lift = attack_client()
|
25 |
+
return lift.get_object_by_attack_id(
|
26 |
+
object_type=object_type,
|
27 |
+
attack_id=attack_id,
|
28 |
+
stix_format=False,
|
29 |
+
)[0]
|
30 |
+
|
31 |
+
|
32 |
+
gr_get_stix_of_attack_id = gr.Interface(
|
33 |
+
fn=get_stix_object_of_attack_id,
|
34 |
+
inputs=["text", "text"],
|
35 |
+
outputs="json",
|
36 |
+
title="MITRE ATT&CK STIX information",
|
37 |
+
description=(
|
38 |
+
"Retrieves a specific STIX object identified by an ATT&CK ID across all ATT&CK"
|
39 |
+
" matrices"
|
40 |
+
),
|
41 |
+
)
|
tdagent/tools/retrieve_from_mitre_attack_information
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
from typing import Any
|
2 |
-
|
3 |
-
from attackcti import attack_client
|
4 |
-
|
5 |
-
|
6 |
-
def get_stix_object_of_attack_id(attack_id: str, object_type: str = "attack-pattern") -> dict[str, Any]:
|
7 |
-
"""Retrieves a specific STIX object identified by an ATT&CK ID across all ATT&CK matrices.
|
8 |
-
|
9 |
-
Args:
|
10 |
-
attack_id (str): The ATT&CK ID (e.g., 'T1234') of the STIX object to retrieve.
|
11 |
-
object_type (str): The type of STIX object to retrieve, such as 'attack-pattern', 'course-of-action', 'intrusion-set',
|
12 |
-
'malware', 'tool', or 'x-mitre-data-component'. Default is 'attack-pattern'
|
13 |
-
|
14 |
-
Returns:
|
15 |
-
List: A list containing the matched STIX object, either in its raw STIX format or as a custom dictionary
|
16 |
-
following the structure defined by the relevant Pydantic model, depending on the 'stix_format' flag.
|
17 |
-
"""
|
18 |
-
lift = attack_client()
|
19 |
-
return lift.get_object_by_attack_id(object_type=object_type, attack_id=attack_id)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|