當前位置: 首頁>>代碼示例>>Python>>正文


Python pymisp.PyMISP方法代碼示例

本文整理匯總了Python中pymisp.PyMISP方法的典型用法代碼示例。如果您正苦於以下問題:Python pymisp.PyMISP方法的具體用法?Python pymisp.PyMISP怎麽用?Python pymisp.PyMISP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pymisp的用法示例。


在下文中一共展示了pymisp.PyMISP方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_misp_event

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def create_misp_event(event, distribution=0, threat_level_id=4, publish=False, analysis=0, event_info=None):
    if event_info:
        event.info = event_info
    event.distribution = sanitize_event_distribution(distribution)
    event.threat_level_id = sanitize_event_threat_level_id(threat_level_id)
    event.analysis = sanitize_event_analysis(analysis)
    if publish:
        event.publish()

    # # TODO: handle multiple MISP instance
    misp = PyMISP(misp_url, misp_key, misp_verifycert)
    #print(event.to_json())
    misp_event = misp.add_event(event)
     #print(misp_event)
    # # TODO: handle error
    event_metadata = extract_event_metadata(misp_event)
    return event_metadata 
開發者ID:CIRCL,項目名稱:AIL-framework,代碼行數:19,代碼來源:MispExport.py

示例2: submit_to_misp

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def submit_to_misp(hash_dict, tweet, tweet_url):
    misp = PyMISP(misp_url, misp_key, True, 'json')

    event_name = 'New tweet from ' + status.author.screen_name
    comment = tweet + '\t' + tweet_url

    for malware_hash in hash_dict:
        if event == 0:
            event = misp.new_event(0, 4, 0, event_name)
            eventid = event['Event']['id']

        hash_type = hash_dict[malware_hash]
        if hash_type == 'sha256':
            misp.add_hashes(event, sha256=malware_hash, comment=comment)
        elif hash_type == 'sha1':
            misp.add_hashes(event, sha1=malware_hash, comment=comment)
        elif hash_type == 'md5':
            misp.add_hashes(event, md5=malware_hash, comment=comment) 
開發者ID:ntddk,項目名稱:virustream,代碼行數:20,代碼來源:virustream.py

示例3: selftest_function

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def selftest_function(opts):
    """
    Placeholder for selftest function. An example use would be to test package api connectivity.
    Suggested return values are be unimplemented, success, or failure.
    """
    options = opts.get("fn_misp", {})

    verify_cert = True if options.get("verify_cert", "true").lower() == "true" else False

    try:
        misp_client = PyMISP(options.get("misp_url"), options.get("misp_key"), verify_cert, 'json')

        result = misp_client.search_all(None)
        return {"state": "success"}
    except Exception as err:
        print (err)
        return {"state": "failed",
                "reason": str(err)
               } 
開發者ID:ibmresilient,項目名稱:resilient-community-apps,代碼行數:21,代碼來源:selftest.py

示例4: ping_misp

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def ping_misp():
    try:
        PyMISP(misp_url, misp_key, misp_verifycert)
        return True
    except Exception as e:
        print(e)
        return False 
開發者ID:CIRCL,項目名稱:AIL-framework,代碼行數:9,代碼來源:MispExport.py

示例5: _misp_create_sighting_function

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def _misp_create_sighting_function(self, event, *args, **kwargs):
        """Function: """
        try:

            def get_config_option(option_name, optional=False):
                """Given option_name, checks if it is in app.config. Raises ValueError if a mandatory option is missing"""
                option = self.options.get(option_name)

                if option is None and optional is False:
                    err = "'{0}' is mandatory and is not set in ~/.resilient/app.config file. You must set this value to run this function".format(option_name)
                    raise ValueError(err)
                else:
                    return option

            API_KEY = get_config_option("misp_key")
            URL = get_config_option("misp_url")
            VERIFY_CERT = True if get_config_option("verify_cert").lower() == "true" else False

            # Get the function parameters:
            misp_sighting = kwargs.get("misp_sighting")  # text

            log = logging.getLogger(__name__)
            log.info("misp_sighting: %s", misp_sighting)

            misp_client = PyMISP(URL, API_KEY, VERIFY_CERT, 'json')

            sighting_json = {
                            "values":["{}".format(misp_sighting)], 
                            "timestamp": int(time.time())
                            }

            result = misp_client.set_sightings(sighting_json)

            results = { "success": True,
                        "content": result }

            # Produce a FunctionResult with the results
            yield FunctionResult(results)
        except Exception:
            yield FunctionError() 
開發者ID:ibmresilient,項目名稱:resilient-community-apps,代碼行數:42,代碼來源:misp_create_sighting.py

示例6: _misp_search_attribute_function

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def _misp_search_attribute_function(self, event, *args, **kwargs):
        """Function: Search to see if an attribute exists for a given artifact value"""
        try:

            def get_config_option(option_name, optional=False):
                """Given option_name, checks if it is in app.config. Raises ValueError if a mandatory option is missing"""
                option = self.options.get(option_name)

                if option is None and optional is False:
                    err = "'{0}' is mandatory and is not set in ~/.resilient/app.config file. You must set this value to run this function".format(option_name)
                    raise ValueError(err)
                else:
                    return option

            API_KEY = get_config_option("misp_key")
            URL = get_config_option("misp_url")
            VERIFY_CERT = True if get_config_option("verify_cert").lower() == "true" else False

            # Get the function parameters:
            search_attribute = kwargs.get("misp_attribute_value")  # text

            log = logging.getLogger(__name__)
            log.info("search_attribute: %s", search_attribute)

            misp_client = PyMISP(URL, API_KEY, VERIFY_CERT, 'json')

            result = misp_client.search('attributes', values=search_attribute)

            results = { "success": True,
                        "content": result }

            # Produce a FunctionResult with the results
            yield FunctionResult(results)
        except Exception:
            yield FunctionError() 
