Created
January 4, 2018 05:10
-
-
Save keithmccammon/82a66ba804c37cf0dea0f8937c0296c6 to your computer and use it in GitHub Desktop.
Download MITRE PRE-ATT&CK techniques via Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import pprint | |
import requests | |
if __name__ == '__main__': | |
request_all = requests.get('https://attack.mitre.org/pre-attack/api.php?action=ask&format=json&query=%5B%5BCategory%3ATechnique%5D%5D%7C%3FHas%20tactic%7C%3FHas%20ID%7C%3FHas%20display%20name%7Climit%3D9999') | |
all_techniques = json.loads(request_all.text)['query']['results'] | |
for technique, data in all_techniques.items(): | |
for v in data.values(): | |
if type(v) is dict: | |
request_technique = requests.get('https://attack.mitre.org/pre-attack/api.php?action=ask&format=json&query=%5B%5BCategory%3ATechnique%5D%5D%5B%5BHas%20ID%3A%3A{0}%5D%5D%7C%3FHas%20tactic%7C%3FHas%20ID%7C%3FHas%20display%20name%7C%3FHas%20technical%20description%7Climit%3D9999'.format(v['Has ID'][0])) | |
technique_detail = json.loads(request_technique.text)['query']['results'] | |
for details in technique_detail.values(): | |
pprint.pprint(details) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment