【ATTCK】开源项目-mitreattack-python

2023-11-08 18:52

本文主要是介绍【ATTCK】开源项目-mitreattack-python,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

        mitreattack-python是用来处理ATT&CK数据的python开源工具。

        开源地址:GitHub - mitre-attack/mitreattack-python: A python module for working with ATT&CK

安装

pip3 install mitreattack-python #使用清华源pip3 install mitreattack-python  -i https://pypi.tuna.tsinghua.edu.cn/simple/

使用教程

1、下载attck json数据文件

https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json

https://raw.githubusercontent.com/mitre/cti/master/mobile-attack/mobile-attack.json

https://raw.githubusercontent.com/mitre/cti/master/ics-attack/ics-attack.json

2、将下载的文件复制到当前工作目录

        不然会报文件不存在的错误,或指定文件目录。

>>> mitre_attack_data = MitreAttackData("enterprise-attack.json")Traceback (most recent call last):File "<stdin>", line 1, in <module>File "C:\Users\xxxxxx\.conda\envs\attck\lib\site-packages\mitreattack\stix20\MitreAttackData.py", line 85, in __init__self.src.load_from_file(stix_filepath)File "C:\Users\xxxxxx\.conda\envs\attck\lib\site-packages\stix2\datastore\memory.py", line 148, in load_from_filereturn self.source.load_from_file(*args, **kwargs)File "C:\Users\xxxxxx\.conda\envs\attck\lib\site-packages\stix2\datastore\memory.py", line 363, in load_from_filewith io.open(os.path.abspath(file_path), "r", encoding=encoding) as f:FileNotFoundError: [Errno 2] No such file or directory: 'D:\\opt\\attck\\enterprise-attack.json'

3、加载数据文件

