from lib.ProgressBar import progressbar
from lib.Config import Configuration as conf
import lib.DatabaseLayer as db

i = db.getLastModified('user_misp')
now = datetime.utcnow().replace(tzinfo=pytz.utc)
if i:
    last = dateutil.parser.parse(i)
    delta = now - last
    since = "%sm" % math.ceil(delta.total_seconds() / 60)
else:
    since = ""

# Misp interface
misp_url, misp_key = conf.getMISPCredentials()
if not misp_url:
    print("MISP credentials not specified")
    sys.exit(1)
try:
    misp = PyMISP(misp_url, misp_key, True, 'json')
except:
    print("Failed to connect to MISP. Wrong URL?")
    sys.exit(1)

# Fetch data
misp_last = misp.download_last(since)

# Check data
if 'message' in misp_last.keys():
    if misp_last['message'] == 'No matches':
示例#2
0
from pymisp import PyMISP

from lib.ProgressBar import progressbar
from lib.Config import Configuration as conf
import lib.DatabaseLayer as db

i = db.getLastModified('user_misp')
now = datetime.utcnow().replace(tzinfo = pytz.utc)
if i: 
    last  = dateutil.parser.parse(i)
    delta = now - last
    since = "%sm"%math.ceil(delta.total_seconds()/60)
else: since=""

# Misp interface
misp_url, misp_key = conf.getMISPCredentials()
if not misp_url:
    print("MISP credentials not specified")
    sys.exit(1)
try:
    misp = PyMISP(misp_url, misp_key, True, 'json')
except:
    print("Failed to connect to MISP. Wrong URL?")
    sys.exit(1)

# Fetch data
misp_last = misp.download_last(since)

# Check data
if 'message' in misp_last.keys():
    if misp_last['message'] == 'No matches':