mirror of
https://github.com/DISARMFoundation/DISARMframeworks.git
synced 2024-12-26 15:59:52 -05:00
c11e9d06ad
Added framework objects: - Added technique T0066 "Degrade adversary" to TA02 - Added technique T0067 "Plan to discredit credible sources" to TA02 - Added technique T0068 "respond to breaking news event" to TA02 - Added technique T0069 "respond to active crisis" to TA02 - Added technique T0070 "Analyze existing communities" to TA02 - Added technique T0071 "Find echo chambers" to TA13 - Added technique T0072 "Segment audiences" to TA13 Added STIX generator from repo DISARM-stix2, and added code to generate github files, databases, and STIX from the same Jupyter notebook.
83 lines
1.4 KiB
Python
83 lines
1.4 KiB
Python
import json
|
|
import os
|
|
from stix2 import Bundle
|
|
import shutil
|
|
|
|
outdir = '../generated_files/DISARM_STIX/'
|
|
|
|
def write_disarm_dir(dir, outdir=outdir):
|
|
"""
|
|
|
|
Args:
|
|
dir (str): a directory name
|
|
|
|
Returns:
|
|
|
|
"""
|
|
try:
|
|
os.mkdir(outdir)
|
|
except FileExistsError:
|
|
pass
|
|
|
|
try:
|
|
os.mkdir(outdir + dir)
|
|
except FileExistsError:
|
|
pass
|
|
|
|
|
|
def clean_output_dir(outdir=outdir):
|
|
"""Recursively delete the output folder.
|
|
|
|
Returns:
|
|
|
|
"""
|
|
try:
|
|
os.mkdir(outdir)
|
|
except FileExistsError:
|
|
pass
|
|
|
|
shutil.rmtree(outdir)
|
|
|
|
|
|
def write_file(file_name, file_data):
|
|
"""Write a JSON file to outdir
|
|
|
|
Args:
|
|
file_name (str): a file name
|
|
file_data (str): the file json data
|
|
|
|
Returns:
|
|
|
|
"""
|
|
with open(file_name, 'w') as f:
|
|
# f.write(json.dumps(file_data, sort_keys=True, indent=4))
|
|
f.write(file_data.serialize(pretty=True))
|
|
f.write('\n')
|
|
|
|
|
|
def write_files(stix_objects, outdir=outdir):
|
|
"""
|
|
|
|
Args:
|
|
stix_objects:
|
|
|
|
Returns:
|
|
|
|
"""
|
|
for i in stix_objects:
|
|
write_disarm_dir(i.type)
|
|
write_file(outdir+f"{i.type}/{i.id}.json", Bundle(i, allow_custom=True))
|
|
|
|
|
|
def write_bundle(bundle, bundle_name, outdir=outdir):
|
|
"""
|
|
|
|
Args:
|
|
bundle:
|
|
bundle_name:
|
|
|
|
Returns:
|
|
|
|
"""
|
|
write_file(outdir+f"{bundle_name}.json", bundle)
|