From 6f0227a78a971ea5576fc1278743a2a7e532c5d2 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 20 Nov 2017 12:12:06 +0100 Subject: [PATCH] Starting support of python3 --- bin/ailleakOject.py | 16 ++-------------- bin/packages/Date.py | 8 ++++---- bin/packages/Paste.py | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/bin/ailleakOject.py b/bin/ailleakOject.py index d8475779..8459a126 100755 --- a/bin/ailleakOject.py +++ b/bin/ailleakOject.py @@ -33,21 +33,9 @@ if __name__ == "__main__": from pymisp import PyMISP pymisp = PyMISP(misp_url, misp_key, misp_verifycert) - eventID = "9356" - mispTYPE = 'ail-leak' moduleName = "Credentials" path = "/home/sami/git/AIL-framework/PASTES/archive/pastebin.com_pro/2017/08/23/bPFaJymf.gz" - misp_object = AilleakObject(moduleName, path) - print('validate mispobj', misp_object._validate()) - print(misp_object) - - # Publish object to MISP - try: - templateID = [x['ObjectTemplate']['id'] for x in pymisp.get_object_templates_list() if x['ObjectTemplate']['name'] == mispTYPE][0] - except IndexError: - valid_types = ", ".join([x['ObjectTemplate']['name'] for x in pymisp.get_object_templates_list()]) - print ("Template for type %s not found! Valid types are: %s" % (mispTYPE, valid_types)) - print(templateID) - #r = pymisp.add_object(eventID, templateID, misp_object) + wrapper = objectWrapper(moduleName, path, pymisp) + wrapper.pushToMISP() diff --git a/bin/packages/Date.py b/bin/packages/Date.py index ce02636a..85da5b36 100644 --- a/bin/packages/Date.py +++ b/bin/packages/Date.py @@ -32,10 +32,10 @@ class Date(object): self.day = day def substract_day(self, numDay): - import datetime - computed_date = datetime.date(int(self.year), int(self.month), int(self.day)) - datetime.timedelta(numDay) - comp_year = str(computed_date.year) + import datetime + computed_date = datetime.date(int(self.year), int(self.month), int(self.day)) - datetime.timedelta(numDay) + comp_year = str(computed_date.year) comp_month = str(computed_date.month).zfill(2) comp_day = str(computed_date.day).zfill(2) - return comp_year + comp_month + comp_day + return comp_year + comp_month + comp_day diff --git a/bin/packages/Paste.py b/bin/packages/Paste.py index 6d18e846..1debd33e 100755 --- a/bin/packages/Paste.py +++ b/bin/packages/Paste.py @@ -24,8 +24,17 @@ import operator import string import re import json -import ConfigParser -import cStringIO +try: # dirty to support python3 + import ConfigParser +except: + import configparser + ConfigParser = configparser +try: # dirty to support python3 + import cStringIO +except: + from io import StringIO as cStringIO +import sys +sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/')) from Date import Date from Hash import Hash @@ -84,6 +93,7 @@ class Paste(object): var = self.p_path.split('/') self.p_date = Date(var[-4], var[-3], var[-2]) self.p_source = var[-5] + self.supposed_url = 'https://{}/{}'.format(self.p_source.replace('_pro', ''), var[-1].split('.gz')[0]) self.p_encoding = None self.p_hash_kind = {}