(attck) D:\opt\attck>pythonPython 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:01:37) [MSC v.1935 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> from mitreattack.stix20 import MitreAttackData>>> mitre_attack_data = MitreAttackData("enterprise-attack.json")4、常见用法

4、使用案例

get_object_by_stix_id

>>> G0075 = mitre_attack_data.get_object_by_stix_id("intrusion-set--f40eb8ce-2a74-4e56-89a1-227021410142")>>> print(G0075.serialize(pretty=True)){"type": "intrusion-set","id": "intrusion-set--f40eb8ce-2a74-4e56-89a1-227021410142","created_by_ref": "identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5","created": "2018-10-17T00:14:20.652Z","modified": "2020-03-30T19:15:49.217Z","name": "Rancor","description": "[Rancor](https://attack.mitre.org/groups/G0075) is a threat group that has led targeted campaigns against the South East Asia region. [Rancor](https://attack.mitre.org/groups/G0075) uses politically-motivated lures to entice victims to open malicious documents. (Citation: Rancor Unit42 June 2018)","aliases": ["Rancor"],"external_references": [{"source_name": "mitre-attack","url": "https://attack.mitre.org/groups/G0075","external_id": "G0075"},{"source_name": "Rancor","description": "(Citation: Rancor Unit42 June 2018)"},{"source_name": "Rancor Unit42 June 2018","description": "Ash, B., et al. (2018, June 26). RANCOR: Targeted Attacks in South East Asia Using PLAINTEE and DDKONG Malware Families. Retrieved July 2, 2018.","url": "https://researchcenter.paloaltonetworks.com/2018/06/unit42-rancor-targeted-attacks-south-east-asia-using-plaintee-ddkong-malware-families/"}],"object_marking_refs": ["marking-definition--fa42a846-8d90-4e51-bc29-71d5b4802168"],"x_mitre_domains": ["enterprise-attack"],"x_mitre_modified_by_ref": "identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5","x_mitre_version": "1.2"}>>>

get_object_by_attack_id

>>> T1134 = mitre_attack_data.get_object_by_attack_id("T1134", "attack-pattern")>>> mitre_attack_data.print_stix_object(T1134, pretty=True){"type": "attack-pattern","id": "attack-pattern--dcaa092b-7de9-4a21-977f-7fcb77e89c48","created_by_ref": "identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5","created": "2017-12-14T16:46:06.044Z","modified": "2023-03-30T21:01:47.762Z","name": "Access Token Manipulation","description": "Adversaries may modify access tokens to operate under a different user or system security context to perform actions and bypass access controls. Windows uses access tokens to determine the ownership of a running process. A user can manipulate access tokens to make a running process appear as though it is the child of a different process or belongs to someone other than the user that started the process. When this occurs, the process also takes on the security context associated with the new token.\n\nAn adversary can use built-in Windows API functions to copy access tokens from existing processes; this is known as token stealing. These token can then be applied to an existing process (i.e. [Token Impersonation/Theft](https://attack.mitre.org/techniques/T1134/001)) or used to spawn a new process (i.e. [Create Process with Token](https://attack.mitre.org/techniques/T1134/002)). An adversary must already be in a privileged user context (i.e. administrator) to steal a token. However, adversaries commonly use token stealing to elevate their security context from the administrator level to the SYSTEM level. An adversary can then use a token to authenticate to a remote system as the account for that token if the account has appropriate permissions on the remote system.(Citation: Pentestlab Token Manipulation)\n\nAny standard user can use the <code>runas</code> command, and the Windows API functions, to create impersonation tokens; it does not require access to an administrator account. There are also other mechanisms, such as Active Directory fields, that can be used to modify access tokens.","kill_chain_phases": [{"kill_chain_name": "mitre-attack","phase_name": "defense-evasion"},{"kill_chain_name": "mitre-attack","phase_name": "privilege-escalation"}],"external_references": [{"source_name": "mitre-attack","url": "https://attack.mitre.org/techniques/T1134","external_id": "T1134"},{"source_name": "BlackHat Atkinson Winchester Token Manipulation","description": "Atkinson, J., Winchester, R. (2017, December 7). A Process is No One: Hunting for Token Manipulation. Retrieved December 21, 2017.","url": "https://www.blackhat.com/docs/eu-17/materials/eu-17-Atkinson-A-Process-Is-No-One-Hunting-For-Token-Manipulation.pdf"},{"source_name": "Microsoft Command-line Logging","description": "Mathers, B. (2017, March 7). Command line process auditing. Retrieved April 21, 2017.","url": "https://technet.microsoft.com/en-us/windows-server-docs/identity/ad-ds/manage/component-updates/command-line-process-auditing"},{"source_name": "Microsoft LogonUser","description": "Microsoft TechNet. (n.d.). Retrieved April 25, 2017.","url": "https://msdn.microsoft.com/en-us/library/windows/desktop/aa378184(v=vs.85).aspx"},{"source_name": "Microsoft DuplicateTokenEx","description": "Microsoft TechNet. (n.d.). Retrieved April 25, 2017.","url": "https://msdn.microsoft.com/en-us/library/windows/desktop/aa446617(v=vs.85).aspx"},{"source_name": "Microsoft ImpersonateLoggedOnUser","description": "Microsoft TechNet. (n.d.). Retrieved April 25, 2017.","url": "https://msdn.microsoft.com/en-us/library/windows/desktop/aa378612(v=vs.85).aspx"},{"source_name": "Pentestlab Token Manipulation","description": "netbiosX. (2017, April 3). Token Manipulation. Retrieved April 21, 2017.","url": "https://pentestlab.blog/2017/04/03/token-manipulation/"}],"object_marking_refs": ["marking-definition--fa42a846-8d90-4e51-bc29-71d5b4802168"],"x_mitre_attack_spec_version": "2.1.0","x_mitre_contributors": ["Tom Ueltschi @c_APT_ure","Travis Smith, Tripwire","Robby Winchester, @robwinchester3","Jared Atkinson, @jaredcatkinson"],"x_mitre_data_sources": ["Process: OS API Execution","Command: Command Execution","User Account: User Account Metadata","Process: Process Metadata","Process: Process Creation","Active Directory: Active Directory Object Modification"],"x_mitre_defense_bypassed": ["Windows User Account Control","Heuristic Detection","System Access Controls","Host Forensic Analysis"],"x_mitre_deprecated": false,"x_mitre_detection": "If an adversary is using a standard command-line shell, analysts can detect token manipulation by auditing command-line activity. Specifically, analysts should look for use of the <code>runas</code> command. Detailed command-line logging is not enabled by default in Windows.(Citation: Microsoft Command-line Logging)\n\nIf an adversary is using a payload that calls the Windows token APIs directly, analysts can detect token manipulation only through careful analysis of user network activity, examination of running processes, and correlation with other endpoint and network behavior. \n\nThere are many Windows API calls a payload can take advantage of to manipulate access tokens (e.g., <code>LogonUser</code> (Citation: Microsoft LogonUser), <code>DuplicateTokenEx</code>(Citation: Microsoft DuplicateTokenEx), and <code>ImpersonateLoggedOnUser</code>(Citation: Microsoft ImpersonateLoggedOnUser)). Please see the referenced Windows API pages for more information.\n\nQuery systems for process and thread token information and look for inconsistencies such as user owns processes impersonating the local SYSTEM account.(Citation: BlackHat Atkinson Winchester Token Manipulation)\n\nLook for inconsistencies between the various fields that store PPID information, such as the EventHeader ProcessId from data collected via Event Tracing for Windows (ETW), Creator Process ID/Name from Windows event logs, and the ProcessID and ParentProcessID (which are also produced from ETW and other utilities such as Task Manager and Process Explorer). The ETW provided EventHeader ProcessId identifies the actual parent process.","x_mitre_domains": ["enterprise-attack"],"x_mitre_effective_permissions": ["SYSTEM"],"x_mitre_is_subtechnique": false,"x_mitre_modified_by_ref": "identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5","x_mitre_permissions_required": ["User","Administrator"],"x_mitre_platforms": ["Windows"],"x_mitre_version": "2.0"}

get_software_used_by_group

 

 # get software used by G0019>>> group_stix_id = "intrusion-set--2a158b0a-7ef8-43cb-9985-bf34d1e12050">>> software_used_by_g0019 = mitre_attack_data.get_software_used_by_group(group_stix_id)>>> print(f"Software used by G0019 ({len(software_used_by_g0019)}):")Software used by G0019 (15):>>> for s in software_used_by_g0019:...         software = s["object"]...         print(f"* {software.name} ({mitre_attack_data.get_attack_id(software.id)})")...* ftp (S0095)* Net (S0039)* Ping (S0097)* netsh (S0108)* Systeminfo (S0096)* PsExec (S0029)* Tasklist (S0057)* WinMM (S0059)* RainyDay (S0629)* Nebulae (S0630)* RARSTONE (S0055)* HDoor (S0061)* Sys10 (S0060)* SslMM (S0058)* Aria-body (S0456)>>>

这篇关于【ATTCK】开源项目-mitreattack-python的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/371830

相关文章

一文教你Python如何快速精准抓取网页数据

《一文教你Python如何快速精准抓取网页数据》这篇文章主要为大家详细介绍了如何利用Python实现快速精准抓取网页数据,文中的示例代码简洁易懂,具有一定的借鉴价值,有需要的小伙伴可以了解下... 目录1. 准备工作2. 基础爬虫实现3. 高级功能扩展3.1 抓取文章详情3.2 保存数据到文件4. 完整示例

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

基于Python打造一个智能单词管理神器

《基于Python打造一个智能单词管理神器》这篇文章主要为大家详细介绍了如何使用Python打造一个智能单词管理神器,从查询到导出的一站式解决,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. 项目概述:为什么需要这个工具2. 环境搭建与快速入门2.1 环境要求2.2 首次运行配置3. 核心功能使用指

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

利用Python打造一个Excel记账模板

《利用Python打造一个Excel记账模板》这篇文章主要为大家详细介绍了如何使用Python打造一个超实用的Excel记账模板,可以帮助大家高效管理财务,迈向财富自由之路,感兴趣的小伙伴快跟随小编一... 目录设置预算百分比超支标红预警记账模板功能介绍基础记账预算管理可视化分析摸鱼时间理财法碎片时间利用财

Python中的Walrus运算符分析示例详解

《Python中的Walrus运算符分析示例详解》Python中的Walrus运算符(:=)是Python3.8引入的一个新特性,允许在表达式中同时赋值和返回值,它的核心作用是减少重复计算,提升代码简... 目录1. 在循环中避免重复计算2. 在条件判断中同时赋值变量3. 在列表推导式或字典推导式中简化逻辑

python处理带有时区的日期和时间数据

《python处理带有时区的日期和时间数据》这篇文章主要为大家详细介绍了如何在Python中使用pytz库处理时区信息,包括获取当前UTC时间,转换为特定时区等,有需要的小伙伴可以参考一下... 目录时区基本信息python datetime使用timezonepandas处理时区数据知识延展时区基本信息

Python位移操作和位运算的实现示例

《Python位移操作和位运算的实现示例》本文主要介绍了Python位移操作和位运算的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 位移操作1.1 左移操作 (<<)1.2 右移操作 (>>)注意事项:2. 位运算2.1

使用Python和Pyecharts创建交互式地图

《使用Python和Pyecharts创建交互式地图》在数据可视化领域,创建交互式地图是一种强大的方式,可以使受众能够以引人入胜且信息丰富的方式探索地理数据,下面我们看看如何使用Python和Pyec... 目录简介Pyecharts 简介创建上海地图代码说明运行结果总结简介在数据可视化领域,创建交互式地