{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Export All Techniques to YAML\n", "------------------" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Import ATTACK API Client" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from attackcti import attack_client" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Import Extra Libraries" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import logging\n", "logging.getLogger('taxii2client').setLevel(logging.CRITICAL)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Initialize ATT&CK Client Variable" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "lift = attack_client()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Get Enterprise Techniques" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "795" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "enterprise_techniques = lift.get_techniques()\n", "len(enterprise_techniques)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\"type\": \"attack-pattern\", \"id\": \"attack-pattern--90c4a591-d02d-490b-92aa-619d9701ac04\", \"created_by_ref\": \"identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5\", \"created\": \"2023-03-30T22:45:00.431Z\", \"modified\": \"2023-05-04T18:02:51.318Z\", \"name\": \"Network Provider DLL\", \"description\": \"Adversaries may register malicious network provider dynamic link libraries (DLLs) to capture cleartext user credentials during the authentication process. Network provider DLLs allow Windows to interface with specific network protocols and can also support add-on credential management functions.(Citation: Network Provider API) During the logon process, Winlogon (the interactive logon module) sends credentials to the local `mpnotify.exe` process via RPC. The `mpnotify.exe` process then shares the credentials in cleartext with registered credential managers when notifying that a logon event is happening.(Citation: NPPSPY - Huntress)(Citation: NPPSPY Video)(Citation: NPLogonNotify) \\n\\nAdversaries can configure a malicious network provider DLL to receive credentials from `mpnotify.exe`.(Citation: NPPSPY) Once installed as a credential manager (via the Registry), a malicious DLL can receive and save credentials each time a user logs onto a Windows workstation or domain via the `NPLogonNotify()` function.(Citation: NPLogonNotify)\\n\\nAdversaries may target planting malicious network provider DLLs on systems known to have increased logon activity and/or administrator logon activity, such as servers and domain controllers.(Citation: NPPSPY - Huntress)\", \"kill_chain_phases\": [{\"kill_chain_name\": \"mitre-attack\", \"phase_name\": \"credential-access\"}, {\"kill_chain_name\": \"mitre-attack\", \"phase_name\": \"defense-evasion\"}, {\"kill_chain_name\": \"mitre-attack\", \"phase_name\": \"persistence\"}], \"external_references\": [{\"source_name\": \"mitre-attack\", \"url\": \"https://attack.mitre.org/techniques/T1556/008\", \"external_id\": \"T1556.008\"}, {\"source_name\": \"NPPSPY - Huntress\", \"description\": \" Dray Agha. (2022, August 16). Cleartext Shenanigans: Gifting User Passwords to Adversaries With NPPSPY. Retrieved March 30, 2023.\", \"url\": \"https://www.huntress.com/blog/cleartext-shenanigans-gifting-user-passwords-to-adversaries-with-nppspy\"}, {\"source_name\": \"NPPSPY Video\", \"description\": \"Grzegorz Tworek. (2021, December 14). How winlogon.exe shares the cleartext password with custom DLLs. Retrieved March 30, 2023.\", \"url\": \"https://www.youtube.com/watch?v=ggY3srD9dYs\"}, {\"source_name\": \"NPPSPY\", \"description\": \"Grzegorz Tworek. (2021, December 15). NPPSpy. Retrieved March 30, 2023.\", \"url\": \"https://github.com/gtworek/PSBits/tree/master/PasswordStealing/NPPSpy\"}, {\"source_name\": \"Network Provider API\", \"description\": \"Microsoft. (2021, January 7). Network Provider API. Retrieved March 30, 2023.\", \"url\": \"https://learn.microsoft.com/en-us/windows/win32/secauthn/network-provider-api\"}, {\"source_name\": \"NPLogonNotify\", \"description\": \"Microsoft. (2021, October 21). NPLogonNotify function (npapi.h). Retrieved March 30, 2023.\", \"url\": \"https://learn.microsoft.com/en-us/windows/win32/api/npapi/nf-npapi-nplogonnotify\"}], \"object_marking_refs\": [\"marking-definition--fa42a846-8d90-4e51-bc29-71d5b4802168\"], \"x_mitre_attack_spec_version\": \"3.1.0\", \"x_mitre_contributors\": [\"CrowdStrike Falcon OverWatch\", \"Jai Minton\"], \"x_mitre_data_sources\": [\"Windows Registry: Windows Registry Key Modification\", \"File: File Creation\", \"Process: OS API Execution\", \"Windows Registry: Windows Registry Key Creation\"], \"x_mitre_deprecated\": false, \"x_mitre_detection\": \"\", \"x_mitre_domains\": [\"enterprise-attack\"], \"x_mitre_is_subtechnique\": true, \"x_mitre_modified_by_ref\": \"identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5\", \"x_mitre_platforms\": [\"Windows\"], \"x_mitre_version\": \"1.0\"}\n" ] } ], "source": [ "print(enterprise_techniques[0])" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "techniques_one = enterprise_techniques[0]" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "import json\n", "technique_dict = json.loads(techniques_one.serialize())" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'type': 'attack-pattern',\n", " 'id': 'attack-pattern--90c4a591-d02d-490b-92aa-619d9701ac04',\n", " 'created_by_ref': 'identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5',\n", " 'created': '2023-03-30T22:45:00.431Z',\n", " 'modified': '2023-05-04T18:02:51.318Z',\n", " 'name': 'Network Provider DLL',\n", " 'description': 'Adversaries may register malicious network provider dynamic link libraries (DLLs) to capture cleartext user credentials during the authentication process. Network provider DLLs allow Windows to interface with specific network protocols and can also support add-on credential management functions.(Citation: Network Provider API) During the logon process, Winlogon (the interactive logon module) sends credentials to the local `mpnotify.exe` process via RPC. The `mpnotify.exe` process then shares the credentials in cleartext with registered credential managers when notifying that a logon event is happening.(Citation: NPPSPY - Huntress)(Citation: NPPSPY Video)(Citation: NPLogonNotify) \\n\\nAdversaries can configure a malicious network provider DLL to receive credentials from `mpnotify.exe`.(Citation: NPPSPY) Once installed as a credential manager (via the Registry), a malicious DLL can receive and save credentials each time a user logs onto a Windows workstation or domain via the `NPLogonNotify()` function.(Citation: NPLogonNotify)\\n\\nAdversaries may target planting malicious network provider DLLs on systems known to have increased logon activity and/or administrator logon activity, such as servers and domain controllers.(Citation: NPPSPY - Huntress)',\n", " 'kill_chain_phases': [{'kill_chain_name': 'mitre-attack',\n", " 'phase_name': 'credential-access'},\n", " {'kill_chain_name': 'mitre-attack', 'phase_name': 'defense-evasion'},\n", " {'kill_chain_name': 'mitre-attack', 'phase_name': 'persistence'}],\n", " 'external_references': [{'source_name': 'mitre-attack',\n", " 'url': 'https://attack.mitre.org/techniques/T1556/008',\n", " 'external_id': 'T1556.008'},\n", " {'source_name': 'NPPSPY - Huntress',\n", " 'description': ' Dray Agha. (2022, August 16). Cleartext Shenanigans: Gifting User Passwords to Adversaries With NPPSPY. Retrieved March 30, 2023.',\n", " 'url': 'https://www.huntress.com/blog/cleartext-shenanigans-gifting-user-passwords-to-adversaries-with-nppspy'},\n", " {'source_name': 'NPPSPY Video',\n", " 'description': 'Grzegorz Tworek. (2021, December 14). How winlogon.exe shares the cleartext password with custom DLLs. Retrieved March 30, 2023.',\n", " 'url': 'https://www.youtube.com/watch?v=ggY3srD9dYs'},\n", " {'source_name': 'NPPSPY',\n", " 'description': 'Grzegorz Tworek. (2021, December 15). NPPSpy. Retrieved March 30, 2023.',\n", " 'url': 'https://github.com/gtworek/PSBits/tree/master/PasswordStealing/NPPSpy'},\n", " {'source_name': 'Network Provider API',\n", " 'description': 'Microsoft. (2021, January 7). Network Provider API. Retrieved March 30, 2023.',\n", " 'url': 'https://learn.microsoft.com/en-us/windows/win32/secauthn/network-provider-api'},\n", " {'source_name': 'NPLogonNotify',\n", " 'description': 'Microsoft. (2021, October 21). NPLogonNotify function (npapi.h). Retrieved March 30, 2023.',\n", " 'url': 'https://learn.microsoft.com/en-us/windows/win32/api/npapi/nf-npapi-nplogonnotify'}],\n", " 'object_marking_refs': ['marking-definition--fa42a846-8d90-4e51-bc29-71d5b4802168'],\n", " 'x_mitre_attack_spec_version': '3.1.0',\n", " 'x_mitre_contributors': ['CrowdStrike Falcon OverWatch', 'Jai Minton'],\n", " 'x_mitre_data_sources': ['Windows Registry: Windows Registry Key Modification',\n", " 'File: File Creation',\n", " 'Process: OS API Execution',\n", " 'Windows Registry: Windows Registry Key Creation'],\n", " 'x_mitre_deprecated': False,\n", " 'x_mitre_detection': '',\n", " 'x_mitre_domains': ['enterprise-attack'],\n", " 'x_mitre_is_subtechnique': True,\n", " 'x_mitre_modified_by_ref': 'identity--c78cb6e5-0c4b-4611-8297-d1b8b55e40b5',\n", " 'x_mitre_platforms': ['Windows'],\n", " 'x_mitre_version': '1.0'}" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "technique_dict" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "new_techniques = list()" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "for t in enterprise_techniques:\n", " td = json.loads(t.serialize())\n", " new_dict = dict()\n", " new_dict['name'] = td['name']\n", " new_dict['description'] = td['description']\n", " new_dict['tactics'] = list()\n", " for kc in td['kill_chain_phases']:\n", " new_dict['tactics'].append(kc['phase_name'])\n", " new_dict['technique_id'] = td['external_references'][0]['external_id']\n", " new_techniques.append(new_dict)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'name': 'Network Provider DLL',\n", " 'description': 'Adversaries may register malicious network provider dynamic link libraries (DLLs) to capture cleartext user credentials during the authentication process. Network provider DLLs allow Windows to interface with specific network protocols and can also support add-on credential management functions.(Citation: Network Provider API) During the logon process, Winlogon (the interactive logon module) sends credentials to the local `mpnotify.exe` process via RPC. The `mpnotify.exe` process then shares the credentials in cleartext with registered credential managers when notifying that a logon event is happening.(Citation: NPPSPY - Huntress)(Citation: NPPSPY Video)(Citation: NPLogonNotify) \\n\\nAdversaries can configure a malicious network provider DLL to receive credentials from `mpnotify.exe`.(Citation: NPPSPY) Once installed as a credential manager (via the Registry), a malicious DLL can receive and save credentials each time a user logs onto a Windows workstation or domain via the `NPLogonNotify()` function.(Citation: NPLogonNotify)\\n\\nAdversaries may target planting malicious network provider DLLs on systems known to have increased logon activity and/or administrator logon activity, such as servers and domain controllers.(Citation: NPPSPY - Huntress)',\n", " 'tactics': ['credential-access', 'defense-evasion', 'persistence'],\n", " 'technique_id': 'T1556.008'}" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "new_techniques[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.5 64-bit", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.5" }, "vscode": { "interpreter": { "hash": "d5578407454ed8b46d5a520aa891bfa98d54062902a5b11199a67e3a266b6c1b" } } }, "nbformat": 4, "nbformat_minor": 4 }