Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…alyzers into nsmfoo-CIRCLHashlookup
  • Loading branch information
jeromeleonard committed Jul 21, 2021
2 parents 85b0db0 + 84105fc commit 2ea153a
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 97 deletions.
101 changes: 4 additions & 97 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,68 +62,6 @@ steps:
when:
event: [tag]


# Bintray will not be used anymore. We keep it until Feb 21

- name: upload catalogs to bintray
image: thehiveproject/drone-bintray
settings:
user: {from_secret: bintray_user}
key: {from_secret: bintray_key}
subject: thehive-project
package: catalogs
version: latest
override: 1
publish: 1
commands:
- |
export PLUGIN_USER
export PLUGIN_KEY
export PLUGIN_SUBJECT
export PLUGIN_PACKAGE
export PLUGIN_VERSION
export PLUGIN_OVERRIDE
export PLUGIN_PUBLISH
upload \
--file analyzers/analyzers.json \
--repo cortexneurons
upload \
--file analyzers/analyzers-stable.json \
--repo cortexneurons
upload \
--file responders/responders.json \
--repo cortexneurons
upload \
--file responders/responders-stable.json \
--repo cortexneurons
when:
event: [tag]

- name: upload report-templates to bintray
image: thehiveproject/drone-bintray
settings:
user: {from_secret: bintray_user}
key: {from_secret: bintray_key}
subject: thehive-project
package: report-templates
version: latest
override: 1
publish: 1
commands:
- |
export PLUGIN_USER
export PLUGIN_KEY
export PLUGIN_SUBJECT
export PLUGIN_PACKAGE
export PLUGIN_VERSION
export PLUGIN_OVERRIDE
export PLUGIN_PUBLISH
upload \
--file analyzers/report-templates.zip \
--repo binary
when:
event: [tag]

- name: upload catalogs and report-templates package to package server
image: appleboy/drone-scp
settings:
Expand All @@ -146,37 +84,6 @@ steps:
when:
branch: [develop]


# Bintray will not be used anymore. We keep it until Feb 21
- name: upload devel catalogs to bintray
image: thehiveproject/drone-bintray
settings:
user: {from_secret: bintray_user}
key: {from_secret: bintray_key}
subject: thehive-project
package: catalogs
version: latest
override: 1
publish: 1
commands:
- |
export PLUGIN_USER
export PLUGIN_KEY
export PLUGIN_SUBJECT
export PLUGIN_PACKAGE
export PLUGIN_VERSION
export PLUGIN_OVERRIDE
export PLUGIN_PUBLISH
upload \
--file analyzers/analyzers-devel.json \
--repo cortexneurons
upload \
--file responders/responders-devel.json \
--repo cortexneurons
when:
branch: [develop]

- name: upload devel catalogs to package server
image: appleboy/drone-scp
settings:
Expand Down Expand Up @@ -212,8 +119,8 @@ steps:
settings:
worker_path: analyzers
namespace: cortexneurons
registry_dockerhub: {from_secret: docker_credentials}
registry_harbor: {from_secret: harbor_credentials}
registry_dockerhub: {from_secret: registry_dockerhub}
registry_harbor: {from_secret: registry_harbor}
stable: true
force: true
when:
Expand All @@ -224,8 +131,8 @@ steps:
settings:
worker_path: responders
namespace: cortexneurons
registry_dockerhub: {from_secret: docker_credentials}
registry_harbor: {from_secret: harbor_credentials}
registry_dockerhub: {from_secret: registry_dockerhub}
registry_harbor: {from_secret: registry_harbor}
stable: true
force: true
when:
Expand Down
31 changes: 31 additions & 0 deletions analyzers/CIRCLHashlookup/CIRCLHashlookup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "CIRCLHashlookup",
"author": "Mikael Keri",
"license": "AGPL-V3",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"version": "1.0",
"description": "CIRCL Hashlookup is a public service to lookup hash values against known database of good files",
"dataTypeList": ["hash"],
"baseConfig": "CIRCLHashlookup",
"config": {
"check_tlp": true,
"max_tlp": 2,
"check_pap": true,
"max_pap": 2
},
"command": "CIRCLHashlookup/circlhashlookup_analyzer.py",
"registration_required": false,
"subscription_required": false,
"free_subscription": true,
"service_homepage": "https://hashlookup.circl.lu/",
"service_logo": {"path":"assets/circlhashlookup_logo.png", "caption": "logo"},
"screenshots": [
{
"path": "assets/circlhashlookup_long_report.png",
"caption:":"CIRCL Hashlookup analyzer full report"
},
{
"path": "assets/circlhashlookup_verdict.png",
"caption:":"CIRCL Hashlookup analyzer verdict"
}]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions analyzers/CIRCLHashlookup/circlhashlookup_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
# encoding: utf-8

