Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

Release of DeHashed, httpX, veriphone, scamalytics enrichers

z3rodaycve0d04423b5991
diff --git a/flowsint-api/Dockerfile b/flowsint-api/Dockerfile
index 7d38b371..cdf8fd2f 100644
--- a/flowsint-api/Dockerfile
+++ b/flowsint-api/Dockerfile
@@ -46,6 +46,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
+# Install httpX for 'to_ssl' enricher
+RUN apt-get update && apt-get install -y golang-go
+RUN rm -f /app/.venv/bin/httpx || true
+RUN go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
+
WORKDIR /app
# Copy virtual environment from builder
@@ -89,6 +94,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
+# Install httpX for 'to_ssl' enricher
+RUN apt-get update && apt-get install -y golang-go
+RUN rm -f /app/.venv/bin/httpx || true
+RUN go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
+
# Create non-root user
RUN groupadd -g 1001 flowsint && \
useradd -u 1001 -g flowsint -s /bin/bash -m flowsint
@@ -120,4 +130,4 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
ENTRYPOINT ["./entrypoint.sh"]
# Production command (no reload)
-CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "5001"]
+CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "5001"]
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/domain/to_dehashed.py b/flowsint-enrichers/src/flowsint_enrichers/domain/to_dehashed.py
new file mode 100644
index 00000000..80fd8ba8
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/domain/to_dehashed.py
@@ -0,0 +1,161 @@
+import json
+import os
+import requests
+
+from typing import Any, Dict, List, Optional
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_types.domain import Domain
+from flowsint_types.individual import Individual
+from flowsint_core.core.logger import Logger
+
+@flowsint_enricher
+class DomainToDehashed(Enricher):
+ """[DeHashed] Get breach intelligence from a domain."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Domain
+ OutputType = Individual
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ # @classmethod
+ # def required_params(cls) -> bool:
+ # return True
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ """Declare required parameters for this enricher"""
+ return [
+ {
+ "name": "DEHASHED_API_KEY", # Get your API key from dehashed.com/api
+ "type": "vaultSecret",
+ "description": "Your Dehashed API key.",
+ "required": True,
+ }
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "domain_to_dehashed"
+
+ @classmethod
+ def category(cls) -> str:
+ return "Domain"
+
+ @classmethod
+ def key(cls) -> str:
+ return "domain"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ api_key = self.get_secret("DEHASHED_API_KEY", os.getenv("DEHASHED_API_KEY"))
+
+ for domain in data:
+ try:
+ headers = {'Dehashed-Api-Key': api_key, 'Content-Type': 'application/json'}
+ raw_data = json.dumps({"query": f"domain:{domain.domain}"})
+
+ api_request = requests.post(f'https://api.dehashed.com/v2/search', data=raw_data, headers=headers, timeout=30)
+
+ if api_request.status_code != 200:
+ if api_request.status_code == 401:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(DomainToDehashed) Enricher failed for the domain because API key does not have a valid subscription: '{domain.domain}': {api_request.text}"
+ },
+ )
+
+ elif api_request.status_code == 403:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(DomainToDehashed) Enricher failed for the domain because request has malfunctioned (missing API_KEY): '{domain.domain}': {api_request.text}"
+ },
+ )
+
+ try:
+ response_json = api_request.json()
+ except Exception as e:
+ Logger.error(None, {"message": f"(DomainToDehashed) Failed to parse JSON for {domain.domain}: {e}"})
+ continue
+
+ dehashed_entries = response_json.get("entries", [])
+ if not dehashed_entries:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(DomainToDehashed) Enricher failed for the domain: '{domain.domain}': {api_request.text}"
+ },
+ )
+ continue
+
+
+ api_balance = response_json.get("balance")
+ if api_balance:
+ Logger.info(self.sketch_id, f'(DomainToDehashed) Your remaining API balance is {api_balance}.')
+
+ for entry in dehashed_entries:
+ entry_email = entry.get("email")
+ entry_phone = entry.get("phone")
+ entry_name = entry.get("name")
+ entry_socialmedia = entry.get("social")
+ entry_ip = entry.get("ip_address")
+ entry_username = entry.get("username")
+ entry_dob = entry.get("dob")
+
+ results.append(
+ Individual(
+ full_name=entry_name[0] if entry_name else None,
+ birth_date=entry_dob[0] if entry_dob else None,
+ email_addresses=entry_email if entry_email else None,
+ phone_numbers=entry_phone if entry_phone else None,
+ social_media_profiles=entry_socialmedia if entry_socialmedia else None,
+ ip_addresses=entry_ip if entry_ip else None,
+ usernames=entry_username if entry_username else None
+ )
+ )
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(DomainToDehashed) Exception while querying {domain.domain}: {e}"})
+
+ return results
+
+ def postprocess(
+ self, results: List[OutputType], input_data: List[InputType] = None
+ ) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ if input_data and self._graph_service:
+ for domain in input_data:
+ for individual in results:
+ self.create_node(domain)
+ self.create_node(individual)
+
+ # Create relationship
+ self.create_relationship(domain, individual, "CONNECTION_WITH")
+ self.log_graph_message(
+ f"(DomainToDehashed) Successfully found individual connections with {domain.domain}. "
+ )
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = DomainToDehashed.InputType
+OutputType = DomainToDehashed.OutputType
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/domain/to_ssl.py b/flowsint-enrichers/src/flowsint_enrichers/domain/to_ssl.py
new file mode 100644
index 00000000..3dfd4713
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/domain/to_ssl.py
@@ -0,0 +1,105 @@
+import json
+import os
+import requests
+import subprocess
+
+from typing import Any, Dict, List, Optional
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_types.domain import Domain
+from flowsint_types.website import Website
+from flowsint_core.core.logger import Logger
+from flowsint_types.address import Location
+
+@flowsint_enricher
+class DomainToTLS(Enricher):
+ """[httpX] Get TLS information from a domain."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Domain
+ OutputType = Website
+
+ # @classmethod
+ # def required_params(cls) -> bool:
+ # return True
+
+ @classmethod
+ def name(cls) -> str:
+ return "domain_to_tls"
+
+ @classmethod
+ def category(cls) -> str:
+ return "Domain"
+
+ @classmethod
+ def key(cls) -> str:
+ return "domain"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ for domain in data:
+ Logger.info(self.sketch_id, f"(DomainToTLS) Received {len(data)} inputs")
+ try:
+ httpx_process = subprocess.Popen(
+ ["/root/go/bin/httpx", "-tls-grab", "-json", "-silent"],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True
+ )
+
+ stdout, stderr = httpx_process.communicate(f'{domain.domain}\n')
+
+ if not stdout.strip():
+ Logger.error(None, {"message": f"(DomainToTLS) No results for the domain '{domain.domain}'"})
+ continue
+ else:
+ for line in stdout.splitlines():
+ if line.strip():
+ tlsdata = json.loads(line)
+
+ web_url = tlsdata.get("url")
+ web_title = tlsdata.get("title")
+ web_content_type = tlsdata.get("content_type")
+ web_statuscode = tlsdata.get("status_code") # status_code is int
+
+ results.append(
+ Website(
+ url=web_url if web_url else None,
+ domain=domain,
+ active=True,
+ title=web_title if web_title else None,
+ content_type=web_content_type if web_content_type else None,
+ status_code=web_statuscode if web_statuscode else None
+ )
+ )
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(DomainToTLS) Exception while querying the domain '{domain.domain}': {e}"})
+
+ return results
+
+ def postprocess(
+ self, results: List[OutputType], input_data: List[InputType] = None
+ ) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ if input_data and self._graph_service:
+ for domain in input_data:
+ for website in results:
+ self.create_node(domain)
+ self.create_node(website)
+
+ # Create relationship
+ self.create_relationship(domain, website, "TLS_INFO")
+ self.log_graph_message(
+ f"(DomainToTLS) Successfully fetched TLS information for the domain '{domain.domain}'. "
+ )
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = DomainToTLS.InputType
+OutputType = DomainToTLS.OutputType
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/email/to_dehashed.py b/flowsint-enrichers/src/flowsint_enrichers/email/to_dehashed.py
new file mode 100644
index 00000000..622e8d16
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/email/to_dehashed.py
@@ -0,0 +1,161 @@
+import json
+import os
+import requests
+
+from typing import Any, Dict, List, Optional
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_types.email import Email
+from flowsint_types.individual import Individual
+from flowsint_core.core.logger import Logger
+
+@flowsint_enricher
+class EmailToDehashed(Enricher):
+ """[DeHashed] Get breach intelligence from an email address."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Email
+ OutputType = Individual
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ # @classmethod
+ # def required_params(cls) -> bool:
+ # return True
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ """Declare required parameters for this enricher"""
+ return [
+ {
+ "name": "DEHASHED_API_KEY", # Get your API key from dehashed.com/api
+ "type": "vaultSecret",
+ "description": "Your Dehashed API key.",
+ "required": True,
+ }
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "email_to_intelligence"
+
+ @classmethod
+ def category(cls) -> str:
+ return "Email"
+
+ @classmethod
+ def key(cls) -> str:
+ return "email"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ api_key = self.get_secret("DEHASHED_API_KEY", os.getenv("DEHASHED_API_KEY"))
+
+ for email in data:
+ try:
+ headers = {'Dehashed-Api-Key': api_key, 'Content-Type': 'application/json'}
+ raw_data = json.dumps({"query": f"email:{email.email}"})
+
+ api_request = requests.post(f'https://api.dehashed.com/v2/search', data=raw_data, headers=headers, timeout=30)
+
+ if api_request.status_code != 200:
+ if api_request.status_code == 401:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(EmailToDehashed) Enricher failed for the email because API key does not have a valid subscription: '{email.email}': {api_request.text}"
+ },
+ )
+
+ elif api_request.status_code == 403:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(EmailToDehashed) Enricher failed for the email because request has malfunctioned (missing API_KEY): '{email.email}': {api_request.text}"
+ },
+ )
+
+ try:
+ response_json = api_request.json()
+ except Exception as e:
+ Logger.error(None, {"message": f"(EmailToDehashed) Failed to parse JSON for {email.email}: {e}"})
+ continue
+
+ dehashed_entries = response_json.get("entries", [])
+ if not dehashed_entries:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(EmailToDehashed) Enricher failed for the email: '{email.email}': {api_request.text}"
+ },
+ )
+ continue
+
+
+ api_balance = response_json.get("balance")
+ if api_balance:
+ Logger.info(self.sketch_id, f'(EmailToDehashed) Your remaining API balance is {api_balance}.')
+
+ for entry in dehashed_entries:
+ entry_email = entry.get("email")
+ entry_phone = entry.get("phone")
+ entry_name = entry.get("name")
+ entry_socialmedia = entry.get("social")
+ entry_ip = entry.get("ip_address")
+ entry_username = entry.get("username")
+ entry_dob = entry.get("dob")
+
+ results.append(
+ Individual(
+ full_name=entry_name[0] if entry_name else None,
+ birth_date=entry_dob[0] if entry_dob else None,
+ email_addresses=entry_email if entry_email else None,
+ phone_numbers=entry_phone if entry_phone else None,
+ social_media_profiles=entry_socialmedia if entry_socialmedia else None,
+ ip_addresses=entry_ip if entry_ip else None,
+ usernames=entry_username if entry_username else None
+ )
+ )
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(EmailToDehashed) Exception while querying email {email.email}: {e}"})
+
+ return results
+
+ def postprocess(
+ self, results: List[OutputType], input_data: List[InputType] = None
+ ) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ if input_data and self._graph_service:
+ for email in input_data:
+ for individual in results:
+ self.create_node(email)
+ self.create_node(individual)
+
+ # Create relationship
+ self.create_relationship(email, individual, "CONNECTION_WITH")
+ self.log_graph_message(
+ f"(EmailToDehashed) Successfully found individual connections with {email.email}. "
+ )
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = EmailToDehashed.InputType
+OutputType = EmailToDehashed.OutputType
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/ip/to_dehashed.py b/flowsint-enrichers/src/flowsint_enrichers/ip/to_dehashed.py
new file mode 100644
index 00000000..6612f56e
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/ip/to_dehashed.py
@@ -0,0 +1,163 @@
+import json
+import os
+import requests
+
+from typing import Any, Dict, List, Optional
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_types.ip import Ip
+from flowsint_types.individual import Individual
+from flowsint_core.core.logger import Logger
+
+@flowsint_enricher
+class IpToIntelligence(Enricher):
+ """[DeHashed] Get breach intelligence from an IP address."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Ip
+ OutputType = Individual
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ # @classmethod
+ # def required_params(cls) -> bool:
+ # return True
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ """Declare required parameters for this enricher"""
+ return [
+ {
+ "name": "DEHASHED_API_KEY", # Get your API key from dehashed.com/api
+ "type": "vaultSecret",
+ "description": "Your Dehashed API key.",
+ "required": True,
+ }
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "ip_to_intelligence"
+
+ @classmethod
+ def category(cls) -> str:
+ return "Ip"
+
+ @classmethod
+ def key(cls) -> str:
+ return "address"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ api_key = self.get_secret("DEHASHED_API_KEY", os.getenv("DEHASHED_API_KEY"))
+
+ for ip in data:
+ try:
+ headers = {'Dehashed-Api-Key': api_key, 'Content-Type': 'application/json'}
+ raw_data = json.dumps({"query": f"ip_address:{ip.address}"})
+
+ api_request = requests.post(f'https://api.dehashed.com/v2/search', data=raw_data, headers=headers, timeout=30)
+
+ if api_request.status_code != 200:
+ if api_request.status_code == 401:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(IpToIntelligence) Enricher failed for the IP address because API key does not have a valid subscription: '{ip.address}': {api_request.text}"
+ },
+ )
+
+ elif api_request.status_code == 403:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(IpToIntelligence) Enricher failed for the IP address because request has malfunctioned (missing API_KEY): '{ip.address}': {api_request.text}"
+ },
+ )
+
+ try:
+ response_json = api_request.json()
+ except Exception as e:
+ Logger.error(None, {"message": f"(IpToIntelligence) Failed to parse JSON for {ip.address}: {e}"})
+ continue
+
+ dehashed_entries = response_json.get("entries", [])
+ if not dehashed_entries:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(IpToIntelligence) Enricher failed for the IP address: '{ip.address}': {api_request.text}"
+ },
+ )
+ continue
+
+
+ api_balance = response_json.get("balance")
+ if api_balance:
+ Logger.info(self.sketch_id, f'(EmailToDehashed) Your remaining API balance is {api_balance}.')
+
+ time_took = response_json.get("took")
+
+ for entry in dehashed_entries:
+ entry_email = entry.get("email")
+ entry_phone = entry.get("phone")
+ entry_name = entry.get("name")
+ entry_socialmedia = entry.get("social")
+ entry_ip = entry.get("ip_address")
+ entry_username = entry.get("username")
+ entry_dob = entry.get("dob")
+
+ results.append(
+ Individual(
+ full_name=entry_name[0] if entry_name else None,
+ birth_date=entry_dob[0] if entry_dob else None,
+ email_addresses=entry_email if entry_email else None,
+ phone_numbers=entry_phone if entry_phone else None,
+ social_media_profiles=entry_socialmedia if entry_socialmedia else None,
+ ip_addresses=entry_ip if entry_ip else None,
+ usernames=entry_username if entry_username else None
+ )
+ )
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(IpToIntelligence) Exception while querying {ip.address}: {e}"})
+
+ return results
+
+ def postprocess(
+ self, results: List[OutputType], input_data: List[InputType] = None
+ ) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ if input_data and self._graph_service:
+ for ip in input_data:
+ for individual in results:
+ self.create_node(ip)
+ self.create_node(individual)
+
+ # Create relationship
+ self.create_relationship(ip, individual, "CONNECTION_WITH")
+ self.log_graph_message(
+ f"(IpToIntelligence) Successfully found individual connections with {ip.address}."
+ )
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = IpToIntelligence.InputType
+OutputType = IpToIntelligence.OutputType
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/ip/to_fraudscore.py b/flowsint-enrichers/src/flowsint_enrichers/ip/to_fraudscore.py
new file mode 100644
index 00000000..e8ad32f7
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/ip/to_fraudscore.py
@@ -0,0 +1,157 @@
+import json
+import os
+import requests
+import datetime
+
+from typing import Any, Dict, List, Optional, Union
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_types.ip import Ip
+from flowsint_types.risk_profile import RiskProfile
+from flowsint_core.utils import is_valid_ip
+from flowsint_core.core.logger import Logger
+
+@flowsint_enricher
+class IpToFraudScore(Enricher):
+ """[Scamalytics] Get fraud score for an IP address."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Ip
+ OutputType = RiskProfile
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ # @classmethod
+ # def required_params(cls) -> bool:
+ # return True
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ """Declare required parameters for this enricher"""
+ return [
+ {
+ "name": "SCAMLYTICS_USERNAME",
+ "type": "vaultSecret",
+ "description": "The Scamalytics Username.",
+ "required": True,
+ },
+ {
+ "name": "SCAMLYTICS_API_KEY",
+ "type": "vaultSecret",
+ "description": "The Scamalytics API key for IP-based lookups.",
+ "required": True,
+ },
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "ip_to_fraudscore"
+
+ @classmethod
+ def category(cls) -> str:
+ return "Ip"
+
+ @classmethod
+ def key(cls) -> str:
+ return "address"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ api_username = self.get_secret("SCAMLYTICS_USERNAME", os.getenv("SCAMLYTICS_USERNAME"))
+ api_key = self.get_secret("SCAMLYTICS_API_KEY", os.getenv("SCAMLYTICS_API_KEY"))
+
+ for ip in data:
+ try:
+ api_request = requests.get(f'https://api12.scamalytics.com/v3/{api_username}/?key={api_key}&ip={ip.address}', timeout=30)
+
+ if api_request.status_code != 200:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(IpToFraudScore) Enricher failed for the IP address: '{ip.address}': {api_request.text}"
+ },
+ )
+ continue
+
+ try:
+ response_json = api_request.json()
+ except Exception as e:
+ Logger.error(None, {"message": f"(IpToFraudScore) Failed to parse JSON for {ip.address}: {api_request.text}"})
+ continue
+
+ scamalytics_info = response_json.get("scamalytics", {})
+ if scamalytics_info.get("status") != "ok":
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(IpToFraudScore) Request to Scamlytics failed (status): '{response_json["status"]}'."
+ },
+ )
+ continue
+
+ fraud_score = scamalytics_info.get("scamalytics_score")
+ fraud_risk = scamalytics_info.get("scamalytics_risk")
+ proxy_flags = []
+
+ proxy_detectors = {
+ "is_datacenter": "Datacenter",
+ "is_vpn": "VPN",
+ "is_apple_icloud_private_relay": "iCloud Private Relay",
+ "is_amazon_aws": "Amazon AWS",
+ "is_google": "Google"
+ }
+
+ proxy_info = scamalytics_info.get("scamalytics_proxy", {})
+
+ for key, label in proxy_detectors.items():
+ if proxy_info.get(key):
+ proxy_flags.append(label)
+
+ results.append(
+ RiskProfile(
+ entity_id=ip.address, entity_type="IP address", overall_risk_score=fraud_score, risk_level=fraud_risk, last_updated=datetime.datetime.utcnow().isoformat(), risk_factors=proxy_flags, source="Scamalytics"
+ )
+ )
+
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(IpToFraudScore) Exception while querying {ip.address}: {e}"})
+
+ return results
+
+ def postprocess(
+ self, results: List[OutputType], input_data: List[InputType] = None
+ ) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ if input_data and self._graph_service:
+ for ip, risk_profile in zip(input_data, results):
+ self.create_node(ip)
+ self.create_node(risk_profile)
+
+ # Create relationship
+ self.create_relationship(ip, risk_profile, "HAS_RISK_PROFILE")
+ self.log_graph_message(
+ f"(IpToFraudScore) IP {ip.address} has risk level of {risk_profile.risk_level}"
+ )
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = IpToFraudScore.InputType
+OutputType = IpToFraudScore.OutputType
diff --git a/flowsint-enrichers/src/flowsint_enrichers/phone/to_carrier.py b/flowsint-enrichers/src/flowsint_enrichers/phone/to_carrier.py
new file mode 100644
index 00000000..133c5c4b
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/phone/to_carrier.py
@@ -0,0 +1,120 @@
+import requests
+import os
+
+from typing import Dict, Any, List, Optional
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_core.core.logger import Logger
+from flowsint_types.phone import Phone
+
+
+@flowsint_enricher
+class PhoneToCarrier(Enricher):
+ """[veriphone] Looks up phone number/s carrier using veriphone API."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Phone
+ OutputType = Phone
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ """Declare required parameters for this enricher"""
+ return [
+ {
+ "name": "VERIPHONE_API_KEY",
+ "type": "vaultSecret",
+ "description": "The veriphone API key for phone number carrier lookups.",
+ "required": True,
+ },
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "phone_to_carrier"
+
+ @classmethod
+ def category(cls) -> str:
+ return "phones"
+
+ @classmethod
+ def key(cls) -> str:
+ return "number"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ api_key = self.get_secret("VERIPHONE_API_KEY", os.getenv("VERIPHONE_API_KEY"))
+ Logger.debug(self.sketch_id, {"message": f"API key present: {bool(api_key)}"})
+
+ for phone_obj in data:
+ phonenum_value = phone_obj.number
+ try:
+ api_request = requests.get(f'https://api.veriphone.io/v2/verify?key={api_key}&phone={phonenum_value}', timeout=30)
+
+ if api_request.status_code != 200:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(PhoneToCarrier) Enricher failed for the phone number: '{phonenum_value}': {api_request.text}"
+ },
+ )
+ continue
+
+ try:
+ response_json = api_request.json()
+ except Exception as e:
+ Logger.error(None, {"message": f"(PhoneToCarrier) Failed to parse JSON for phone number '{phonenum_value}'': {api_request.text}"})
+ continue
+
+ carrier = response_json.get("carrier")
+ if carrier:
+ results.append({
+ "number": phonenum_value,
+ "carrier": carrier
+ })
+
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(PhoneToCarrier) Exception while querying phone number '{phonenum_value}'': {e}"})
+
+ return results
+
+ def postprocess(self, results: List[OutputType], original_input: List[InputType]) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ for result in results:
+ number = result["number"]
+ carrier = result["carrier"]
+
+ for phone_obj in original_input:
+ if phone_obj.number == number:
+ phone_obj.carrier = carrier
+
+ self.create_node(phone_obj)
+
+ self.log_graph_message(
+ f"(PhoneToCarrier) Found carrier ({carrier}) for the phone number '{number}'."
+ )
+ break
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = PhoneToCarrier.InputType
+OutputType = PhoneToCarrier.OutputType
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/social/to_dehashed.py b/flowsint-enrichers/src/flowsint_enrichers/social/to_dehashed.py
new file mode 100644
index 00000000..00638792
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/social/to_dehashed.py
@@ -0,0 +1,161 @@
+import json
+import os
+import requests
+
+from typing import Any, Dict, List, Optional
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_types.username import Username
+from flowsint_types.individual import Individual
+from flowsint_core.core.logger import Logger
+
+@flowsint_enricher
+class UsernameToDehashed(Enricher):
+ """[DeHashed] Get breach intelligence from a username."""
+
+ # Define types as class attributes - base class handles schema generation automatically
+ InputType = Username
+ OutputType = Individual
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ # @classmethod
+ # def required_params(cls) -> bool:
+ # return True
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ """Declare required parameters for this enricher"""
+ return [
+ {
+ "name": "DEHASHED_API_KEY", # Get your API key from dehashed.com/api
+ "type": "vaultSecret",
+ "description": "Your Dehashed API key.",
+ "required": True,
+ }
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "username_to_dehashed"
+
+ @classmethod
+ def category(cls) -> str:
+ return "social"
+
+ @classmethod
+ def key(cls) -> str:
+ return "username"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results: List[OutputType] = []
+
+ api_key = self.get_secret("DEHASHED_API_KEY", os.getenv("DEHASHED_API_KEY"))
+
+ for username in data:
+ try:
+ headers = {'Dehashed-Api-Key': api_key, 'Content-Type': 'application/json'}
+ raw_data = json.dumps({"query": f"username:{username.value}"})
+
+ api_request = requests.post(f'https://api.dehashed.com/v2/search', data=raw_data, headers=headers, timeout=30)
+
+ if api_request.status_code != 200:
+ if api_request.status_code == 401:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(UsernameToDehashed) Enricher failed for the username because API key does not have a valid subscription: '{username.value}': {api_request.text}"
+ },
+ )
+
+ elif api_request.status_code == 403:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(UsernameToDehashed) Enricher failed for the username because request has malfunctioned (missing API_KEY): '{username.value}': {api_request.text}"
+ },
+ )
+
+ try:
+ response_json = api_request.json()
+ except Exception as e:
+ Logger.error(None, {"message": f"(UsernameToDehashed) Failed to parse JSON for {username.value}: {e}"})
+ continue
+
+ dehashed_entries = response_json.get("entries", [])
+ if not dehashed_entries:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(UsernameToDehashed) failed for the username: '{username.value}': {api_request.text}"
+ },
+ )
+ continue
+
+
+ api_balance = response_json.get("balance")
+ if api_balance:
+ Logger.info(self.sketch_id, f'(UsernameToDehashed) Your remaining API balance is {api_balance}.')
+
+ for entry in dehashed_entries:
+ entry_email = entry.get("email")
+ entry_phone = entry.get("phone")
+ entry_name = entry.get("name")
+ entry_socialmedia = entry.get("social")
+ entry_ip = entry.get("ip_address")
+ entry_username = entry.get("username")
+ entry_dob = entry.get("dob")
+
+ results.append(
+ Individual(
+ full_name=entry_name[0] if entry_name else None,
+ birth_date=entry_dob[0] if entry_dob else None,
+ email_addresses=entry_email if entry_email else None,
+ phone_numbers=entry_phone if entry_phone else None,
+ social_media_profiles=entry_socialmedia if entry_socialmedia else None,
+ ip_addresses=entry_ip if entry_ip else None,
+ usernames=entry_username if entry_username else None
+ )
+ )
+ except Exception as e:
+ Logger.error(self.sketch_id, {"message": f"(UsernameToDehashed) Exception while querying username {username.value}: {e}"})
+
+ return results
+
+ def postprocess(
+ self, results: List[OutputType], input_data: List[InputType] = None
+ ) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ if input_data and self._graph_service:
+ for username in input_data:
+ for individual in results:
+ self.create_node(username)
+ self.create_node(individual)
+
+ # Create relationship
+ self.create_relationship(username, individual, "CONNECTION_WITH")
+ self.log_graph_message(
+ f"(UsernameToDehashed) Successfully found individual connections with {username.value}. "
+ )
+
+ return results
+
+
+# Make types available at module level for easy access
+InputType = UsernameToDehashed.InputType
+OutputType = UsernameToDehashed.OutputType
\ No newline at end of file
diff --git a/flowsint-enrichers/src/flowsint_enrichers/website/to_subdomain.py b/flowsint-enrichers/src/flowsint_enrichers/website/to_subdomain.py
new file mode 100644
index 00000000..79ad423d
--- /dev/null
+++ b/flowsint-enrichers/src/flowsint_enrichers/website/to_subdomain.py
@@ -0,0 +1,127 @@
+from typing import List, Union, Optional, Dict, Any
+from flowsint_core.core.enricher_base import Enricher
+from flowsint_enrichers.registry import flowsint_enricher
+from flowsint_core.core.logger import Logger
+from flowsint_types.website import Website
+import requests
+import os
+
+@flowsint_enricher
+class WebsiteToSubdomains(Enricher):
+ """[c99.nl] Performs an automated scan to find subdomains of the given domain."""
+
+ InputType = Website
+ OutputType = Website
+
+ def __init__(
+ self,
+ sketch_id: Optional[str] = None,
+ scan_id: Optional[str] = None,
+ vault=None,
+ params: Optional[Dict[str, Any]] = None,
+ ):
+ super().__init__(
+ sketch_id=sketch_id,
+ scan_id=scan_id,
+ params_schema=self.get_params_schema(),
+ vault=vault,
+ params=params,
+ )
+
+ @classmethod
+ def get_params_schema(cls) -> List[Dict[str, Any]]:
+ return [
+ {
+ "name": "C99_API_KEY",
+ "type": "vaultSecret",
+ "description": "Your C99.nl API key",
+ "required": True,
+ },
+ ]
+
+ @classmethod
+ def name(cls) -> str:
+ return "website_to_subdomains"
+
+ @classmethod
+ def category(cls) -> str:
+ return "Website"
+
+ @classmethod
+ def key(cls) -> str:
+ return "url"
+
+ async def scan(self, data: List[InputType]) -> List[OutputType]:
+ results = []
+
+ api_key = self.get_secret("C99_API_KEY", os.getenv("C99_API_KEY"))
+
+ for website in data:
+ try:
+ api_request = requests.get(f'https://api.c99.nl/subdomainfinder?key={api_key}&domain={website.url}', timeout=30)
+
+ if api_request.status_code != 200:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(WebsiteToSubdomains) Enricher failed for '{website.url}': {api_request.text}"
+ },
+ )
+ continue
+
+ response_json = api_request.json()
+
+ for subdomain in response_json.get("subdomains", []):
+ url = subdomain.get("subdomain")
+ if website.url not in [f'http://{url}', f'https://{url}', f'http://www.{url}', f'https://www.{url}']:
+ ip = subdomain.get("ip")
+
+ cloudflare = []
+ if subdomain.get("cloudflare") is True:
+ cloudflare.append("Cloudflare")
+ else:
+ cloudflare = None
+
+ results.append(
+ Website(
+ url=f"http://{url}", description=f"IP address: {ip}", technologies=cloudflare
+ )
+ )
+
+ except Exception as e:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(WebsiteToSubdomains) Failed to run enricher for {website.url}: {e}"
+ },
+ )
+
+ return results
+
+ def postprocess(self, results: List[OutputType], original_input: List[InputType]) -> List[OutputType]:
+ if not self._graph_service:
+ return results
+
+ for subdomain in results:
+ try:
+ self.create_node(subdomain)
+
+ for url in original_input:
+ self.create_node(url)
+ self.create_relationship(url, subdomain, "IS_SUBDOMAIN")
+ self.log_graph_message(
+ f"(WebsiteToSubdomains) Found {url.url}'s subdomain - '{subdomain.url}'"
+ )
+
+ except Exception as e:
+ Logger.error(
+ self.sketch_id,
+ {
+ "message": f"(WebsiteToSubdomains) relationship error: {e}"
+ },
+ )
+
+ return results
+
+InputType = WebsiteToSubdomains.InputType
+OutputType = WebsiteToSubdomains.OutputType
\ No newline at end of file