当前位置: 首页>>代码示例>>Python>>正文


Python PyMISP.add_object方法代码示例

本文整理汇总了Python中pymisp.PyMISP.add_object方法的典型用法代码示例。如果您正苦于以下问题:Python PyMISP.add_object方法的具体用法?Python PyMISP.add_object怎么用?Python PyMISP.add_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymisp.PyMISP的用法示例。


在下文中一共展示了PyMISP.add_object方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GenericObject

# 需要导入模块: from pymisp import PyMISP [as 别名]
# 或者: from pymisp.PyMISP import add_object [as 别名]
from keys import misp_url, misp_key, misp_verifycert
import argparse

class GenericObject(AbstractMISPObjectGenerator):
    def __init__(self, type, data_dict):
        super(GenericObject, self).__init__(type)
        self.__data = data_dict
        self.generate_attributes()

    def generate_attributes(self):
        for key, value in self.__data.items():
            self.add_attribute(key, value=value)

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Create a MISP Object selectable by type starting from a dictionary')
    parser.add_argument("-e", "--event", required=True, help="Event ID to update")
    parser.add_argument("-t", "--type", required=True, help="Type of the generic object")
    parser.add_argument("-d", "--dict", required=True, help="Dict ")
    args = parser.parse_args()

    pymisp = PyMISP(misp_url, misp_key, misp_verifycert)
    try:
        template_id = [x['ObjectTemplate']['id'] for x in pymisp.get_object_templates_list() if x['ObjectTemplate']['name'] == args.type][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" % (args.type, valid_types))
        exit()

    misp_object = GenericObject(args.type.replace("|", "-"), json.loads(args.dict))
    r = pymisp.add_object(args.event, template_id, misp_object)
开发者ID:sebdraven,项目名称:PyMISP,代码行数:32,代码来源:add_generic_object.py

示例2: process

# 需要导入模块: from pymisp import PyMISP [as 别名]
# 或者: from pymisp.PyMISP import add_object [as 别名]
# -*- coding: utf-8 -*-

from pymisp import PyMISP
from pymisp.tools import EMailObject
import traceback
from keys import misp_url, misp_key, misp_verifycert
import glob
import argparse


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Extract indicators out of binaries and add MISP objects to a MISP instance.')
    parser.add_argument("-e", "--event", required=True, help="Event ID to update.")
    parser.add_argument("-p", "--path", required=True, help="Path to process (expanded using glob).")
    args = parser.parse_args()

    pymisp = PyMISP(misp_url, misp_key, misp_verifycert, debug=True)

    for f in glob.glob(args.path):
        try:
            eo = EMailObject(f)
        except Exception as e:
            traceback.print_exc()
            continue

        if eo:
            template_id = pymisp.get_object_template_id(eo.template_uuid)
            response = pymisp.add_object(args.event, template_id, eo)
            for ref in eo.ObjectReference:
                r = pymisp.add_object_reference(ref)
开发者ID:3c7,项目名称:PyMISP,代码行数:32,代码来源:add_email_object.py

示例3: process

# 需要导入模块: from pymisp import PyMISP [as 别名]
# 或者: from pymisp.PyMISP import add_object [as 别名]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from pymisp import PyMISP
from pymisp.tools import SSHAuthorizedKeysObject
import traceback
from keys import misp_url, misp_key, misp_verifycert
import glob
import argparse


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Extract indicators out of authorized_keys file.')
    parser.add_argument("-e", "--event", required=True, help="Event ID to update.")
    parser.add_argument("-p", "--path", required=True, help="Path to process (expanded using glob).")
    args = parser.parse_args()

    pymisp = PyMISP(misp_url, misp_key, misp_verifycert, debug=True)

    for f in glob.glob(args.path):
        try:
            auth_keys = SSHAuthorizedKeysObject(f)
        except Exception:
            traceback.print_exc()
            continue

        template_id = pymisp.get_object_template_id(auth_keys.template_uuid)
        response = pymisp.add_object(args.event, template_id, auth_keys)
        for ref in auth_keys.ObjectReference:
            r = pymisp.add_object_reference(ref)
开发者ID:MISP,项目名称:PyMISP,代码行数:32,代码来源:add_ssh_authorized_keys.py

示例4: int

# 需要导入模块: from pymisp import PyMISP [as 别名]
# 或者: from pymisp.PyMISP import add_object [as 别名]
                nb_attr = response['response'][0]['attribute_count']
                if last_event_date < date.today() or int(nb_attr) > 1000:
                    me = create_new_event()
                else:
                    event_id = response['response'][0]['id']
        else:
            me = create_new_event()

    parameters = {'banned-ip': args.banned_ip, 'attack-type': args.attack_type}
    if args.processing_timestamp:
        parameters['processing-timestamp'] = args.processing_timestamp
    if args.failures:
        parameters['failures'] = args.failures
    if args.sensor:
        parameters['sensor'] = args.sensor
    if args.victim:
        parameters['victim'] = args.victim
    if args.logline:
        parameters['logline'] = b64decode(args.logline).decode()
    if args.logfile:
        with open(args.logfile, 'rb') as f:
            parameters['logfile'] = {'value': os.path.basename(args.logfile),
                                     'data': BytesIO(f.read())}
    f2b = Fail2BanObject(parameters=parameters, standalone=False)
    if me:
        me.add_object(f2b)
        pymisp.add_event(me)
    elif event_id:
        template_id = pymisp.get_object_template_id(f2b.template_uuid)
        a = pymisp.add_object(event_id, template_id, f2b)
开发者ID:3c7,项目名称:PyMISP,代码行数:32,代码来源:add_fail2ban_object.py

示例5: PyMISP

# 需要导入模块: from pymisp import PyMISP [as 别名]
# 或者: from pymisp.PyMISP import add_object [as 别名]
import json
from pymisp import PyMISP
from keys import misp_url, misp_key, misp_verifycert
from pymisp.tools import SBSignatureObject

pymisp = PyMISP(misp_url, misp_key, misp_verifycert)
a = json.loads('{"signatures":[{"new_data":[],"confidence":100,"families":[],"severity":1,"weight":0,"description":"AttemptstoconnecttoadeadIP:Port(2uniquetimes)","alert":false,"references":[],"data":[{"IP":"95.101.39.58:80(Europe)"},{"IP":"192.35.177.64:80(UnitedStates)"}],"name":"dead_connect"},{"new_data":[],"confidence":30,"families":[],"severity":2,"weight":1,"description":"PerformssomeHTTPrequests","alert":false,"references":[],"data":[{"url":"http://cert.int-x3.letsencrypt.org/"},{"url":"http://apps.identrust.com/roots/dstrootcax3.p7c"}],"name":"network_http"},{"new_data":[],"confidence":100,"families":[],"severity":2,"weight":1,"description":"Theofficefilehasaunconventionalcodepage:ANSICyrillic;Cyrillic(Windows)","alert":false,"references":[],"data":[],"name":"office_code_page"}]}')
a = [(x['name'], x['description']) for x in a["signatures"]]


b = SBSignatureObject(a)


template_id = [x['ObjectTemplate']['id'] for x in pymisp.get_object_templates_list() if x['ObjectTemplate']['name'] == 'sb-signature'][0]

pymisp.add_object(234111, template_id, b)
开发者ID:3c7,项目名称:PyMISP,代码行数:18,代码来源:add_sbsignature.py

示例6: process

# 需要导入模块: from pymisp import PyMISP [as 别名]
# 或者: from pymisp.PyMISP import add_object [as 别名]
    parser = argparse.ArgumentParser(description='Extract indicators out of binaries and add MISP objects to a MISP instance.')
    parser.add_argument("-e", "--event", required=True, help="Event ID to update.")
    parser.add_argument("-p", "--path", required=True, help="Path to process (expanded using glob).")
    args = parser.parse_args()

    pymisp = PyMISP(misp_url, misp_key, misp_verifycert)

    for f in glob.glob(args.path):
        try:
            fo, peo, seos = make_binary_objects(f)
        except Exception as e:
            traceback.print_exc()
            continue

        if seos:
            for s in seos:
                template_id = pymisp.get_object_template_id(s.template_uuid)
                r = pymisp.add_object(args.event, template_id, s)

        if peo:
            template_id = pymisp.get_object_template_id(peo.template_uuid)
            r = pymisp.add_object(args.event, template_id, peo)
            for ref in peo.ObjectReference:
                r = pymisp.add_object_reference(ref)

        if fo:
            template_id = pymisp.get_object_template_id(fo.template_uuid)
            response = pymisp.add_object(args.event, template_id, fo)
            for ref in fo.ObjectReference:
                r = pymisp.add_object_reference(ref)
开发者ID:3c7,项目名称:PyMISP,代码行数:32,代码来源:add_file_object.py


注:本文中的pymisp.PyMISP.add_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。