def BundleManage(mode):
    if (mode == "import"):
        if not (isProjectActive()):
            tk.messagebox.showwarning("Error", "You are not into a project. Please Load or Create a project in order to import the Bundle Objects into it otherwise you could use the extract function.")
            return
    bundle=tk.filedialog.askopenfilename(initialdir="/", title="Please select a STIX2 Bundle file.",
                                          filetypes=[("json files (STIX2)", "*.json")])
    if bundle:
        try:
            stix2bundle = stix2.parse(filetoitem(bundle))
            type = stix2bundle.get("type")
            if not (type=="bundle"):
                tk.messagebox.showwarning("Error", "Selected STIX2 object is not a Bundle.")
                return
            else:
                if (mode=="import"):
                    for o in stix2bundle.get("objects"):
                        itemtofile(o)
                    tk.messagebox.showinfo("Success", "Selected Bundle was successfully imported into current project.")
                else:#mode=="extract"
                    dest = tk.filedialog.askdirectory(initialdir="/",
                                                      title="Please select a folder to extract the Bundle to.")
                    if dest:
                        backupcwd = os.getcwd()
                        InitNewEnvironment(dest)
                        for o in stix2bundle.get("objects"):
                            itemtofile(o)
                        os.chdir(backupcwd)
                        tk.messagebox.showinfo("Success", "Selected Bundle was successfully extracted to the selected directory.")
        except:
            tk.messagebox.showwarning("Error", "This does not seem to be a valid STIX2 object. Import failed.")
示例#2
0
def relationship_maker(source, type, target):
    relationship = stix2.Relationship(source, type, target)
    itemtofile(relationship)
    return relationship
示例#3
0
def vulnerability_maker(**kwargs):
    vulnerability = stix2.Vulnerability(**kwargs)
    flag = itemtofile(vulnerability)
    return flag, vulnerability
示例#4
0
def tool_maker(**kwargs):
    tool = stix2.Tool(**kwargs)
    flag = itemtofile(tool)
    return flag, tool
示例#5
0
def threat_actor_maker(**kwargs):
    threat_actor = stix2.ThreatActor(**kwargs)
    flag = itemtofile(threat_actor)
    return flag, threat_actor
示例#6
0
def report_maker(**kwargs):
    report = stix2.Report(**kwargs)
    flag = itemtofile(report)
    return flag, report
示例#7
0
def observed_data_maker(**kwargs):
    observed_data = stix2.ObservedData(**kwargs)
    flag = itemtofile(observed_data)
    return flag, observed_data
示例#8
0
def malware_maker(**kwargs):
    malware = stix2.Malware(**kwargs)
    flag = itemtofile(malware)
    return flag, malware
示例#9
0
def intrusion_set_maker(**kwargs):
    intrusion_set = stix2.IntrusionSet(**kwargs)
    flag = itemtofile(intrusion_set)
    return flag, intrusion_set
示例#10
0
def indicator_maker(**kwargs):
    indicator = stix2.Indicator(**kwargs)
    flag = itemtofile(indicator)
    return flag, indicator
示例#11
0
def identity_maker(**kwargs):
    identity = stix2.Identity(**kwargs)
    flag = itemtofile(identity)
    return flag, identity
示例#12
0
def course_of_action_maker(**kwargs):
    coa = stix2.CourseOfAction(**kwargs)
    flag = itemtofile(coa)
    return flag, coa
示例#13
0
def campaign_maker(**kwargs):
    campaign = stix2.Campaign(**kwargs)
    flag = itemtofile(campaign)
    return flag, campaign
示例#14
0
def attack_pattern_maker(**kwargs):
    attack_pattern = stix2.AttackPattern(**kwargs)
    flag = itemtofile(attack_pattern)
    return flag, attack_pattern
示例#15
0
def sighting_maker(**kwargs):
    sighting = stix2.Sighting(**kwargs)
    flag = itemtofile(sighting)
    return flag, sighting
示例#16
0
def marking_definition_maker(**kwargs):
    marking_definition = stix2.MarkingDefinition(**kwargs)
    flag = itemtofile(marking_definition)
    return flag, marking_definition