def test_convert(): # This is a public MISP instance. # Just running on AWS, nothing particularly interesting. mispAPI = misp.MISP("http://35.163.95.230", "pF4Rq3JOHbYAJLMiFDqRPpLxAh3s0PakiSPKWSN5") test_files = glob.glob("test_files/*.xml") for test_file in test_files: with open(test_file, "r") as f: convert.STIXtoMISP(f.read(), mispAPI.mispAPI)
def test_convert(): # This is a public MISP instance. # Just running on AWS, nothing particularly interesting. mispAPI = misp.MISP( "http://ec2-52-42-201-6.us-west-2.compute.amazonaws.com", "Vjy0ra7wO6w6si7hbjxX52nARfVpaAO6Tm6lxeSm") test_files = glob.glob("test_files/*.xml") for test_file in test_files: print(test_file) with open(test_file, "r") as f: convert.STIXtoMISP(f.read(), mispAPI.mispAPI)
from misp_stix_converter.converters.buildMISPAttribute import open_stix parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument("-c", "--config", help="Path to config file. Default is misp.login.") parser.add_argument("file", help="The STIX file to push") args = parser.parse_args() # Set the config file if args.config: configfile = args.config else: configfile = os.path.expanduser("~/.misptostix/misp.login") try: with open(configfile, "r") as f: CONFIG = pyaml.yaml.load(f) except FileNotFoundError: print("Could not find config file {}".format(configfile)) sys.exit(1) # This is just a file conversion # Relatively quick and easy MISP = misp.MISP(CONFIG["MISP"]["URL"], CONFIG["MISP"]["KEY"]) # Load the package pkg = open_stix(args.file) # We'll use my nice little misp module MISP.push(pkg)
package = convert.MISPtoSTIX(jsondata) except FileNotFoundError: print("Could not open {}".format(args.file)) sys.exit() else: # Backwards compatability, if users haven't updated config if "SSL" not in CONFIG["MISP"]: print("Please update your config file using the misp.login.example to include SSL\n") time.sleep(1) CONFIG["MISP"]["SSL"] = False # This requires a connection to MISP # As we need to pull an event # Connect to MISP MISP = misp.MISP(CONFIG["MISP"]["URL"], CONFIG["MISP"]["KEY"], CONFIG["MISP"].get("SSL", True)) if args.tag: log.debug("Converting all events tagged with %s", args.tag) package = MISP.pull(tags=[args.tag]) else: log.debug("Converting event %s", args.eid) package = MISP.pull(args.eid)[0] def write_pkg(pkg, outfile): # Set the version log.debug("Writing to %s", outfile) log.debug("As stix v%s", args.stix_version) if args.stix_version: