Skip to content

Commit

Permalink
[Shodan] Save results to note (OpenCTI-Platform#2636)
Browse files Browse the repository at this point in the history
  • Loading branch information
annoyingapt authored Sep 23, 2024
1 parent 793f81b commit 0842217
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions internal-enrichment/shodan/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ services:
- SHODAN_MAX_TLP=TLP:AMBER
- SHODAN_DEFAULT_SCORE=50
- SHODAN_IMPORT_SEARCH_RESULTS=true
- SHODAN_CREATE_NOTE=true # Add results to note rather than description
restart: always
1 change: 1 addition & 0 deletions internal-enrichment/shodan/src/config.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ shodan:
max_tlp: 'TLP:AMBER'
default_score: 50
import_search_results: true
create_note: true
31 changes: 22 additions & 9 deletions internal-enrichment/shodan/src/shodanImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def __init__(self):
config,
default=True,
)
self.create_note = get_config_variable(
"SHODAN_CREATE_NOTE",
["shodan", "create_note"],
config,
default=True,
)

# Shodan Identity
self.shodan_identity = self.helper.api.identity.create(
Expand Down Expand Up @@ -338,21 +344,28 @@ def _upsert_stix_observable(self, description, labels, external_reference):
value=self.stix_entity["value"],
custom_properties={
"x_opencti_external_references": [external_reference],
"x_opencti_description": description,
**(
{"x_opencti_description": description}
if not self.create_note
else {}
),
"x_opencti_score": self.score,
"x_opencti_labels": labels,
"x_opencti_created_by_ref": self.shodan_identity["standard_id"],
},
)
self.stix_objects.append(stix_observable)
"""
{
"source_name": "Shodan",
"url": f"www.shodan.io/host/{data['ip_str']}",
"description": "ceci est une description",
# "external_id": str(data['ip_str']),
}
"""
if self.create_note:
now = datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
stix_note = stix2.Note(
type="note",
id=Note.generate_id(now, description),
abstract="Shodan Results",
content=description,
created_by_ref=self.shodan_identity["standard_id"],
object_refs=self.stix_entity["id"],
)
self.stix_objects.append(stix_note)
return stix_observable

def _generate_stix_bundle(
Expand Down

0 comments on commit 0842217

Please sign in to comment.