開發者ID:ibmresilient,項目名稱:resilient-community-apps,代碼行數:37,代碼來源:misp_search_attribute.py

示例7: _misp_sighting_list_function

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def _misp_sighting_list_function(self, event, *args, **kwargs):
        """Function: Return a list of sightings associated with a given event"""
        try:

            def get_config_option(option_name, optional=False):
                """Given option_name, checks if it is in app.config. Raises ValueError if a mandatory option is missing"""
                option = self.options.get(option_name)

                if option is None and optional is False:
                    err = "'{0}' is mandatory and is not set in ~/.resilient/app.config file. You must set this value to run this function".format(option_name)
                    raise ValueError(err)
                else:
                    return option

            API_KEY = get_config_option("misp_key")
            URL = get_config_option("misp_url")
            VERIFY_CERT = True if get_config_option("verify_cert").lower() == "true" else False

            # Get the function parameters:
            event_id = int(kwargs.get("misp_event_id"))  # text

            log = logging.getLogger(__name__)
            log.info("event_id: %s", event_id)

            misp_client = PyMISP(URL, API_KEY, VERIFY_CERT, 'json')

            result = misp_client.sighting_list(event_id, 'event')

            results = { "success": True,
                        "content": result }

            # Produce a FunctionResult with the results
            yield FunctionResult(results)
        except Exception:
            yield FunctionError() 
開發者ID:ibmresilient,項目名稱:resilient-community-apps,代碼行數:37,代碼來源:misp_sighting_list.py

示例8: run

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def run(self):
        super(MISP, self).run()
        if self.args is None:
            return

        if not HAVE_PYMISP:
            self.log('error', "Missing dependency, install requests (`pip install pymisp`)")
            return

        if self.args.url is None:
            self.url = MISP_URL
        else:
            self.url = self.args.url

        if self.args.key is None:
            self.key = MISP_KEY
        else:
            self.key = self.args.key

        if self.url is None:
            self.log('error', "This command requires the URL of the MISP instance you want to query.")
            return
        if self.key is None:
            self.log('error', "This command requires a MISP private API key.")
            return

        self.misp = PyMISP(self.url, self.key, True, 'json')

        if self.args.subname == 'upload':
            self.upload()
        elif self.args.subname == 'search':
            self.searchall()
        elif self.args.subname == 'download':
            self.download()
        elif self.args.subname == 'check_hashes':
            self.check_hashes()
        elif self.args.subname == 'yara':
            self.yara()
        elif self.args.subname == 'get_event':
            self.get_event()
        elif self.args.subname == 'create_event':
            self.create_event()
        elif self.args.subname == 'add':
            self.add()
        elif self.args.subname == 'show':
            self.show() 
開發者ID:opensourcesec,項目名稱:CIRTKit,代碼行數:48,代碼來源:misp.py

示例9: _misp_create_event_function

# 需要導入模塊: import pymisp [as 別名]
# 或者: from pymisp import PyMISP [as 別名]
def _misp_create_event_function(self, event, *args, **kwargs):
        """Function: create a MISP event from an incident """
        try:

            def get_config_option(option_name, optional=False):
                """Given option_name, checks if it is in app.config. Raises ValueError if a mandatory option is missing"""
                option = self.options.get(option_name)

                if option is None and optional is False:
                    err = "'{0}' is mandatory and is not set in ~/.resilient/app.config file. You must set this value to run this function".format(option_name)
                    raise ValueError(err)
                else:
                    return option

            API_KEY = get_config_option("misp_key")
            URL = get_config_option("misp_url")
            VERIFY_CERT = True if get_config_option("verify_cert").lower() == "true" else False

            # Get the function parameters:
            misp_event_name = kwargs.get("misp_event_name")  # text
            misp_distribution = kwargs.get("misp_distribution")  # number
            misp_analysis_level = kwargs.get("misp_analysis_level")  # number
            misp_threat_level = kwargs.get("misp_threat_level")  # number

            log = logging.getLogger(__name__)
            log.info("misp_event_name: %s", misp_event_name)
            log.info("misp_distribution: %s", misp_distribution)
            log.info("misp_analysis_level: %s", misp_analysis_level)
            log.info("misp_threat_level: %s", misp_threat_level)

            yield StatusMessage("Setting up connection to MISP")

            misp_client = PyMISP(URL, API_KEY, VERIFY_CERT, 'json')

            eventJson = {"Event": {"info": misp_event_name,
                    "analysis": misp_analysis_level,
                    "distribution": misp_distribution,
                    "threat_level_id": misp_threat_level}}

            event = misp_client.add_event(eventJson)

            log.info(event)

            yield StatusMessage("Event has been created")

            results = {
                "success": True,
                "content": event
            }

            # Produce a FunctionResult with the results
            yield FunctionResult(results)
        except Exception:
            yield FunctionError() 
開發者ID:ibmresilient,項目名稱:resilient-community-apps,代碼行數:56,代碼來源:misp_create_event.py


注:本文中的pymisp.PyMISP方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。