Skip to content

Commit d7fac00

Browse files
author
sebdraven
authored
Merge branch 'master' into dnstrails
2 parents 804e59e + ef665d3 commit d7fac00

File tree

12 files changed

+165
-14
lines changed

12 files changed

+165
-14
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ services:
66
cache: pip
77

88
python:
9-
- "3.4"
109
- "3.5"
1110
- "3.5-dev"
1211
- "3.6"
1312
- "3.6-dev"
13+
- "3.7-dev"
1414

1515
install:
1616
- pip install -U nose codecov pytest

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/
3838
* [rbl](misp_modules/modules/expansion/rbl.py) - a module to get RBL (Real-Time Blackhost List) values from an attribute.
3939
* [reversedns](misp_modules/modules/expansion/reversedns.py) - Simple Reverse DNS expansion service to resolve reverse DNS from MISP attributes.
4040
* [shodan](misp_modules/modules/expansion/shodan.py) - a minimal [shodan](https://www.shodan.io/) expansion module.
41+
* [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.
4142
* [Sigma syntax validator](misp_modules/modules/expansion/sigma_syntax_validator.py) - Sigma syntax validator.
4243
* [sourcecache](misp_modules/modules/expansion/sourcecache.py) - a module to cache a specific link from a MISP instance.
44+
* [STIX2 pattern syntax validator](misp_modules/modules/expansion/stix2_pattern_syntax_validator.py) - a module to check a STIX2 pattern syntax.
4345
* [ThreatCrowd](misp_modules/modules/expansion/threatcrowd.py) - an expansion module for [ThreatCrowd](https://www.threatcrowd.org/).
4446
* [threatminer](misp_modules/modules/expansion/threatminer.py) - an expansion module to expand from [ThreatMiner](https://www.threatminer.org/).
4547
* [virustotal](misp_modules/modules/expansion/virustotal.py) - an expansion module to pull known resolutions and malware samples related with an IP/Domain from virusTotal (this modules require a VirusTotal private API key)
@@ -380,7 +382,7 @@ Recommended Plugin.Import_ocr_enabled true Enable or disable the ocr
380382
In this same menu set any other plugin settings that are required for testing.
381383

382384
## Install misp-module on an offline instance.
383-
First, you need to grab all necessery packages for example like this :
385+
First, you need to grab all necessary packages for example like this :
384386

385387
Use pip wheel to create an archive
386388
~~~

REQUIREMENTS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ git+https://github.com/sebdraven/pyonyphe#egg=pyonyphe
1515
git+https://github.com/sebdraven/pydnstrails#egg=pydnstrails
1616
pillow
1717
pytesseract
18+
wand
1819
SPARQLWrapper
1920
domaintools_api
2021
pygeoip
2122
bs4
2223
oauth2
2324
yara
2425
sigmatools
26+
stix2-patterns

misp_modules/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def post(self):
193193
if dict_payload.get('timeout'):
194194
timeout = datetime.timedelta(seconds=int(dict_payload.get('timeout')))
195195
else:
196-
timeout = datetime.timedelta(seconds=30)
196+
timeout = datetime.timedelta(seconds=300)
197197
response = yield tornado.gen.with_timeout(timeout, self.run_request(jsonpayload))
198198
self.write(response)
199199
except tornado.gen.TimeoutError:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from . import _vmray
22

3-
__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']
3+
__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']
File renamed without changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import sys, os, io, json
2+
try:
3+
from sigma.parser import SigmaCollectionParser
4+
from sigma.config import SigmaConfiguration
5+
from sigma.backends import getBackend, BackendOptions
6+
except ModuleNotFoundError:
7+
print("sigma or yaml is missing, use 'pip3 install sigmatools' to install it.")
8+
9+
misperrors = {'error': 'Error'}
10+
mispattributes = {'input': ['sigma'], 'output': ['text']}
11+
moduleinfo = {'version': '0.1', 'author': 'Christian Studer', 'module-type': ['expansion', 'hover'],
12+
'description': 'An expansion hover module to display the result of sigma queries.'}
13+
moduleconfig = []
14+
sigma_targets = ('es-dsl', 'es-qs', 'graylog', 'kibana', 'xpack-watcher', 'logpoint', 'splunk', 'grep', 'wdatp', 'splunkxml', 'arcsight', 'qualys')
15+
16+
def handler(q=False):
17+
if q is False:
18+
return False
19+
request = json.loads(q)
20+
if not request.get('sigma'):
21+
misperrors['error'] = 'Sigma rule missing'
22+
return misperrors
23+
config = SigmaConfiguration()
24+
backend_options = BackendOptions(None)
25+
f = io.TextIOWrapper(io.BytesIO(request.get('sigma').encode()), encoding='utf-8')
26+
parser = SigmaCollectionParser(f, config, None)
27+
targets = []
28+
old_stdout = sys.stdout
29+
result = io.StringIO()
30+
sys.stdout = result
31+
for t in sigma_targets:
32+
backend = getBackend(t)(config, backend_options, None)
33+
try:
34+
parser.generate(backend)
35+
backend.finalize()
36+
print("#NEXT")
37+
targets.append(t)
38+
except:
39+
continue
40+
sys.stdout = old_stdout
41+
results = result.getvalue()[:-5].split('#NEXT')
42+
d_result = {t: r.strip() for t,r in zip(targets, results)}
43+
return {'results': [{'types': mispattributes['output'], 'values': d_result}]}
44+
45+
def introspection():
46+
return mispattributes
47+
48+
def version():
49+
moduleinfo['config'] = moduleconfig
50+
return moduleinfo
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import json
2+
try:
3+
from stix2patterns.validator import run_validator
4+
except ModuleNotFoundError:
5+
print("stix2 patterns python library is missing, use 'pip3 install stix2-patterns' to install it.")
6+
7+
misperrors = {'error': 'Error'}
8+
mispattributes = {'input': ['stix2-pattern'], 'output': ['text']}
9+
moduleinfo = {'version': '0.1', 'author': 'Christian Studer', 'module-type': ['expansion', 'hover'],
10+
'description': 'An expansion hover module to perform a syntax check on stix2 patterns.'}
11+
moduleconfig = []
12+
13+
def handler(q=False):
14+
if q is False:
15+
return False
16+
request = json.loads(q)
17+
if not request.get('stix2-pattern'):
18+
misperrors['error'] = 'STIX2 pattern missing'
19+
return misperrors
20+
pattern = request.get('stix2-pattern')
21+
syntax_errors = []
22+
for p in pattern[2:-2].split(' AND '):
23+
syntax_validator = run_validator("[{}]".format(p))
24+
if syntax_validator:
25+
for error in syntax_validator:
26+
syntax_errors.append(error)
27+
if syntax_errors:
28+
s = 's' if len(syntax_errors) > 1 else ''
29+
s_errors = ""
30+
for error in syntax_errors:
31+
s_errors += "{}\n".format(error[6:])
32+
result = "Syntax error{}: \n{}".format(s, s_errors[:-1])
33+
else:
34+
result = "Syntax valid"
35+
return {'results': [{'types': mispattributes['output'], 'values': result}]}
36+
37+
def introspection():
38+
return mispattributes
39+
40+
def version():
41+
moduleinfo['config'] = moduleconfig
42+
return moduleinfo
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__all__ = ['testexport','cef_export','liteexport','goamlexport','threat_connect_export','pdfexport','threatStream_misp_export']
1+
__all__ = ['cef_export','liteexport','goamlexport','threat_connect_export','pdfexport','threatStream_misp_export']
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from . import _vmray
22

3-
__all__ = ['vmray_import', 'testimport', 'ocr', 'cuckooimport', 'goamlimport', 'email_import', 'mispjson', 'openiocimport', 'threatanalyzer_import', 'csvimport']
3+
__all__ = ['vmray_import', 'ocr', 'cuckooimport', 'goamlimport', 'email_import', 'mispjson', 'openiocimport', 'threatanalyzer_import', 'csvimport']

0 commit comments

Comments
 (0)