mirror of https://github.com/MISP/misp-modules
Merge pull request #206 from chrisr3d/master
Expansion module displaying SIEM signatures from a sigma rulepull/209/head
commit
ef665d318c
|
@ -38,6 +38,7 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/
|
||||||
* [rbl](misp_modules/modules/expansion/rbl.py) - a module to get RBL (Real-Time Blackhost List) values from an attribute.
|
* [rbl](misp_modules/modules/expansion/rbl.py) - a module to get RBL (Real-Time Blackhost List) values from an attribute.
|
||||||
* [reversedns](misp_modules/modules/expansion/reversedns.py) - Simple Reverse DNS expansion service to resolve reverse DNS from MISP attributes.
|
* [reversedns](misp_modules/modules/expansion/reversedns.py) - Simple Reverse DNS expansion service to resolve reverse DNS from MISP attributes.
|
||||||
* [shodan](misp_modules/modules/expansion/shodan.py) - a minimal [shodan](https://www.shodan.io/) expansion module.
|
* [shodan](misp_modules/modules/expansion/shodan.py) - a minimal [shodan](https://www.shodan.io/) expansion module.
|
||||||
|
* [Sigma queries](misp_modules/modules/expansion/sigma_queries.py) - Experimental expansion module querying a sigma rule to convert it into all the available SIEM signatures.
|
||||||
* [Sigma syntax validator](misp_modules/modules/expansion/sigma_syntax_validator.py) - Sigma syntax validator.
|
* [Sigma syntax validator](misp_modules/modules/expansion/sigma_syntax_validator.py) - Sigma syntax validator.
|
||||||
* [sourcecache](misp_modules/modules/expansion/sourcecache.py) - a module to cache a specific link from a MISP instance.
|
* [sourcecache](misp_modules/modules/expansion/sourcecache.py) - a module to cache a specific link from a MISP instance.
|
||||||
* [STIX2 pattern syntax validator](misp_modules/modules/expansion/stix2_pattern_syntax_validator.py) - a module to check a STIX2 pattern syntax.
|
* [STIX2 pattern syntax validator](misp_modules/modules/expansion/stix2_pattern_syntax_validator.py) - a module to check a STIX2 pattern syntax.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
from . import _vmray
|
from . import _vmray
|
||||||
|
|
||||||
__all__ = ['vmray_submit', 'asn_history', 'circl_passivedns', 'circl_passivessl', 'countrycode', 'cve', 'dns', 'domaintools', 'eupi', 'farsight_passivedns', 'ipasn', 'passivetotal', 'sourcecache', 'virustotal', 'whois', 'shodan', 'reversedns', 'geoip_country', 'wiki', 'iprep', 'threatminer', 'otx', 'threatcrowd', 'vulndb', 'crowdstrike_falcon', 'yara_syntax_validator', 'hashdd', 'onyphe', 'onyphe_full', 'rbl', 'xforceexchange', 'sigma_syntax_validator', 'stix2_pattern_syntax_validator']
|
__all__ = ['vmray_submit', 'asn_history', 'circl_passivedns', 'circl_passivessl', 'countrycode', 'cve', 'dns', 'domaintools', 'eupi', 'farsight_passivedns', 'ipasn', 'passivetotal', 'sourcecache', 'virustotal', 'whois', 'shodan', 'reversedns', 'geoip_country', 'wiki', 'iprep', 'threatminer', 'otx', 'threatcrowd', 'vulndb', 'crowdstrike_falcon', 'yara_syntax_validator', 'hashdd', 'onyphe', 'onyphe_full', 'rbl', 'xforceexchange', 'sigma_syntax_validator', 'stix2_pattern_syntax_validator', 'sigma_queries']
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import sys, os, io, json
|
||||||
|
try:
|
||||||
|
from sigma.parser import SigmaCollectionParser
|
||||||
|
from sigma.config import SigmaConfiguration
|
||||||
|
from sigma.backends import getBackend, BackendOptions
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
print("sigma or yaml is missing, use 'pip3 install sigmatools' to install it.")
|
||||||
|
|
||||||
|
misperrors = {'error': 'Error'}
|
||||||
|
mispattributes = {'input': ['sigma'], 'output': ['text']}
|
||||||
|
moduleinfo = {'version': '0.1', 'author': 'Christian Studer', 'module-type': ['expansion', 'hover'],
|
||||||
|
'description': 'An expansion hover module to display the result of sigma queries.'}
|
||||||
|
moduleconfig = []
|
||||||
|
sigma_targets = ('es-dsl', 'es-qs', 'graylog', 'kibana', 'xpack-watcher', 'logpoint', 'splunk', 'grep', 'wdatp', 'splunkxml', 'arcsight', 'qualys')
|
||||||
|
|
||||||
|
def handler(q=False):
|
||||||
|
if q is False:
|
||||||
|
return False
|
||||||
|
request = json.loads(q)
|
||||||
|
if not request.get('sigma'):
|
||||||
|
misperrors['error'] = 'Sigma rule missing'
|
||||||
|
return misperrors
|
||||||
|
config = SigmaConfiguration()
|
||||||
|
backend_options = BackendOptions(None)
|
||||||
|
f = io.TextIOWrapper(io.BytesIO(request.get('sigma').encode()), encoding='utf-8')
|
||||||
|
parser = SigmaCollectionParser(f, config, None)
|
||||||
|
targets = []
|
||||||
|
old_stdout = sys.stdout
|
||||||
|
result = io.StringIO()
|
||||||
|
sys.stdout = result
|
||||||
|
for t in sigma_targets:
|
||||||
|
backend = getBackend(t)(config, backend_options, None)
|
||||||
|
try:
|
||||||
|
parser.generate(backend)
|
||||||
|
backend.finalize()
|
||||||
|
print("#NEXT")
|
||||||
|
targets.append(t)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
sys.stdout = old_stdout
|
||||||
|
results = result.getvalue()[:-5].split('#NEXT')
|
||||||
|
d_result = {t: r.strip() for t,r in zip(targets, results)}
|
||||||
|
return {'results': [{'types': mispattributes['output'], 'values': d_result}]}
|
||||||
|
|
||||||
|
def introspection():
|
||||||
|
return mispattributes
|
||||||
|
|
||||||
|
def version():
|
||||||
|
moduleinfo['config'] = moduleconfig
|
||||||
|
return moduleinfo
|
Loading…
Reference in New Issue