Cofense Intelligence Deprecated

Deprecated. Use Cofense Intelligence v2 instead. Use the Cofense Intelligence integration to check the reputation of URLs, IP addresses, file hashes, and email addresses.

Data Enrichment & Threat Intelligence · Cofense Intelligence (Deprecated)

Details

IDCofense Intelligence
ProviderCofense
CategoryData Enrichment & Threat Intelligence
From Version5.0.0
Supported ModulesAgentix

README

Use the Cofense Intelligence integration to check the reputation of URLs, IP addresses, file hashes, and email addresses.

Configure Cofense Intelligence in Cortex

Parameter Description Required
Server URL (e.g., https://www.threathq.com/apiv1)   True
API username   True
Source Reliability Reliability of the source providing the intelligence data. True
Use system proxy settings   False
Trust any certificate (not secure)   False
URL Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the URL malicious   False
File Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the file malicious   False
IP Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the IP malicious   False
Email Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the email malicious   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.

url


Checks the reputation of a URL.

Base Command

url

Input

Argument Name Description Required
url URL to check. Required

Context Output

Path Type Description
URL.Data unknown Bad URLs.
URL.Malicious.Vendor unknown For malicious URLs, the vendor that made the decision.
URL.Malicious.Description unknown For malicious URLs, the reason that the vendor made the decision.
DBotScore.Indicator String The indicator that was tested.
DBotScore.Type String The indicator type.
DBotScore.Vendor String The vendor used to calculate the score.
DBotScore.Score Number The actual score.
DBotScore.Reliability String Reliability of the source providing the intelligence data.
Cofense.URL.Data unknown Bad URLs.
Cofense.URL.Malicious.Vendor unknown For malicious URLs, the vendor that made the decision.
Cofense.URL.Malicious.Description unknown For malicious URLs, the reason that the vendor made the decision.
Cofense.URL.Cofense.ThreatIDs unknown The thread IDs retrieved by the vendor.

Command Example

!url url=example.com using="Cofense Intelligence_instance_1"

Context Example

{
    "DBotScore": {
        "Indicator": "example.com",
        "Reliability": "B - Usually reliable",
        "Score": 0,
        "Type": "url",
        "Vendor": "Cofense"
    }
}

Human Readable Output

Cofense URL Reputation for: example.com

No information found for this url

file


Checks the reputation of a file hash.

Base Command

file

Input

Argument Name Description Required
file A CSV list of file hashes to check (MD5, SHA1, or SHA256). Required

Context Output

Path Type Description
File.MD5 unknown File MD5
File.Malicious.Vendor unknown For malicious files, the vendor that made the decision.
File.Malicious.Description unknown For malicious files, the reason that the vendor made the decision.
DBotScore.Indicator String The indicator that was tested.
DBotScore.Type String The indicator type.
DBotScore.Vendor String The vendor used to calculate the score.
DBotScore.Score Number The actual score.
DBotScore.Reliability String Reliability of the source providing the intelligence data.
Cofense.File.MD5 unknown MD5 hash of the file.
Cofense.File.Malicious.Vendor unknown For malicious files, the vendor that made the decision.
Cofense.File.Malicious.Description unknown For malicious files, the reason that the vendor made the decision.
Cofense.File.ThreatIDs unknown The thread IDs retrieved by the vendor.

Command Example


#### Human Readable Output

### ip

***
Checks the reputation of an IP address.

#### Base Command

`ip`

#### Input

| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| ip | IP address to check. | Required |

#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| IP.Data | unknown | Bad IP Address found |
| IP.Malicious.Vendor | unknown | For malicious IPs, the vendor that made the decision |
| IP.Malicious.Description | unknown | For malicious IPs, the reason that the vendor made the decision |
| DBotScore.Indicator | String | The indicator that was tested. |
| DBotScore.Type | String | The indicator type. |
| DBotScore.Vendor | String | The vendor used to calculate the score. |
| DBotScore.Score | Number | The actual score. |
| DBotScore.Reliability | String | Reliability of the source providing the intelligence data. |
| Cofense.IP.Data | unknown | Bad IP Address found |
| Cofense.IP.Malicious.Vendor | unknown | For malicious IPs, the vendor that made the decision |
| Cofense.IP.Malicious.Description | unknown | For malicious IPs, the reason that the vendor made the decision |
| Cofense.IP.Cofense.ThreatIDs | unknown | The thread ids retrieved by the vendor. |
| IP.ASN | unknown | Autonomous System name for the IP. |
| IP.GEO.Location | unknown | Location in format latitude, longitude. |
| IP.GEO.Country | unknown | Country of the IP. |
| IP.Address | string | IP address. |

#### Command Example

```!ip ip=1.2.3.4 using="Cofense Intelligence_instance_1"```

#### Context Example

```json
{
    "DBotScore": {
        "Indicator": "1.2.3.4",
        "Reliability": "B - Usually reliable",
        "Score": 0,
        "Type": "ip",
        "Vendor": "Cofense"
    }
}
```

#### Human Readable Output

>## Cofense IP Reputation for: x.x.x.x
>
>No information found for this ip

### email

***
Checks the reputation of an email address.

#### Base Command

`email`

#### Input

| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| email | Sender email address to check. | Required |

#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| Email.Data | unknown | Sender address to check. |
| Account.Email.Address | unknown | Sender email address to check. |
| Account.Email.Malicious.Vendor | unknown | For malicious emails, the vendor that made the decision. |
| Account.Email.Malicious.Description | unknown | For malicious emails, the reason that the vendor made the decision. |
| DBotScore.Indicator | String | The indicator that was tested. |
| DBotScore.Type | String | The indicator type. |
| DBotScore.Vendor | String | The vendor used to calculate the score. |
| DBotScore.Score | Number | The actual score. |
| DBotScore.Reliability | String | Reliability of the source providing the intelligence data. |
| Cofense.Email.Data | unknown | Sender address to check. |
| Cofense.Email.Malicious.Vendor | unknown | For malicious emails, the vendor that made the decision. |
| Cofense.Email.Malicious.Description | unknown | For malicious URLs, the reason that the vendor made the decision. |
| Cofense.Email.Cofense.ThreatIDs | unknown | The thread ids retrieved by the vendor. |

#### Command Example

```!email email=example@example.com using="Cofense Intelligence_instance_1"```

#### Context Example

```json
{
    "DBotScore": {
        "Indicator": "example@example.com",
        "Reliability": "B - Usually reliable",
        "Score": 0,
        "Type": "email",
        "Vendor": "Cofense"
    }
}
```

#### Human Readable Output

>## Cofense email Reputation for: example@example.com
>
>No infomation found for this email

### cofense-search

***
Searches for extracted strings identified within malware campaigns.

#### Base Command

`cofense-search`

#### Input

| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| str | String to search. | Required |
| limit | Maximum number of strings to search. Default is 10. Default is 10. | Optional |

#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| Cofense.NumOfThreats | unknown | Number of threats. |
| Cofense.String | unknown | String that was searched. |

#### Command Example

Human Readable Output

Configuration parameters

  • url — Server URL (e.g., https://www.threathq.com/apiv1) (required)
  • credentials — API username (required)
  • integrationReliability — Source Reliability (required)
  • proxy — Use system proxy settings
  • insecure — Trust any certificate (not secure)
  • urlThreshold — URL Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the URL malicious
  • fileThreshold — File Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the file malicious
  • ipThreshold — IP Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the IP malicious
  • emailThreshold — Email Threshold (None, Minor, Moderate, or Major). Minimum severity to consider the email malicious

Commands (5)

  • cofense-search

    Searches for extracted strings identified within malware campaigns.

  • email

    Checks the reputation of an email address.

  • file

    Checks the reputation of a file hash.

  • ip

    Checks the reputation of an IP address.

  • url

    Checks the reputation of a URL.

 var reliability = params.integrationReliability;

 if(!reliability){
     reliability = 'B - Usually reliable';
 }
 var isValidReliability = function(reliability) {
     var reliability_options = ['A+ - 3rd party enrichment', 'A - Completely reliable', 'B - Usually reliable', 'C - Fairly reliable', 'D - Not usually reliable', 'E - Unreliable', 'F - Reliability cannot be judged'];
     return reliability_options.indexOf(reliability) >= 0;}
 if(!isValidReliability(reliability)) {
     return 'Error, Source Reliability value is invalid. Please choose from available reliability options.';}

  var auth = 'Basic ' + Base64.encode(params.credentials.identifier + ':' + params.credentials.password);
     var sendRequest = function(method,api,urlargs) {
         var url = params.url;
         if (url[url.length - 1] === '/') {
             url = url.substring(0, url.length - 1);
         }
         var requestUrl = url + '/' + api + encodeToURLQuery(urlargs);
         var res = http(
             requestUrl,
             {
                 Method: method,
                 Headers: {
                     'Authorization': [auth]
                 }
             },
             params.insecure,
             params.proxy
         );
         if ((res.StatusCode < 200 || res.StatusCode >= 300) && res.success === false) {
             throw 'Cofense Request Failed.\nStatus code: ' + res.StatusCode + '.\nBody: ' + JSON.stringify(res) + '.';
         }
         try{
             return JSON.parse(res.Body);
         }
         catch(exc){
             throw "Cofense Error: JSON parse error\n" + res;
         }
     };
     var addMD = function(threat) {
         var md = "";
         md += '### Threat ID: ' + threat.id + '\n';
         if (threat.label !== undefined) {
             md += "Name of the campaign: **" + threat.label + "**\n";
         }
         if (threat.blockSet[0].ipDetail !== undefined) {
             md += "ASN: **" + threat.blockSet[0].ipDetail.asn + " " + threat.blockSet[0].ipDetail.asnOrganization+"**\n";
         }
         if (threat.blockSet[0].ipDetail !== undefined) {
             md += "Country: **" + threat.blockSet[0].ipDetail.countryName + "**\n";
         }
         if (threat.executiveSummary !== undefined) {
             md += "#### Executive Summary: \n";
         }
         if (threat.executiveSummary !== undefined) {
             md += threat.executiveSummary + "\n";
         }
         md += "#### Threat Types:\n";
         for (var j = 0; j < threat.malwareFamilySet.length; j++){
             md += "* " + threat.malwareFamilySet[j].description + "\n";
         }
         md += '##### Last published: ' + new Date(threat.lastPublished) +'\n';
         return md;
     };
     // Returns {severityScore: 'The severity score found', md: 'The markdown for the threat', indicatorFound: 'set to true if indicator was found in threat'}
     var checkThreat = function(threat, threshold, indicator) {
         var severityLevel = 0;
         var md = '';
         var threshold_score = calcScore(threshold);
         if (threshold_score === -1) {
             throw "Cofense error: Invalid threshold value: " + threshold + ". Valid values are: None, Minor, Moderate or Major.";
         }
         res = {}
         for (var i = 0; i < threat.blockSet.length; i++){
             if (threat.blockSet[i]['impact']) {
                 var threat_score = calcScore(threat.blockSet[i]['impact']);
                 var adjusted_score = threshold_score <= threat_score ? 3 : threat_score;
                 // if the queried indicator has a severity level, we'll take it
                 if (threat.blockSet[i]['data'] === indicator) {
                     severityLevel = adjusted_score;
                     res.indicatorFound = true;
                     break;
                 }
                 severityLevel = Math.max(severityLevel, adjusted_score);
             }
         }
         var threatLevel = calcVerdict(severityLevel);
         md += 'Verdict: ' + threatLevel +'\n';
         md += addMD(threat);
         res.severityScore = severityLevel;
         res.md = md;
         return res;
     }
     var searchUrl = function(url) {
         var tmpargs = {};
         tmpargs.urlSearch = url;
         var res = sendRequest("POST","threat/search",tmpargs);
         var threats = res.data.threats;
         var ec = {};
         var md = "## Cofense URL Reputation for: "+url+"\n";
         var dbotScore = 0;
         var threatArray = [];
         var threshold = params.urlThreshold;
         var indicatorFnd = false;
         if (threats.length && threats.length !== 0) {
             ec[outputPaths.url] = {
                 Data: url
             };
             for (var k = 0; k < threats.length; k++) {
                 threatAnalysis = checkThreat(threats[k], threshold, url);
                 threatArray[k] = threats[k].id;
                 md += threatAnalysis['md'];
                 if (threatAnalysis.indicatorFound) {
                     indicatorFnd = true;
                     dbotScore = threatAnalysis['severityScore'];
                 } else if (!indicatorFnd) {
                     dbotScore = Math.max(dbotScore, threatAnalysis['severityScore']);
                 }
             }
             ec[outputPaths.url]['Cofense'] = {};
             ec[outputPaths.url].Cofense['ThreatIDs'] = threatArray;
             ec["Cofense." + outputPaths.url] = {
                 Data: url,
                 ThreatIDs: threatArray
             };
             if (dbotScore === 3) {
                 ec[outputPaths.url].Malicious = {
                     Vendor: 'Cofense',
                     Description: 'Match found in Cofense database'
                 };
                 ec["Cofense." + outputPaths.url].Malicious = ec[outputPaths.url].Malicious;
             }
         } else {
             md += "No information found for this url";
         }
         ec.DBotScore = {Indicator: url, Type: 'url', Vendor: 'Cofense', Score: dbotScore, Reliability: reliability};
         return ( {'ContentsFormat': formats.json, 'Type': entryTypes.note, 'Contents': res, "HumanReadable": md, "EntryContext": ec} );
     };
     var extractedString = function(str,limit) {
         var tmpargs = {};
         tmpargs.extractedString = str;
         var res = sendRequest("POST","threat/search",tmpargs);
         var threats = res.data.threats;
         var countThreats = 0;
         var md = "## Cofense Search Reputation for: "+str+"\n";
         var mdBody = "";
         var ec = {};
         if (threats.length !== 0) {
             if(limit === undefined){
                 limit = 10;
             }
             for(var i = 0; i < threats.length && (countThreats<limit); i++){
                 if (threats[i].hasReport === true){
                     countThreats += 1;
                     mdBody += addMD(threats[i]);
                 }
             }
             md += "There are " + countThreats + " threats regarding your string search.\n";
             md += "### Details from the last campaign\n";
             md += mdBody;
             ec = {"Cofense" : {}};
             ec.Cofense = {"String": str, "NumOfThreats": countThreats};
         } else {
             md += "There are no results for this search\n";
             ec = {"Cofense" : {}};
             ec.Cofense = {"String": str, "NumOfThreats": 0};
         }
         return ( {'ContentsFormat': formats.json, 'Type': entryTypes.note, 'Contents': res, "HumanReadable": md, "EntryContext": ec} );
     };
     var checkEmail = function(sender_name) {
         var tmpargs = {};
         tmpargs.watchListEmail = sender_name;
         var res = sendRequest("POST","threat/search",tmpargs);
         var threats = res.data.threats;
         var ec = {};
         var md = "## Cofense email Reputation for: " + sender_name + "\n";
         var dbotScore = 0;
         var threatArray = [];
         var threshold = params.emailThreshold;
         var indicatorFnd = false;
         var contextEmailKey = 'Email(val.Data && val.Data === obj.Data)';
         if (threats.length && threats.length !== 0) {
             ec[contextEmailKey] = {
                 'Data': sender_name
             };
             ec[outputPaths.email] = {
                 'Address': sender_name
             };
             for (var k = 0; k < threats.length; k++) {
                 threatAnalysis = checkThreat(threats[k], threshold, sender_name);
                 threatArray[k] = threats[k].id;
                 md += threatAnalysis['md'];
                 if (threatAnalysis.indicatorFound) {
                     indicatorFnd = true;
                     dbotScore = threatAnalysis['severityScore'];
                 } else if (!indicatorFnd) {
                     dbotScore = Math.max(dbotScore, threatAnalysis['severityScore']);
                 }
             }
             ec[contextEmailKey]['Cofense'] = {};
             ec[contextEmailKey].Cofense['ThreatIDs'] = threatArray;
             ec['Cofense.' + contextEmailKey] = {
                 Data: sender_name,
                 ThreatIDs: threatArray
             };
             if (dbotScore === 3) {
                 ec[outputPaths.email].Malicious = {
                     Vendor: 'Cofense',
                     Description: 'Match found in Cofense database'
                 };
                 ec["Cofense." + contextEmailKey].Malicious = ec[outputPaths.email].Malicious;
             }
         } else {
             md += "No infomation found for this email";
         }
         ec.DBotScore = {Indicator: sender_name, Type: 'email', Vendor: 'Cofense', Score: dbotScore, Reliability: reliability};
         return ( {'ContentsFormat': formats.json, 'Type': entryTypes.note, 'Contents': res, "HumanReadable": md, "EntryContext": ec} );
     };
     var checkMD5 = function(str) {
         var tmpargs = {};
         tmpargs.allMD5 = str;
         var res = sendRequest("POST","threat/search",tmpargs);
         var threats = res.data.threats;
         var ec = {};
         var md = "## Cofense Hash Reputation for: "+str+"\n";
         var dbotScore = 0;
         var threatArray = [];
         var threshold = params.fileThreshold;
         var indicatorFnd = false;
         var threshold_score = calcScore(threshold);
         if (threshold_score === -1) {
             throw "Cofense error: Invalid threshold value: " + threshold + ". Valid values are: None, Minor, Moderate or Major.";
         }
         if (threats.length !== 0) {
             ec[outputPaths.file] = {
                 MD5: str
             };
             for (var k = 0; k < threats.length; k++) {
                 var severityLevel = 0;
                 for (var i = 0; i < threats[k].blockSet.length; i++){
                     if (threats[k].blockSet[i]['impact']) {
                         var threat_score = calcScore(threats[k].blockSet[i]['impact']);
                         var adjusted_score = threshold_score <= threat_score ? 3 : threat_score;
                         // if the queried indicator has a severity level, we'll take it
                         if (threats[k].executableSet[i] && threats[k].executableSet[i]['md5Hex'] === str) {
                             severityLevel = adjusted_score;
                             dbotScore = severityLevel;
                             indicatorFnd = true;
                             break;
                         }
                         severityLevel = Math.max(severityLevel, adjusted_score);
                     }
                 }
                 var threatLevel = calcVerdict(severityLevel);
                 md += 'Verdict: ' + threatLevel +'\n';
                 md += addMD(threats[k]);
                 threatArray[k] = threats[k].id;
                 if (!indicatorFnd) {
                     dbotScore = Math.max(dbotScore, severityLevel);
                 }
             }
             ec[outputPaths.file]['Cofense'] = {};
             ec[outputPaths.file]['ThreatIDs'] = threatArray;
             ec['Cofense.' + outputPaths.file] = {
                     MD5: str,
                     ThreatIDs: threatArray
             };
             if (dbotScore === 3) {
                 ec[outputPaths.file].Malicious = {
                     Vendor: 'Cofense',
                     Description: 'Match found in Cofense database'
                 };
                 ec["Cofense." + outputPaths.file].Malicious = ec[outputPaths.file].Malicious;
             }
         } else {
             md += "No information found for this hash";
         }
         ec.DBotScore = {Indicator: str, Type: 'file', Vendor: 'Cofense', Score: dbotScore, Reliability: reliability};
         return ( {'ContentsFormat': formats.json, 'Type': entryTypes.note, 'Contents': res, "HumanReadable": md, "EntryContext": ec} );
     }
     var checkIP = function(ip) {
         var tmpargs = {};
         tmpargs.ip = ip;
         var res = sendRequest("POST","threat/search",tmpargs);
         var threats = res.data.threats;
         var ec = {};
         var md = "## Cofense IP Reputation for: "+ip+"\n";
         var dbotScore = 0;
         var threatArray = [];
         var threshold = params.ipThreshold;
         var indicatorFnd = false;
         var threshold_score = calcScore(threshold);
         if (threshold_score === -1) {
             throw "Cofense error: Invalid threshold value: " + threshold + ". Valid values are: None, Minor, Moderate or Major.";
         }
         if (threats.length && threats.length !== 0) {
             ec[outputPaths.ip] = {
                 Data: ip,
                 'Address': ip
             };
             for (var k = 0; k < threats.length; k++) {
                 var severityLevel = 0;
                 for (var i = 0; i < threats[k].blockSet.length; i++){
                     if (threats[k].blockSet[i].data === ip && threats[k].blockSet[i].ipDetail) {
                         ec[outputPaths.ip].ASN = threats[k].blockSet[i].ipDetail.asn;
                         ec[outputPaths.ip].GEO = {
                             "Location": (threats[k].blockSet[i].ipDetail.latitude + ', ' + threats[k].blockSet[i].ipDetail.longitude),
                             "Country": threats[k].blockSet[i].ipDetail.countryIsoCode
                         };
                     }
                     if (threats[k].blockSet[i]['impact']) {
                         var threat_score = calcScore(threats[k].blockSet[i]['impact']);
                         var adjusted_score = threshold_score <= threat_score ? 3 : threat_score;
                         // if the queried indicator has a severity level, we'll take it
                         if (threats[k].blockSet[i]['ipDetail'] && threats[k].blockSet[i]['ipDetail']['ip']===ip) {
                             severityLevel = adjusted_score;
                             dbotScore = severityLevel;
                             indicatorFnd = true;
                             break;
                         }
                         severityLevel = Math.max(severityLevel, adjusted_score);
                     }
                 }
                 var threatLevel = calcVerdict(severityLevel);
                 md += 'Verdict: ' + threatLevel +'\n';
                 md += addMD(threats[k]);
                 threatArray[k] = threats[k].id;
                 if (!indicatorFnd) {
                     dbotScore = Math.max(dbotScore, severityLevel);
                 }
             }
             ec[outputPaths.ip]['Cofense'] = {};
             ec[outputPaths.ip].Cofense['ThreatIDs'] = threatArray;
             ec["Cofense." + outputPaths.ip] = {
                 Data: ip,
                 ThreatIDs: threatArray
             };
             if (dbotScore === 3) {
                 ec[outputPaths.ip].Malicious = {
                     Vendor: 'Cofense',
                     Description: 'Match found in Cofense database'
                 };
                 ec["Cofense." + outputPaths.ip].Malicious = ec[outputPaths.ip].Malicious;
             }
         } else {
             md += "No information found for this ip";
         }
         ec.DBotScore = {Indicator: ip, Type: 'ip', Vendor: 'Cofense', Score: dbotScore, Reliability: reliability};
         return ( {'ContentsFormat': formats.json, 'Type': entryTypes.note, 'Contents': res, "HumanReadable": md, "EntryContext": ec} );
     }
     var calcVerdict = function (dbotScore) {
         switch (dbotScore){
             case 0:
                 return 'Unknown';
             case 2:
                 return 'Suspicious';
             case 3:
                 return 'Bad';
         }
     }
     var calcScore = function (severityLevel) {
         switch (severityLevel){
             case 'None':
                 return 0;
             case 'Minor':
                 return 2;
             case 'Moderate':
                 return 2;
             case 'Major':
                 return 3;
             default:
                 return -1;
         }
     }
     function addDays(theDate, days) {
         return theDate.getTime() - days*24*60*60*1000;
     }
     var updates = function(){
         var newDate = addDays(new Date(), 50);
         var tmpargs = {};
         tmpargs.timestamp = newDate;
         var res = sendRequest("POST","threat/updates", tmpargs);
         var ec = {};
         var md = "";
         return res;
     }
     switch (command) {
         // This is the call made when pressing the integration test button.
         case 'test-module':
             res = updates();
             if (res.success === true){
                 return 'ok';
             }else {
                 return JSON.stringify(res);
             }
         case "url":
             return searchUrl(args.url);
         case "cofense-search":
             return extractedString(args.str, args.limit);
         case "email":
             return checkEmail(args.email)
         case "file":
             return checkMD5(args.file);
         case "ip":
             return checkIP(args.ip);
         default:
    }