EmailRepIO

Provides email address reputation and reports.

Utilities · EmailRepIO

Details

IDEmailRepIO
ProviderSublime Security
CategoryUtilities
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658
Supported ModulesAgentix XSIAM

README

EmailRep.io provides the reputation and reports for email addresses.
This integration was integrated and tested with version EmailRep Alpha API v0.1 of EmailRep.io

Configure EmailRepIO in Cortex

Parameter Description Required
url Server URL (e.g., https://emailrep.io) True
apikey API Key False
insecure Trust any certificate (not secure) False
proxy Use system proxy settings False
Source Reliability Reliability of the source providing the intelligence data. False

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

emailrepio-email-reputation-get


Gets the EmailRepIO reputation for the given email address.

Base Command

emailrepio-email-reputation-get

Input

Argument Name Description Required
email_address The email address to get the reputation for. Required

Context Output

Path Type Description
EmailRepIO.Email.email String The email address that was queried.
EmailRepIO.Email.reputation String The reputation of the email. Possible values are: “high”, “medium”, “low”, and “none”.
EmailRepIO.Email.suspicious Boolean Whether the email address should be treated as suspicious or risky.
EmailRepIO.Email.references Number The total number of positive and negative sources of the reputation. Note that these may not all be direct references to the email address, but can include reputation sources for the domain or other related information.
EmailRepIO.Email.details.blacklisted Boolean Whether the email is believed to be malicious or spam.
EmailRepIO.Email.details.malicious_activity Boolean Whether the email exhibited malicious behavior (e.g., phishing or fraud).
EmailRepIO.Email.details.malicious_activity_recent Boolean Whether the email exhibited malicious behavior in the last 90 days (e.g., in the case of temporal account takeovers).
EmailRepIO.Email.details.credentials_leaked Boolean Whether the email credentials were ever leaked (e.g., a data breach, pastebin, dark web, etc.).
EmailRepIO.Email.details.credentials_leaked_recent Boolean Whether the email credentials were leaked in the last 90 days.
EmailRepIO.Email.details.data_breach Boolean Whether the email was ever in a data breach.
EmailRepIO.Email.details.first_seen Date The first date the email was observed in a breach, credential leak, or exhibiting malicious or spammy behavior. Displays “never” if the email was never observed in a breach, credential leak, or exhibiting malicious or spammy behavior.
EmailRepIO.Email.details.last_seen Date The last date the email was observed in a breach, credential leak, or exhibiting malicious or spammy behavior. Displays “never” if the email was never observed in a breach, credential leak, or exhibiting malicious or spammy behavior.
EmailRepIO.Email.details.domain_exists Boolean Whether the domain is a valid domain.
EmailRepIO.Email.details.domain_reputation String The reputation of the domain. Possible values are: “high”, “medium”, “low”, and “n/a”. Displays “n/a” if the domain is a free_provider, disposable, or doesn’t exist.
EmailRepIO.Email.details.new_domain Boolean Whether the domain was created within the last year.
EmailRepIO.Email.details.days_since_domain_creation Number The number of days since the domain was created.
EmailRepIO.Email.details.suspicious_tld Boolean Whether the email has a suspicious top level domain (tld).
EmailRepIO.Email.details.spam Boolean Whether the email has exhibited spammy behavior (e.g., spam traps, login form abuse).
EmailRepIO.Email.details.free_provider Boolean Whether the email uses a free email provider.
EmailRepIO.Email.details.disposable Boolean Whether the email uses a temporary or disposable service.
EmailRepIO.Email.details.deliverable Boolean Whether the email is deliverable.
EmailRepIO.Email.details.accept_all Boolean Whether the mail server has a default accept all policy. Some mail servers return inconsistent responses, so the default may be an accept all policy.
EmailRepIO.Email.details.valid_mx Boolean Whether the email has a mail exchanger (MX) record.
EmailRepIO.Email.details.spoofable Boolean Whether the email address can be spoofed (e.g., not a strict SPF policy or DMARC is not enforced).
EmailRepIO.Email.details.spf_strict Boolean Whether there is a sufficiently strict SPF record to prevent spoofing.
EmailRepIO.Email.details.dmarc_enforced Boolean Whether DMARC is configured correctly and enforced.
EmailRepIO.Email.details.profiles String The online profiles used by the email.

Command Example

!emailrepio-email-reputation-get email_address="test@example.com"

email


Gets the DBot score for the given email address using the EmailRepIO reputation.

Base Command

email

Input

Argument Name Description Required
email The email address to get the reputation for. Required

Context Output

Path Type Description
DBotScore.Indicator String The indicator that was tested.
DBotScore.Score Number The actual DBot score.
DBotScore.Type String The indicator type.
DBotScore.Vendor String The vendor used to calculate the score.
DBotScore.Reliability String Reliability of the source providing the intelligence data.
EmailRepIO.Email.email String email address that was queried
EmailRepIO.Email.reputation String The reputation of the email. Possible values are: “high”, “medium”, “low”, and “none”.
EmailRepIO.Email.suspicious Boolean Whether the email address should be treated as suspicious or risky.
EmailRepIO.Email.references Number The total number of positive and negative sources of the reputation. Note that these may not all be direct references to the email address, but can include reputation sources for the domain or other related information.
EmailRepIO.Email.details.blacklisted Boolean Whether the email is believed to be malicious or spam.
EmailRepIO.Email.details.malicious_activity Boolean Whether the email exhibited malicious behavior (e.g., phishing or fraud).
EmailRepIO.Email.details.malicious_activity_recent Boolean Whether the email exhibited malicious behavior in the last 90 days (e.g., in the case of temporal account takeovers).
EmailRepIO.Email.details.credentials_leaked Boolean Whether the email credentials were ever leaked (e.g., a data breach, pastebin, dark web, etc.).
EmailRepIO.Email.details.credentials_leaked_recent Boolean Whether the email credentials were leaked in the last 90 days.
EmailRepIO.Email.details.data_breach Boolean Whether the email was ever in a data breach.
EmailRepIO.Email.details.first_seen Date The first date the email was observed in a breach, credential leak, or exhibiting malicious or spammy behavior. Displays “never” if the email was never observed in a breach, credential leak, or exhibiting malicious or spammy behavior.
EmailRepIO.Email.details.last_seen Date The last date the email was observed in a breach, credential leak, or exhibiting malicious or spammy behavior. Displays “never” if the email was never observed in a breach, credential leak, or exhibiting malicious or spammy behavior.
EmailRepIO.Email.details.domain_exists Boolean Whether the domain is a valid domain.
EmailRepIO.Email.details.domain_reputation String The reputation of the domain. Possible values are: “high”, “medium”, “low”, and “n/a”. Displays “n/a” if the domain is a free_provider, disposable, or doesn’t exist.
EmailRepIO.Email.details.new_domain Boolean Whether the domain was created within the last year.
EmailRepIO.Email.details.days_since_domain_creation Number The number of days since the domain was created.
EmailRepIO.Email.details.suspicious_tld Boolean Whether the email has a suspicious top level domain (tld).
EmailRepIO.Email.details.spam Boolean Whether the email exhibited spammy behavior (e.g., spam traps, login form abuse).
EmailRepIO.Email.details.free_provider Boolean Whether the email uses a free email provider.
EmailRepIO.Email.details.disposable Boolean Whether the email uses a temporary or disposable service.
EmailRepIO.Email.details.deliverable Boolean Whether the email is deliverable.
EmailRepIO.Email.details.accept_all Boolean Whether the mail server has a default accept all policy. Some mail servers return inconsistent responses, so the default may be an accept all policy.
EmailRepIO.Email.details.valid_mx Boolean Whether the email has a mail exchanger (MX) record.
EmailRepIO.Email.details.spoofable Boolean Whether the email has a mail exchanger (MX) record. (e.g., not a strict SPF policy or DMARC is not enforced).
EmailRepIO.Email.details.spf_strict Boolean Whether there is a sufficiently strict SPF record to prevent spoofing.
EmailRepIO.Email.details.dmarc_enforced Boolean Whether DMARC is configured correctly and enforced.
EmailRepIO.Email.details.profiles String The online profiles used by the email.

Command Example

!email email="test@example.com"

emailrepio-email-address-report


Reports a malicious email address to EmailRepIO.  You tag the type of malicious activity associated with the email address. The date of the malicious activity defaults to the current time unless otherwise specified.

Base Command

emailrepio-email-address-report

Input

Argument Name Description Required
email_address The email address to report. Required
tags The tags that should be applied. See detailed descriptions in the EmailRepIO documentation for more information. Required
description Additional information and context. Optional
timestamp The time the activity occurred in UTC time format. Defaults to now(). Optional
expires The number of hours the email should be considered risky (suspicious=true and blacklisted=true in the QueryResponse). Defaults to no expiration unless the “account_takeover” tag is specified, in which case the default is 14 days. Optional

Context Output

There is no context output for this command.

Command Example

!emailrepio-email-address-report email_address="test@example.com" tags="spam"

Configuration parameters

  • url — Server URL (e.g., https://emailrep.io) (required)
  • apikey — API Key
  • credentials
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings
  • integration_reliability — Source Reliability

Commands (3)

  • email

    Gets the DBot score for the given email address using the EmailRepIO reputation.

  • emailrepio-email-address-report

    Reports a malicious email address to EmailRepIO. You tag the type of malicious activity associated with the email address. The date of the malicious activity defaults to the current time unless otherwise specified.

  • emailrepio-email-reputation-get

    Gets the EmailRepIO reputation for the given email address.

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401

"""EmailRepIO Integration for Cortex XSOAR"""
from typing import Any

import urllib3

from CommonServerUserPython import *

# Disable insecure warnings
urllib3.disable_warnings()


""" CONSTANTS """


ACCEPTED_TAGS = [
    "account_takeover",
    "bec",
    "brand_impersonation",
    "browser_exploit",
    "credential_phishing",
    "generic_phishing",
    "malware",
    "scam",
    "spam",
    "spoofed",
    "task_request",
    "threat_actor",
]
APP_NAME = "Cortex-XSOAR"
INTEGRATION_NAME = "EmailRepIO"

""" CLIENT CLASS """


class Client(BaseClient):
    """Client class to interact with the EmailRepIO service API"""

    def get_email_address_reputation(self, email: str) -> dict[str, Any]:
        """Get email reputation using the '/{email}' API endpoint"""

        return self._http_request(method="GET", url_suffix=f"/{email}")

    def post_email_address_report(
        self, email: str, tags: list[str], description: str | None, timestamp: int | None, expires: int | None
    ) -> dict[str, Any]:
        """Report email reputation using the '/report' API endpoint"""
        request_params: dict[str, Any] = {}
        request_params["email"] = email
        request_params["tags"] = tags

        if description:
            request_params["description"] = description

        if timestamp:
            request_params["timestamp"] = timestamp

        if expires:
            request_params["expires"] = expires

        return self._http_request(method="POST", url_suffix="/report", json_data=request_params)


""" COMMAND FUNCTIONS """


def test_module(client: Client) -> str:
    """Test API connectivity and authentication."""
    try:
        client.get_email_address_reputation(email="test@example.com")
    except DemistoException as e:
        if "invalid api key" in str(e):
            return "Authorization Error: make sure API Key is correctly set"
        else:
            raise e
    return "ok"


def email_command(client: Client, args: dict[str, Any], reliability: str) -> list[CommandResults]:
    """Get email address reputation from EmailRepIO and calculate DBotScore.

    DBot score:
    Good: Suspicious = false
    Malicious: Suspicious = true + (malicious_activity_recent = true or credentials_leaked_recent = true)
    Suspicious: Suspicious = true and not malicious
    """
    emails = argToList(args.get("email"))
    if len(emails) == 0 or emails is None:
        raise ValueError("Email(s) not specified")

    emails_results = []

    for email in emails:
        email_data = client.get_email_address_reputation(email)
        description = f"{INTEGRATION_NAME} returned"
        suspicious = email_data.get("suspicious")
        malicious_activity_recent = email_data.get("details.malicious_activity_recent")
        credentials_leaked_recent = email_data.get("details.credentials_leaked_recent")

        if not suspicious:
            score = Common.DBotScore.GOOD
            description = ""
        elif malicious_activity_recent or credentials_leaked_recent:
            if malicious_activity_recent:
                description += " malicious_activity_recent"
            if credentials_leaked_recent:
                description += " credentials_leaked_recent"
            score = Common.DBotScore.BAD
        else:
            score = Common.DBotScore.SUSPICIOUS
            description = ""

        dbot_score = Common.DBotScore(
            indicator=email,
            indicator_type=DBotScoreType.ACCOUNT,
            integration_name=INTEGRATION_NAME,
            score=score,
            malicious_description=description,
            reliability=DBotScoreReliability.get_dbot_score_reliability_from_str(reliability),
        )

        account_context = Common.Account(id=email, email_address=email, dbot_score=dbot_score)

        readable_output = tableToMarkdown("Email", email_data)

        result = CommandResults(
            readable_output=readable_output,
            outputs_prefix=f"{INTEGRATION_NAME}.Email",
            outputs_key_field="id",
            outputs=email_data,
            indicator=account_context,
        )
        emails_results.append(result)

    return emails_results


def email_reputation_command(client: Client, args: dict[str, Any]) -> CommandResults:
    """Get email address reputation from EmailRepIO"""

    emails = argToList(args.get("email_address"))
    if len(emails) == 0 or emails is None:
        raise ValueError("Email(s) not specified")

    email = emails[0]
    email_data = client.get_email_address_reputation(email)

    readable_output = tableToMarkdown("Email", email_data)

    return CommandResults(
        readable_output=readable_output, outputs_prefix=f"{INTEGRATION_NAME}.Email", outputs_key_field="email", outputs=email_data
    )


def report_email_address_command(client: Client, args: dict[str, Any]) -> CommandResults:
    """Report email address to EmailRepIO"""

    email_address = args.get("email_address")
    if email_address is None:
        raise ValueError("Email(s) not specified")
    tags = argToList(args.get("tags"))
    if len(tags) == 0:
        raise ValueError("Tag(s) not specified")
    for tag in tags:
        if tag not in ACCEPTED_TAGS:
            raise ValueError(f"Tag '{tag}' not in accepted tag list: {ACCEPTED_TAGS}")

    description = args.get("description")
    timestamp = args.get("timestamp")
    if timestamp is not None:
        timestamp = int(args.get("timestamp"))  # type: ignore

    expires = args.get("expires")
    if expires is not None:
        expires = int(args.get("expires"))  # type: ignore

    result = client.post_email_address_report(
        email=email_address, tags=tags, description=description, timestamp=timestamp, expires=expires
    )

    readable_output = tableToMarkdown("Email Report Response", result)

    return CommandResults(
        readable_output=readable_output, outputs_prefix=f"{INTEGRATION_NAME}.Report", outputs_key_field="status", outputs=result
    )


""" MAIN FUNCTION """


def main() -> None:  # pragma: no cover
    """main function, parses params and runs command functions"""
    demisto_params = demisto.params()
    api_key = demisto_params.get("credentials", {}).get("password") or demisto_params.get("apikey")

    # get the service API url
    base_url = demisto_params.get("url", "")
    verify_certificate = not demisto_params.get("insecure", False)
    proxy = demisto_params.get("proxy", False)
    reliability = demisto_params.get("integration_reliability", "")

    demisto.debug(f"Command being called is {demisto.command()}")
    try:
        headers = {"Key": f"{api_key}", "User-Agent": APP_NAME}
        client = Client(base_url=base_url, verify=verify_certificate, headers=headers, proxy=proxy)

        if demisto.command() == "emailrepio-email-reputation-get":
            return_results(email_reputation_command(client, demisto.args()))

        elif demisto.command() == "email":
            return_results(email_command(client, demisto.args(), reliability))

        elif demisto.command() == "emailrepio-email-address-report":
            return_results(report_email_address_command(client, demisto.args()))

        elif demisto.command() == "test-module":
            # This is the call made when pressing the integration Test button.
            return_results(test_module(client))

        else:
            raise NotImplementedError(f"Command {demisto.command()} was not found in {INTEGRATION_NAME} commands")

    # Log exceptions and return errors
    except Exception as e:
        return_error(f"Failed to execute {demisto.command()} command.\nError:\n{e!s}")


""" ENTRY POINT """


if __name__ in ("__main__", "__builtin__", "builtins"):  # pragma: no cover
    main()