import requests
from cortexutils.analyzer import Analyzer

class CIRCLHashlookupAnalyzer(Analyzer):
def __init__(self):
Analyzer.__init__(self)
self.url = 'https://hashlookup.circl.lu'

def summary(self, raw):
taxonomies = []
namespace = "CIRCLHashlookup"

if raw.get('CRC32'):
verdict = "safe"
result = "known"
else:
verdict = "info"
result = "unkown"

taxonomies.append(self.build_taxonomy(
verdict,
namespace,
'Result',
result,
))

return {"taxonomies": taxonomies}

def run(self):
if self.data_type == 'hash':
data = self.get_param('data', None, 'Data is missing')

headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
session = requests.Session()
if len(data) == 32:
s = session.get(self.url + '/lookup/md5/' + data, headers=headers)
elif len(data) == 40:
s = session.get(self.url + '/lookup/sha1/' + data, headers=headers)
else:
self.error('Unsupported hash type')

s.close()
response = s.json()
try:
self.report(response)
except Exception as e:
self.error('Invalid data type')
else:
self.error('Invalid data type')

if __name__ == '__main__':
CIRCLHashlookupAnalyzer().run()
1 change: 1 addition & 0 deletions analyzers/CIRCLHashlookup/requirments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cortexutils
60 changes: 60 additions & 0 deletions thehive-templates/CIRCLHashlookup_1_0/long.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<div class="panel panel-danger" ng-if="!success">
<div class="panel-heading">
<strong>{{(artifact.data || artifact.attachment.name) | fang}}</strong>
</div>
<div class="panel-body">
{{content.errorMessage}}
</div>
</div>

<div class="panel panel-info" ng-if="success && content.message == null">
<div class="panel-heading">CIRCL Hashlookup results</div>
<dl class="dl-horizontal">
<dt>Hashes</dt>
<dd class="wrap">
<b>CRC32:</b> {{content.CRC32 || '-'}}<br />
<b>MD5:</b> {{content.MD5 || '-'}}<br />
<b>SHA1</b>: {{content['SHA-1'] || '-'}}<br />
</dd>
<dt>File</dt>
<dd class="wrap">
<b>Filename:</b> {{content.FileName || '-'}}<br />
<b>Filesize:</b> {{content.FileSize || '-'}}<br />
</dd>
<dt>OpSystemCode</dt>
<dd class="wrap">
<b>MfgCode:</b> {{content.OpSystemCode.MfgCode || '-'}}<br />
<b>OpSystemCode:</b> {{content.OpSystemCode.OpSystemCode || '-'}}<br />
<b>OpSystemName:</b> {{content.OpSystemCode.OpSystemName || '-'}}<br />
<b>OpSystemVersion:</b> {{content.OpSystemCode.OpSystemVersion || '-'}}<br />
</dd>
<dt>ProductCode</dt>
<dd class="wrap">
<b>ApplicationType:</b> {{content.ProductCode.ApplicationType || '-'}}<br />
<b>Language:</b> {{content.ProductCode.Language || '-'}}<br />
<b>MfgCode:</b> {{content.ProductCode.MfgCode || '-'}}<br />
<b>OpSystemCode:</b> {{content.ProductCode.OpSystemCode || '-'}}<br />
<b>ProductCode:</b> {{content.ProductCode.ProductCode || '-'}}<br />
<b>ProductName:</b> {{content.ProductCode.ProductName || '-'}}<br />
<b>ProductVersion:</b> {{content.ProductCode.ProductVersion || '-'}}<br />
<b>SpecialCode:</b> {{content.ProductCode.SpecialCode || '-'}}<br />
</dd>
</div>
<!-- No hits -->
<div class="panel panel-info" ng-if="success && content.message != null">
<div class="panel-heading">No hits</div>
<dd>{{content.message}}</dd>
</div>

<!-- General error -->
<div class="panel panel-danger" ng-if="!success">
<div class="panel-heading">
<strong>General Error: Please try again</strong>
</div>
<div class="panel-body">
<dl class="dl-horizontal" ng-if="content.errorMessage">
<dt><i class="fa fa-warning"></i>CIRCL Hashlookup: </dt>
<dd class="wrap">{{content.errorMessage}}"</dd>
</dl>
</div>
</div>
3 changes: 3 additions & 0 deletions thehive-templates/CIRCLHashlookup_1_0/short.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span class="label" ng-repeat="t in content.taxonomies" ng-class="{'info': 'label-info', 'safe': 'label-success', 'suspicious': 'label-warning', 'malicious':'label-danger'}[t.level]">
{{t.namespace}}:{{t.predicate}}="{{t.value}}"
</span>

0 comments on commit 2ea153a

Please sign in to comment.