mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-21 08:23:08 +01:00
threatfox dep upgrade + use auth for api access
This commit is contained in:
@@ -51,6 +51,8 @@ sensoroni:
|
|||||||
live_flow: False
|
live_flow: False
|
||||||
mailbox_email_address:
|
mailbox_email_address:
|
||||||
message_source_id:
|
message_source_id:
|
||||||
|
threatfox:
|
||||||
|
api_key:
|
||||||
urlscan:
|
urlscan:
|
||||||
base_url: https://urlscan.io/api/v1/
|
base_url: https://urlscan.io/api/v1/
|
||||||
api_key:
|
api_key:
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Threatfox",
|
"name": "Threatfox",
|
||||||
"version": "0.1",
|
"version": "0.2",
|
||||||
"author": "Security Onion Solutions",
|
"author": "Security Onion Solutions",
|
||||||
"description": "This analyzer queries Threatfox to see if a domain, hash, or IP is considered malicious.",
|
"description": "This analyzer queries Threatfox to see if a domain, hash, or IP is considered malicious.",
|
||||||
"supportedTypes" : ["domain","hash","ip"],
|
"supportedTypes" : ["domain","hash","ip"],
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import requests
|
|||||||
import helpers
|
import helpers
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def buildReq(observ_type, observ_value):
|
def buildReq(observ_type, observ_value):
|
||||||
@@ -13,10 +15,20 @@ def buildReq(observ_type, observ_value):
|
|||||||
return qterms
|
return qterms
|
||||||
|
|
||||||
|
|
||||||
def sendReq(meta, query):
|
def checkConfigRequirements(conf):
|
||||||
|
if not conf.get('api_key'):
|
||||||
|
sys.exit(126)
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def sendReq(conf, meta, query):
|
||||||
# send a post request based off of our compiled query
|
# send a post request based off of our compiled query
|
||||||
url = meta['baseUrl']
|
url = meta['baseUrl']
|
||||||
response = requests.post(url, json.dumps(query))
|
headers = {}
|
||||||
|
if conf.get('api_key'):
|
||||||
|
headers['Auth-Key'] = conf['api_key']
|
||||||
|
response = requests.post(url, json.dumps(query), headers=headers)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
@@ -51,23 +63,30 @@ def prepareResults(raw):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def analyze(input):
|
def analyze(conf, input):
|
||||||
# put all of our methods together, pass them input, and return
|
# put all of our methods together, pass them input, and return
|
||||||
# properly formatted json/python dict output
|
# properly formatted json/python dict output
|
||||||
data = json.loads(input)
|
checkConfigRequirements(conf)
|
||||||
meta = helpers.loadMetadata(__file__)
|
meta = helpers.loadMetadata(__file__)
|
||||||
|
data = helpers.parseArtifact(input)
|
||||||
helpers.checkSupportedType(meta, data["artifactType"])
|
helpers.checkSupportedType(meta, data["artifactType"])
|
||||||
query = buildReq(data['artifactType'], data['value'])
|
query = buildReq(data['artifactType'], data['value'])
|
||||||
response = sendReq(meta, query)
|
response = sendReq(conf, meta, query)
|
||||||
return prepareResults(response)
|
return prepareResults(response)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) == 2:
|
dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
results = analyze(sys.argv[1])
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Search ThreatFox for a given artifact')
|
||||||
|
parser.add_argument(
|
||||||
|
'artifact', help='the artifact represented in JSON format')
|
||||||
|
parser.add_argument('-c', '--config', metavar='CONFIG_FILE', default=dir + '/threatfox.yaml',
|
||||||
|
help='optional config file to use instead of the default config file')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.artifact:
|
||||||
|
results = analyze(helpers.loadConfig(args.config), args.artifact)
|
||||||
print(json.dumps(results))
|
print(json.dumps(results))
|
||||||
else:
|
|
||||||
print("ERROR: Input is not in proper JSON format")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
1
salt/sensoroni/files/analyzers/threatfox/threatfox.yaml
Normal file
1
salt/sensoroni/files/analyzers/threatfox/threatfox.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
api_key: "{{ salt['pillar.get']('sensoroni:analyzers:threatfox:api_key', '') }}"
|
||||||
@@ -263,6 +263,14 @@ sensoroni:
|
|||||||
sensitive: False
|
sensitive: False
|
||||||
advanced: True
|
advanced: True
|
||||||
forcedType: string
|
forcedType: string
|
||||||
|
threatfox:
|
||||||
|
api_key:
|
||||||
|
description: API key for the threatfox analyzer.
|
||||||
|
helpLink: sensoroni.html
|
||||||
|
global: False
|
||||||
|
sensitive: True
|
||||||
|
advanced: False
|
||||||
|
forcedType: string
|
||||||
urlscan:
|
urlscan:
|
||||||
api_key:
|
api_key:
|
||||||
description: API key for the Urlscan analyzer.
|
description: API key for the Urlscan analyzer.
|
||||||
|
|||||||
Reference in New Issue
Block a user