txt2stix 1.1.15__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- txt2stix/includes/extractions/ai/config.yaml +17 -1
- txt2stix/includes/extractions/lookup/config.yaml +17 -2
- txt2stix/indicator.py +5 -2
- txt2stix/retriever.py +8 -2
- {txt2stix-1.1.15.dist-info → txt2stix-1.2.0.dist-info}/METADATA +1 -1
- {txt2stix-1.1.15.dist-info → txt2stix-1.2.0.dist-info}/RECORD +9 -9
- {txt2stix-1.1.15.dist-info → txt2stix-1.2.0.dist-info}/WHEEL +0 -0
- {txt2stix-1.1.15.dist-info → txt2stix-1.2.0.dist-info}/entry_points.txt +0 -0
- {txt2stix-1.1.15.dist-info → txt2stix-1.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -778,7 +778,23 @@ ai_country:
|
|
|
778
778
|
type: ai
|
|
779
779
|
dogesec_web: true
|
|
780
780
|
name: 'Country'
|
|
781
|
-
description: 'Will extract countries, turn into two digit country codes, and import location object from CTI Butler.'
|
|
781
|
+
description: 'Will extract countries, turn into two digit country codes, and import location (and all related regions and subregions) object from CTI Butler.'
|
|
782
|
+
notes: 'lookup_country_alpha2 legacy extraction also exists if you cannot use AI'
|
|
783
|
+
created: 2020-01-01
|
|
784
|
+
modified: 2020-01-01
|
|
785
|
+
created_by: dogesec
|
|
786
|
+
version: 1.0.0
|
|
787
|
+
prompt_base: 'Extract all countries described in the text, including countries printed as IS0-3166 Alpha2 and Alpha3 codes.'
|
|
788
|
+
prompt_helper: 'If you are unsure, you can read more about the standard here: https://www.iso.org/iso-3166-country-codes.html'
|
|
789
|
+
prompt_conversion: 'Convert all country extractions to their corresponding IS0-3166 Alpha2 codes.'
|
|
790
|
+
test_cases: ai_country
|
|
791
|
+
stix_mapping: ctibutler-location-with-regions
|
|
792
|
+
|
|
793
|
+
ai_country_only:
|
|
794
|
+
type: ai
|
|
795
|
+
dogesec_web: true
|
|
796
|
+
name: 'Country only'
|
|
797
|
+
description: 'Will extract countries, turn into two digit country codes, and import location (without regions and subregions) object from CTI Butler.'
|
|
782
798
|
notes: 'lookup_country_alpha2 legacy extraction also exists if you cannot use AI'
|
|
783
799
|
created: 2020-01-01
|
|
784
800
|
modified: 2020-01-01
|
|
@@ -5,8 +5,23 @@
|
|
|
5
5
|
lookup_country_alpha2:
|
|
6
6
|
type: lookup
|
|
7
7
|
dogesec_web: false
|
|
8
|
-
name: 'Country Alpha2'
|
|
9
|
-
description: 'Extracts countries using ISO 3166-1 alpha2 codes'
|
|
8
|
+
name: 'Country Alpha2 (with regions)'
|
|
9
|
+
description: 'Extracts countries using ISO 3166-1 alpha2 codes (will create relationships to regions and subregions).'
|
|
10
|
+
notes: 'RECOMMENDED FOR BETTER ACCURACY: Use ai_country. This extractor is very dumb e.g the words `is` and `in` will result in extractions for Iceland and India'
|
|
11
|
+
file: 'lookups/country_iso3166_alpha2.txt'
|
|
12
|
+
created: 2020-01-01
|
|
13
|
+
modified: 2020-01-01
|
|
14
|
+
created_by: dogesec
|
|
15
|
+
version: 1.0.0
|
|
16
|
+
test_cases: generic_country_alpha2
|
|
17
|
+
stix_mapping: ctibutler-location-with-regions
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
lookup_country_alpha2_country_only:
|
|
21
|
+
type: lookup
|
|
22
|
+
dogesec_web: false
|
|
23
|
+
name: 'Country Alpha2 (without regions)'
|
|
24
|
+
description: 'Extracts countries using ISO 3166-1 alpha2 codes (will not create relationships).'
|
|
10
25
|
notes: 'RECOMMENDED FOR BETTER ACCURACY: Use ai_country. This extractor is very dumb e.g the words `is` and `in` will result in extractions for Iceland and India'
|
|
11
26
|
file: 'lookups/country_iso3166_alpha2.txt'
|
|
12
27
|
created: 2020-01-01
|
txt2stix/indicator.py
CHANGED
|
@@ -106,7 +106,10 @@ def _build_observables(
|
|
|
106
106
|
):
|
|
107
107
|
retrieved_objects = retrieve_stix_objects(stix_mapping, extracted_value)
|
|
108
108
|
if retrieved_objects:
|
|
109
|
-
|
|
109
|
+
relatable = [sdo["id"] for sdo in retrieved_objects]
|
|
110
|
+
if 'location' in stix_mapping:
|
|
111
|
+
relatable = [retrieved_objects[0]['id']]
|
|
112
|
+
return retrieved_objects, relatable
|
|
110
113
|
if retrieved_objects == []:
|
|
111
114
|
logger.warning(
|
|
112
115
|
f"could not find `{stix_mapping}` with id=`{extracted_value}` in remote"
|
|
@@ -623,7 +626,7 @@ def _build_observables(
|
|
|
623
626
|
extracted_value = extracted_value.replace("-", "").replace(" ", "")
|
|
624
627
|
|
|
625
628
|
country_code, bank_code = get_iban_details(extracted_value)
|
|
626
|
-
location = retrieve_stix_objects("location", country_code)[0]
|
|
629
|
+
location = retrieve_stix_objects("ctibutler-location", country_code)[0]
|
|
627
630
|
stix_objects.append(location)
|
|
628
631
|
|
|
629
632
|
bank_acc = dict_to_stix2(
|
txt2stix/retriever.py
CHANGED
|
@@ -69,6 +69,10 @@ class STIXObjectRetriever:
|
|
|
69
69
|
return self._retrieve_objects(
|
|
70
70
|
urljoin(self.api_root, f"v1/location/objects/?alpha2_code={id}")
|
|
71
71
|
)
|
|
72
|
+
|
|
73
|
+
def get_location_bundle(self, id):
|
|
74
|
+
endpoint = urljoin(self.api_root, f"v1/location/objects/{id}/bundle/?types=location,relationship")
|
|
75
|
+
return self._retrieve_objects(endpoint, key="objects")
|
|
72
76
|
|
|
73
77
|
def get_objects_by_name(self, name, type):
|
|
74
78
|
return self._retrieve_objects(
|
|
@@ -122,6 +126,10 @@ def _retrieve_stix_objects(host, knowledge_base, filter_value):
|
|
|
122
126
|
return retreiver.retrieve_object_by_id(filter_value, "cpe")
|
|
123
127
|
case "location":
|
|
124
128
|
return retreiver.get_location_objects(filter_value)
|
|
129
|
+
case "location-with-regions":
|
|
130
|
+
locations = retreiver.get_location_bundle(filter_value)
|
|
131
|
+
locations.sort(key=lambda x: int(x.get('country') == filter_value), reverse=True)
|
|
132
|
+
return locations
|
|
125
133
|
|
|
126
134
|
### ATT&CK by Name
|
|
127
135
|
case "mitre-attack-enterprise-name":
|
|
@@ -162,8 +170,6 @@ def _retrieve_stix_objects(host, knowledge_base, filter_value):
|
|
|
162
170
|
|
|
163
171
|
def retrieve_stix_objects(stix_mapping: str, filter_value, host=None):
|
|
164
172
|
knowledge_base = stix_mapping
|
|
165
|
-
if stix_mapping in ["location"]:
|
|
166
|
-
host = "ctibutler"
|
|
167
173
|
if not host:
|
|
168
174
|
host, _, knowledge_base = stix_mapping.partition("-")
|
|
169
175
|
try:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: txt2stix
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: txt2stix is a Python script that is designed to identify and extract IoCs and TTPs from text files, identify the relationships between them, convert them to STIX 2.1 objects, and output as a STIX 2.1 bundle.
|
|
5
5
|
Project-URL: Homepage, https://github.com/muchdogesec/txt2stix
|
|
6
6
|
Project-URL: Issues, https://github.com/muchdogesec/txt2stix/issues
|
|
@@ -4,9 +4,9 @@ txt2stix/bundler.py,sha256=GmpWW9ek4iFZdEIyjVSpd9RnmyeNsZJOpnax5Tt0uT0,16748
|
|
|
4
4
|
txt2stix/common.py,sha256=ISnGNKqJPE1EcfhL-x_4G18mcwt1urmorkW-ru9kV-0,585
|
|
5
5
|
txt2stix/credential_checker.py,sha256=eWDP-jY3-jm8zI0JMoUcyoQZ_JqPNfCIr_HAO8nVYz0,3044
|
|
6
6
|
txt2stix/extractions.py,sha256=_tlsqYHhfAoV-PJzxRHysrX47uxCsMlSg7PQWxww1u0,2171
|
|
7
|
-
txt2stix/indicator.py,sha256=
|
|
7
|
+
txt2stix/indicator.py,sha256=qB_NZooUNXxQbL0yxHLn_4il14DcWV6Ri-h8_5XbRfg,30902
|
|
8
8
|
txt2stix/lookups.py,sha256=h42YVtYUkWZm6ZPv2h5hHDHDzDs3yBqrT_T7pj2MDZI,2301
|
|
9
|
-
txt2stix/retriever.py,sha256=
|
|
9
|
+
txt2stix/retriever.py,sha256=CwcCVER1sAPHeMojcIgdWMEJ5596tyYDf5HAJXiBdOM,7021
|
|
10
10
|
txt2stix/stix.py,sha256=9nXD9a2dCY4uaatl-mlIA1k3srwQBhGW-tUSho3iYe0,30
|
|
11
11
|
txt2stix/txt2stix.py,sha256=eUL0pynQXruJRDvqs-LQ-dspDITx5tFDnTPEgCRQApk,23348
|
|
12
12
|
txt2stix/utils.py,sha256=Le0VYx8n8UNpcjqwpx7Avb06qIS9_hId8yP8_PquBUs,3333
|
|
@@ -74,8 +74,8 @@ txt2stix/pattern/extractors/url/url_extractor.py,sha256=-SH1WvxbViaRZ1on8lRlzNAc
|
|
|
74
74
|
txt2stix/pattern/extractors/url/url_file_extractor.py,sha256=_VDu_BX3Ys9SKhZlscZPp9xSOKCxNKKvJ2gbe7Nvuv0,881
|
|
75
75
|
txt2stix/pattern/extractors/url/url_path_extractor.py,sha256=FNKcMZRnJpcZZF44T8DHsDWzhBqPq5a23h7T7l2osac,2459
|
|
76
76
|
txt2stix/includes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
|
-
txt2stix/includes/extractions/ai/config.yaml,sha256=
|
|
78
|
-
txt2stix/includes/extractions/lookup/config.yaml,sha256=
|
|
77
|
+
txt2stix/includes/extractions/ai/config.yaml,sha256=G2tYApzY8sXNazXEQ5Iz4-ttlLuZpq2Cogh_M6JMGC4,44598
|
|
78
|
+
txt2stix/includes/extractions/lookup/config.yaml,sha256=STMOoFhaBFq5Od6SwM8w1MTbJTGv57A2ola6IrFVlEk,13160
|
|
79
79
|
txt2stix/includes/extractions/pattern/config.yaml,sha256=92buge3fYegXIN1TSjLKq4PdIbKAGvDAc4CoQpR38sA,20196
|
|
80
80
|
txt2stix/includes/helpers/mimetype_filename_extension_list.csv,sha256=kgozjMyp7y87CqRcoedfDwNXSLKrDgC9r9YKDYK0EbY,27593
|
|
81
81
|
txt2stix/includes/helpers/stix_relationship_types.txt,sha256=PQytANVSrWepdK_SLEZtfiTe1eoxj6YMGUZslO_C1oc,505
|
|
@@ -114,8 +114,8 @@ txt2stix/includes/lookups/threat_actor.txt,sha256=QfDO9maQuqKBgW_Sdd7VGv1SHZ9Ra-
|
|
|
114
114
|
txt2stix/includes/lookups/tld.txt,sha256=-MEgJea2NMG_KDsnc4BVvI8eRk5Dm93L-t8SGYx5wMo,8598
|
|
115
115
|
txt2stix/includes/lookups/tool.txt,sha256=HGKG6JpUE26w6ezzSxOjBkp15UpSaB7N-mZ_NU_3G7A,6
|
|
116
116
|
txt2stix/includes/tests/test_cases.yaml,sha256=vErA3c5fySeWvJ5yJ8dCTEo3ufRATASAjaF4gj4Az1M,22424
|
|
117
|
-
txt2stix-1.
|
|
118
|
-
txt2stix-1.
|
|
119
|
-
txt2stix-1.
|
|
120
|
-
txt2stix-1.
|
|
121
|
-
txt2stix-1.
|
|
117
|
+
txt2stix-1.2.0.dist-info/METADATA,sha256=_6YaIPwUikL08hFUGucfftftMmjmENUf6YEezgrm0Xg,15031
|
|
118
|
+
txt2stix-1.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
119
|
+
txt2stix-1.2.0.dist-info/entry_points.txt,sha256=x6QPtt65hWeomw4IpJ_wQUesBl1M4WOLODbhOKyWMFg,55
|
|
120
|
+
txt2stix-1.2.0.dist-info/licenses/LICENSE,sha256=BK8Ppqlc4pdgnNzIxnxde0taoQ1BgicdyqmBvMiNYgY,11364
|
|
121
|
+
txt2stix-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|