mirror of https://github.com/MISP/misp-modules
Modules for expansion services, import and export in MISP
http://misp.github.io/misp-modules
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1017 B
38 lines
1017 B
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
|
|
|