示例#1
0
 def test_mobile_latest(self):
     """Test most recent mobile to excel spreadsheet functionality"""
     if os.path.isdir('test_attacktoexcel_exports_mobile'):
         shutil.rmtree('test_attacktoexcel_exports_mobile')
     try:
         attackToExcel.export(domain='mobile-attack', outputDir='test_attacktoexcel_exports_mobile')
         shutil.rmtree('test_attacktoexcel_exports_mobile')
     except requests.exceptions.SSLError:
         print('UNABLE TO RUN TEST DUE TO CERT ISSUE.')
示例#2
0
    def test_enterprise_legacy(self):
        """Test enterprise v9.0 to excel spreadsheet functionality"""
        if os.path.isdir('test_attacktoexcel_exports_enterprise'):
            shutil.rmtree('test_attacktoexcel_exports_enterprise')

        try:
            attackToExcel.export(domain='enterprise-attack', version='9.0',
                                 outputDir='test_attacktoexcel_exports_enterprise')
            shutil.rmtree('test_attacktoexcel_exports_enterprise')
        except requests.exceptions.SSLError:
            print('UNABLE TO RUN TEST DUE TO CERT ISSUE.')
示例#3
0
def generate_working_with_attack():
    """ Responsible for generating working with ATT&CK and creating excel files
    """

    excel_dirs = [
        f"enterprise-attack-{site_config.full_attack_version}",
        f"mobile-attack-{site_config.full_attack_version}",
        f"ics-attack-{site_config.full_attack_version}"
    ]
    files_types = [
        "matrices", "mitigations", "relationships", "software", "groups",
        "tactics", "techniques"
    ]

    # Verify if directories exists
    if not os.path.isdir(site_config.web_directory):
        os.makedirs(site_config.web_directory)

    docs_dir = os.path.join(site_config.web_directory, 'docs')
    if not os.path.isdir(docs_dir):
        os.makedirs(docs_dir)

    attackToExcel.export("enterprise-attack", site_config.full_attack_version,
                         docs_dir)
    attackToExcel.export("mobile-attack", site_config.full_attack_version,
                         docs_dir)
    attackToExcel.export("ics-attack", site_config.full_attack_version,
                         docs_dir)

    files_json = {'excel_files': []}
    for excel_dir in excel_dirs:
        excel_json = {
            'label': f"{excel_dir}.xlsx",
            'url': f"/docs/{excel_dir}/{excel_dir}.xlsx",
            'children': []
        }
        for file_type in files_types:
            child_json = {
                'label': f"{excel_dir}-{file_type}.xlsx",
                'url': f"/docs/{excel_dir}/{excel_dir}-{file_type}.xlsx"
            }
            excel_json['children'].append(child_json)
        files_json['excel_files'].append(excel_json)

    working_with_attack_content = resources_config.working_with_attack_md + json.dumps(
        files_json)
    # write markdown to file
    with open(os.path.join(site_config.resources_markdown_path,
                           "working_with_attack.md"),
              "w",
              encoding='utf8') as md_file:
        md_file.write(working_with_attack_content)