Merge branch 'master' of github.com:MISP/misp-modules

pull/163/head
chrisr3d 2018-02-13 11:58:56 +01:00
commit b7098d1cff
4 changed files with 41 additions and 1 deletions

View File

@ -40,6 +40,7 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/
* [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)
* [wikidata](misp_modules/modules/expansion/wiki.py) - a [wikidata](https://www.wikidata.org) expansion module.
* [xforce](misp_modules/modules/expansion/xforceexchange.py) - an IBM X-Force Exchange expansion module.
* [YARA syntax validator](misp_modules/modules/expansion/yara_syntax_validator.py) - YARA syntax validator.
### Export modules

View File

@ -21,3 +21,4 @@ domaintools_api
pygeoip
bs4
oauth2
yara

View File

@ -3,4 +3,4 @@ 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']
'threatcrowd', 'vulndb', 'crowdstrike_falcon','yara_syntax_validator']

View File

@ -0,0 +1,38 @@
import json
import requests
try:
import yara
except:
print("yara is missing, use 'pip3 install yara' to install it.")
misperrors = {'error': 'Error'}
mispattributes = {'input': ['yara'], 'output': ['text']}
moduleinfo = {'version': '0.1', 'author': 'Dennis Rand', 'description': 'An expansion hover module to perform a syntax check on if yara rules are valid or not.', 'module-type': ['hover']}
moduleconfig = []
def handler(q=False):
if q is False:
return False
request = json.loads(q)
if not request.get('yara'):
misperrors['error'] = 'Yara rule missing'
return misperrors
try:
rules = yara.compile(source=request.get('yara'))
summary = ("Syntax valid")
except Exception as e:
summary = ("Syntax error: " + str(e))
r = {'results': [{'types': mispattributes['output'], 'values': summary}]}
return r
def introspection():
return mispattributes
def version():
moduleinfo['config'] = moduleconfig
return moduleinfo