new: [passivedns, passivessl] Add support for ip-src|port and ip-dst|port

pull/406/head
Jakub Onderka 2020-06-03 11:12:47 +02:00
parent b65237a0cb
commit 31d15056f9
2 changed files with 12 additions and 8 deletions

View File

@ -2,7 +2,7 @@ import json
import pypdns
from pymisp import MISPAttribute, MISPEvent, MISPObject
mispattributes = {'input': ['hostname', 'domain', 'ip-src', 'ip-dst'], 'format': 'misp_standard'}
mispattributes = {'input': ['hostname', 'domain', 'ip-src', 'ip-dst', 'ip-src|port', 'ip-dst|port'], 'format': 'misp_standard'}
moduleinfo = {'version': '0.2', 'author': 'Alexandre Dulaunoy',
'description': 'Module to access CIRCL Passive DNS',
'module-type': ['expansion', 'hover']}
@ -24,9 +24,11 @@ class PassiveDNSParser():
results = {key: event[key] for key in ('Attribute', 'Object')}
return {'results': results}
def parse(self, value):
def parse(self):
value = self.attribute.value.split('|')[0] if '|' in self.attribute.type else self.attribute.value
try:
results = self.pdns.query(self.attribute.value)
results = self.pdns.query(value)
except Exception:
self.result = {'error': 'There is an authentication error, please make sure you supply correct credentials.'}
return
@ -57,7 +59,7 @@ def handler(q=False):
if not any(input_type == attribute['type'] for input_type in mispattributes['input']):
return {'error': 'Unsupported attributes type'}
pdns_parser = PassiveDNSParser(attribute, authentication)
pdns_parser.parse(attribute['value'])
pdns_parser.parse()
return pdns_parser.get_results()

View File

@ -2,7 +2,7 @@ import json
import pypssl
from pymisp import MISPAttribute, MISPEvent, MISPObject
mispattributes = {'input': ['ip-src', 'ip-dst'], 'format': 'misp_standard'}
mispattributes = {'input': ['ip-src', 'ip-dst', 'ip-src|port', 'ip-dst|port'], 'format': 'misp_standard'}
moduleinfo = {'version': '0.2', 'author': 'Raphaël Vinot',
'description': 'Module to access CIRCL Passive SSL',
'module-type': ['expansion', 'hover']}
@ -31,9 +31,11 @@ class PassiveSSLParser():
results = {key: event[key] for key in ('Attribute', 'Object')}
return {'results': results}
def parse(self, value):
def parse(self):
value = self.attribute.value.split('|')[0] if '|' in self.attribute.type else self.attribute.value
try:
results = self.pssl.query(self.attribute.value)
results = self.pssl.query(value)
except Exception:
self.result = {'error': 'There is an authentication error, please make sure you supply correct credentials.'}
return
@ -78,7 +80,7 @@ def handler(q=False):
if not any(input_type == attribute['type'] for input_type in mispattributes['input']):
return {'error': 'Unsupported attributes type'}
pssl_parser = PassiveSSLParser(attribute, authentication)
pssl_parser.parse(attribute['value'])
pssl_parser.parse()
return pssl_parser.get_results()