├── requirements.txt ├── images ├── slow.png ├── yes.png ├── exportall.png ├── exportone.png ├── addabilites.png ├── saveability.png ├── savevariables.png ├── selectability.png └── reloadabilities.png ├── static ├── img │ ├── load.png │ ├── atomics.png │ ├── reload.png │ ├── export-all.png │ └── export-one.png ├── js │ ├── atomiccaldera.js │ └── sections.js └── css │ ├── modal.css │ ├── tabs.css │ ├── timeline.css │ └── basic.css ├── conf ├── artconf.yml └── ac.sql ├── legacy ├── Cmd-Wrapper.txt ├── Update-AtomicVariables.py └── Atomic-Caldera.py ├── app ├── artyaml.py ├── ac_database.py └── atomic_caldera.py ├── hook.py ├── .gitignore ├── README.md ├── templates └── atomiccaldera.html └── LICENSE /requirements.txt: -------------------------------------------------------------------------------- 1 | pyyaml>=5.1 2 | stix2>=1.1.2 3 | -------------------------------------------------------------------------------- /images/slow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/slow.png -------------------------------------------------------------------------------- /images/yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/yes.png -------------------------------------------------------------------------------- /images/exportall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/exportall.png -------------------------------------------------------------------------------- /images/exportone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/exportone.png -------------------------------------------------------------------------------- /static/img/load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/static/img/load.png -------------------------------------------------------------------------------- /images/addabilites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/addabilites.png -------------------------------------------------------------------------------- /images/saveability.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/saveability.png -------------------------------------------------------------------------------- /static/img/atomics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/static/img/atomics.png -------------------------------------------------------------------------------- /static/img/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/static/img/reload.png -------------------------------------------------------------------------------- /images/savevariables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/savevariables.png -------------------------------------------------------------------------------- /images/selectability.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/selectability.png -------------------------------------------------------------------------------- /static/img/export-all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/static/img/export-all.png -------------------------------------------------------------------------------- /static/img/export-one.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/static/img/export-one.png -------------------------------------------------------------------------------- /images/reloadabilities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xenoscr/atomiccaldera/HEAD/images/reloadabilities.png -------------------------------------------------------------------------------- /conf/artconf.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ctipath: ~/working/atomic-caldera/cti 3 | artpath: ~/working/forks/atomic-red-team/atomics 4 | -------------------------------------------------------------------------------- /conf/ac.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE if not exists art_ability (id integer primary key AUTOINCREMENT, ability_id text, technique integer, name text, description text, tactic text, attack_name text, platform text, executor text, command text, pname text, pproperty text, pscript text, cleanup text, UNIQUE (ability_id, executor, command) ON CONFLICT IGNORE); 2 | CREATE TABLE if not exists art_var (id integer primary key AUTOINCREMENT, ability_id text, var_name text, value text, UNIQUE (ability_id, var_name) ON CONFLICT IGNORE); 3 | -------------------------------------------------------------------------------- /static/js/atomiccaldera.js: -------------------------------------------------------------------------------- 1 | function restRequest(type, data, callback, endpoint='/plugin/atomiccaldera/rest') { 2 | $.ajax({ 3 | url: endpoint, 4 | type: type, 5 | contentType: 'application/json', 6 | data: JSON.stringify(data), 7 | success: function(data) { callback(data); }, 8 | error: function(xhr, ajaxOptions, throwError) { console.log(throwError); } 9 | }); 10 | } 11 | 12 | function updateButtonState(selector, state) { 13 | (state === 'valid') ? 14 | $(selector).attr('class','button-success atomic-button') : 15 | $(selector).attr('class','button-notready atomic-button'); 16 | } 17 | 18 | function updateNavButtonState(selector, state) { 19 | (state === 'valid') ? 20 | $(selector).attr('class','row-toolbar-button') : 21 | $(selector).attr('class','row-toolbar-button-notready row-toolbar-button'); 22 | } 23 | -------------------------------------------------------------------------------- /legacy/Cmd-Wrapper.txt: -------------------------------------------------------------------------------- 1 | $signature = @' 2 | [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); 3 | [DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hWnd); 4 | '@ 5 | $type = Add-Type -MemberDefinition $signature -Name WindowAPI -PassThru 6 | Add-Type -AssemblyName microsoft.VisualBasic 7 | Add-Type -AssemblyName System.Windows.Forms 8 | 9 | Function Show-Process($Process) { 10 | Start-Sleep 3 11 | $hWnd = $Process.MainWindowHandle 12 | $type::ShowWindowAsync($hWnd, 4) 13 | $type::SetForegroundWindow($hWnd) 14 | Start-Sleep 3 15 | } 16 | 17 | $commands = @" 18 | #{command} 19 | "@ -split "`n" 20 | 21 | $cmdWindow = Start-Process -WindowStyle Normal -FilePath c:\windows\system32\cmd.exe -PassThru 22 | 23 | ForEach ($line in $commands) { 24 | If ($line -ne "") { 25 | $cmd = $line -replace "%","{%}" 26 | Show-Process($cmdWindow) 27 | [System.Windows.Forms.SendKeys]::SendWait("$cmd{Enter}") 28 | } 29 | } 30 | Show-Process($cmdWindow) 31 | [System.Windows.Forms.SendKeys]::SendWait("^{a}^{c}exit{Enter}") 32 | Get-Clipboard 33 | -------------------------------------------------------------------------------- /app/artyaml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | ################################################################################ 3 | # Name: artyaml.py 4 | # Author: Conor Richard (@xenosCR) 5 | # 6 | # Description: The ARTyaml class is a simple class that is used to read and 7 | # parse the contents of Red Canary's Atomic Red Team (ART) YAML files. 8 | # 9 | # Instructions: See the README.md file. 10 | # 11 | # Credits: 12 | # Red Canary's Atomic Red Team - https://github.com/redcanaryco/atomic-red-team 13 | # MITRE's Caldera - https://github.com/mitre/caldera 14 | ################################################################################ 15 | 16 | import asyncio 17 | import os, sys, yaml 18 | 19 | class ARTyaml: 20 | def __init__(self): 21 | self.yamlData = None 22 | self.displayName = None 23 | self.attackTech = None 24 | self.atomicTests = None 25 | 26 | def load(self, yamlFile): 27 | self.yamlData = yaml.load(yamlFile, Loader=yaml.Loader) 28 | if 'atomic_tests' in self.yamlData.keys(): 29 | self.displayName = self.get_displayName() 30 | self.attackTech = self.get_attackTech() 31 | self.atomicTests = self.get_atomicTests() 32 | 33 | def get_displayName(self): 34 | if self.yamlData: 35 | return self.yamlData['display_name'] 36 | 37 | def get_attackTech(self): 38 | if self.yamlData: 39 | return self.yamlData['attack_technique'] 40 | 41 | def get_atomicTests(self): 42 | if self.yamlData: 43 | return self.yamlData['atomic_tests'] 44 | -------------------------------------------------------------------------------- /hook.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Name: hook.py 3 | # Author: Conor Richard (@xenosCR) 4 | # 5 | # Description: This is the plugin version of the original Atomic-Caldera script 6 | # the purpose of this plugin is to simplify the task of importing Red Canary's 7 | # Atomic Red Team tests into MITRE's Caldera testing framework. With this plugin 8 | # you can quickly build a library of abilities that can be used to create custom 9 | # adversaries to use with Caldera. 10 | # 11 | # Instructions: See the README.md file. 12 | # 13 | # Credits: 14 | # Red Canary's Atomic Red Team - https://github.com/redcanaryco/atomic-red-team 15 | # MITRE's Caldera - https://github.com/mitre/caldera 16 | ################################################################################ 17 | 18 | from plugins.atomiccaldera.app.atomic_caldera import AtomicCaldera 19 | from plugins.atomiccaldera.app.ac_database import ACDatabase 20 | from app.database.core_dao import CoreDao 21 | 22 | name = 'AtomicCaldera' 23 | description = 'A plugin for MITRE\'s Caldera to convert and manage Red Canaries Atomic Red Team tests for use with stockpile and chain.' 24 | address = '/plugin/atomiccaldera/gui' 25 | 26 | async def initialize(app, services): 27 | ac_data_svc = ACDatabase(CoreDao('ac.db', False), services.get('utility_svc')) 28 | ac_api = AtomicCaldera(services, ac_data_svc) 29 | data_svc = services.get('data_svc') 30 | app.router.add_static('/atomiccaldera', 'plugins/atomiccaldera/static', append_version=True) 31 | app.router.add_route('*', '/plugin/atomiccaldera/gui', ac_api.landing) 32 | app.router.add_route('*', '/plugin/atomiccaldera/rest', ac_api.rest_api) 33 | -------------------------------------------------------------------------------- /static/css/modal.css: -------------------------------------------------------------------------------- 1 | input[type=text], input[type=password], input[type=number] { 2 | width: 100%; 3 | height: 30px; 4 | padding: 12px 20px; 5 | box-sizing: border-box; 6 | margin-top: 15px; 7 | border-radius: 10px; 8 | } 9 | select { 10 | overflow: hidden; 11 | background: white; 12 | font-size: 14px; 13 | height: 30px; 14 | width: 100%; 15 | padding: 5px 15px; 16 | margin-top: 15px; 17 | border-radius: 10px; 18 | } 19 | .modal button { 20 | background-color: green; 21 | color: white; 22 | padding: 14px 20px; 23 | margin: 8px 0; 24 | border: none; 25 | cursor: pointer; 26 | width: 90%; 27 | } 28 | .modal button:hover { 29 | opacity: 0.6; 30 | } 31 | 32 | .cancelbtn { 33 | width: auto; 34 | padding: 10px 18px; 35 | background-color: #7a1f1f; 36 | } 37 | .imgcontainer { 38 | text-align: center; 39 | position: relative; 40 | margin-bottom: 25px; 41 | } 42 | img.avatar { 43 | width: 40%; 44 | border-radius: 50%; 45 | } 46 | .container { 47 | padding: 16px; 48 | } 49 | span.psw { 50 | float: right; 51 | padding-top: 16px; 52 | } 53 | .modal { 54 | display: none; /* Hidden by default */ 55 | position: fixed; /* Stay in place */ 56 | z-index: 100; /* Sit on top */ 57 | left: 0; 58 | top: 0; 59 | width: 100%; /* Full width */ 60 | background-color: rgb(0,0,0); /* Fallback color */ 61 | background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ 62 | padding-top: 70px; 63 | overflow-y: scroll; 64 | height: 100%; 65 | } 66 | .modal-content { 67 | background-color: #fefefe; 68 | margin: 5% auto 15% auto; 69 | width: 80%; 70 | } 71 | .modal p { 72 | color: #333; 73 | } 74 | .close { 75 | position: absolute; 76 | right: 25px; 77 | top: 0; 78 | color: #000; 79 | font-size: 35px; 80 | font-weight: bold; 81 | } 82 | 83 | .close:hover, 84 | .close:focus { 85 | color: #7a1f1f; 86 | cursor: pointer; 87 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | db.sqlite3-journal 62 | 63 | # Flask stuff: 64 | instance/ 65 | .webassets-cache 66 | 67 | # Scrapy stuff: 68 | .scrapy 69 | 70 | # Sphinx documentation 71 | docs/_build/ 72 | 73 | # PyBuilder 74 | target/ 75 | 76 | # Jupyter Notebook 77 | .ipynb_checkpoints 78 | 79 | # IPython 80 | profile_default/ 81 | ipython_config.py 82 | 83 | # pyenv 84 | .python-version 85 | 86 | # pipenv 87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 90 | # install all needed dependencies. 91 | #Pipfile.lock 92 | 93 | # celery beat schedule file 94 | celerybeat-schedule 95 | 96 | # SageMath parsed files 97 | *.sage.py 98 | 99 | # Environments 100 | .env 101 | .venv 102 | env/ 103 | venv/ 104 | ENV/ 105 | env.bak/ 106 | venv.bak/ 107 | 108 | # Spyder project settings 109 | .spyderproject 110 | .spyproject 111 | 112 | # Rope project settings 113 | .ropeproject 114 | 115 | # mkdocs documentation 116 | /site 117 | 118 | # mypy 119 | .mypy_cache/ 120 | .dmypy.json 121 | dmypy.json 122 | 123 | # Pyre type checker 124 | .pyre/ 125 | 126 | # VIM swap files 127 | *~ 128 | *.swp 129 | *.swo 130 | -------------------------------------------------------------------------------- /static/css/tabs.css: -------------------------------------------------------------------------------- 1 | .tab { 2 | overflow: hidden; 3 | background-color: var(--theme-color); 4 | } 5 | .tab button { 6 | background-color: inherit; 7 | float: left; 8 | border: none; 9 | outline: none; 10 | cursor: pointer; 11 | padding: 4px 22px; 12 | transition: 0.3s; 13 | font-size: 14px; 14 | color: white; 15 | } 16 | .tab button:hover { 17 | background-color: white; 18 | color: black; 19 | } 20 | .tab button.active-tab { 21 | background-color: white; 22 | color: black; 23 | } 24 | .tabcontent { 25 | 26 | } 27 | .subtabcontent { 28 | display: none; 29 | padding: 6px 12px; 30 | border-top: none; 31 | } 32 | .subtab { 33 | margin-top: 10px; 34 | background-color: #262626; 35 | border-radius: 4px; 36 | } 37 | 38 | .block-nav { 39 | margin: 0 0 0 0; 40 | font-family: Arial; 41 | font-size: 100%; 42 | width: 80%; 43 | overflow: hidden; 44 | padding: 0 35px; 45 | } 46 | 47 | .block-nav ul { 48 | list-style: none; 49 | padding: 0; 50 | margin: 0 -35px; 51 | } 52 | 53 | .block-nav ul li { 54 | float: left; 55 | width: 50%; 56 | margin: 0; 57 | padding: 0; 58 | } 59 | .block-nav ul li a { 60 | display: block; 61 | background: #000; 62 | padding: 25px 0; 63 | } 64 | 65 | .block-nav .active-tab { 66 | background-color: var(--primary-background); 67 | } 68 | 69 | .block-nav ul li a:hover { 70 | background-color: var(--primary-background); 71 | } 72 | 73 | .block-nav ul li::before{ 74 | display: none; 75 | } 76 | 77 | .top-block-nav { 78 | margin: 0 -25px; 79 | font-family: Arial; 80 | font-size: 100%; 81 | width: 90%; 82 | overflow: hidden; 83 | padding: 0 35px; 84 | } 85 | 86 | .top-block-nav h2 { 87 | margin: 0; 88 | text-align: center; 89 | } 90 | 91 | .top-block-nav ul { 92 | list-style: none; 93 | padding: 0; 94 | margin: 0 -25px; 95 | } 96 | 97 | .top-block-nav ul li { 98 | float: left; 99 | width: 25%; 100 | margin: 0; 101 | padding: 0; 102 | } 103 | .top-block-nav ul li a { 104 | display: block; 105 | background-color: black; 106 | border-bottom: 3px solid #333; 107 | padding: 25px 0 22px 0; 108 | } 109 | 110 | .top-block-nav .active-tab { 111 | border-bottom: 3px solid var(--theme-color); 112 | background-color: #333; 113 | } 114 | 115 | .top-block-nav ul li a:hover { 116 | border-bottom: 3px solid var(--theme-color); 117 | } 118 | 119 | .top-block-nav ul li::before{ 120 | display: none; 121 | } -------------------------------------------------------------------------------- /static/css/timeline.css: -------------------------------------------------------------------------------- 1 | a, 2 | span, 3 | h1, 4 | h2, 5 | h3, 6 | span { 7 | text-decoration: none; 8 | } 9 | 10 | a:hover { 11 | color: #777; 12 | } 13 | .member-title { 14 | font-family: 'Raleway', sans-serif; 15 | letter-spacing: 1.5px; 16 | color: var(--font-color); 17 | font-weight: 100; 18 | font-size: 2.4em; 19 | margin: 0; 20 | border-bottom: 1px solid #777; 21 | padding-bottom: 0.2em; 22 | } 23 | #content { 24 | margin-top: 50px; 25 | text-align: center; 26 | } 27 | .timeline { 28 | border-left: 0.25em solid var(--theme-color); 29 | background: rgba(255, 255, 255, 0.1); 30 | margin: 2em auto; 31 | line-height: 1.4em; 32 | padding: 1em; 33 | padding-left: 3em; 34 | list-style: none; 35 | text-align: left; 36 | margin-left: 10em; 37 | margin-right: 3em; 38 | border-radius: 0.5em; 39 | min-width: 22em; 40 | } 41 | .event { 42 | min-width: 20em; 43 | width: 90%; 44 | vertical-align: middle; 45 | box-sizing: border-box; 46 | position: relative; 47 | } 48 | .timeline .event:before, 49 | .timeline .event:after { 50 | position: absolute; 51 | display: block; 52 | top: 1em; 53 | } 54 | .timeline .event:before { 55 | left: -15em; 56 | color: var(--font-color); 57 | content: attr(data-date); 58 | text-align: right; 59 | font-weight: 100; 60 | font-size: 0.9em; 61 | min-width: 9em; 62 | } 63 | .timeline .event:after { 64 | left: -3.5em; 65 | background: var(--primary-background); 66 | border-radius: 50%; 67 | height: 0.75em; 68 | width: 0.75em; 69 | content: ""; 70 | } 71 | .timeline .grey:after { 72 | box-shadow: 0 0 0 0.2em grey; 73 | } 74 | .timeline .red:after { 75 | box-shadow: 0 0 0 0.2em red; 76 | } 77 | .timeline .green:after { 78 | box-shadow: 0 0 0 0.2em rgb(28, 202, 0); 79 | } 80 | .timeline .event .member-location, 81 | .timeline .event .member-parameters { 82 | display: none; 83 | } 84 | .timeline .event:last-of-type .member-location, 85 | .timeline .event:last-of-type .member-parameters { 86 | display: block; 87 | } 88 | .member-infos { 89 | padding: 10px; 90 | text-align: left; 91 | position: relative; 92 | } 93 | .member-infos > h1 { 94 | font-weight: bold; 95 | font-size: 1.4em; 96 | } 97 | .member-location a:before { 98 | margin-right: 5px; 99 | } 100 | .member-location { 101 | text-indent: 2px; 102 | } 103 | .member-result { 104 | color: var(--font-color); 105 | font-size: 13px; 106 | } 107 | .tooltip { 108 | position: relative; 109 | display: inline-block; 110 | border-bottom: 1px dotted var(--font-color); 111 | font-size: 13px; 112 | } 113 | .tooltip .tooltiptext { 114 | visibility: hidden; 115 | width: 120px; 116 | background-color: black; 117 | color: #fff; 118 | text-align: center; 119 | border-radius: 6px; 120 | padding: 5px 0; 121 | 122 | /* Position the tooltip */ 123 | position: absolute; 124 | z-index: 1; 125 | top: -5px; 126 | left: 105%; 127 | font-size: 13px; 128 | } 129 | .tooltip:hover .tooltiptext { 130 | visibility: visible; 131 | } -------------------------------------------------------------------------------- /app/ac_database.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | ################################################################################ 3 | # Name: ac_database.py 4 | # Author: Conor Richard (@xenosCR) 5 | # 6 | # Description: The ACDatabase class is used to perform the database functions 7 | # required for the Atomic Caldera plugin to work. 8 | # 9 | # Instructions: See the README.md file. 10 | # 11 | # Credits: 12 | # Red Canary's Atomic Red Team - https://github.com/redcanaryco/atomic-red-team 13 | # MITRE's Caldera - https://github.com/mitre/caldera 14 | ################################################################################ 15 | 16 | import asyncio, os 17 | 18 | from app.service.base_service import BaseService 19 | 20 | class ACDatabase(BaseService): 21 | def __init__(self, dao, utility_svc): 22 | self.dao = dao 23 | self.utility_svc = utility_svc 24 | self.log = self.add_service('ac_data_svc', self) 25 | 26 | async def build_db(self, schema): 27 | with open(schema) as schema: 28 | await self.dao.build(schema.read()) 29 | 30 | async def create_art_ability(self, ability): 31 | try: 32 | await self.dao.create('art_ability', ability) 33 | except Exception as e: 34 | self.log.error(e) 35 | 36 | async def create_art_variable(self, variable): 37 | try: 38 | await self.dao.create('art_var', variable) 39 | except Exception as e: 40 | self.log.error(e) 41 | 42 | async def check_art_ability(self, condition): 43 | try: 44 | data = await self.dao.get('art_ability', condition) 45 | except Exception as e: 46 | self.log.error(e) 47 | return False 48 | if len(data) > 0: 49 | return True 50 | else: 51 | return False 52 | 53 | async def get_art_ability(self, condition): 54 | data = None 55 | try: 56 | data = await self.dao.get('art_ability', condition) 57 | except Exception as e: 58 | self.log.error(e) 59 | return None 60 | return data 61 | 62 | async def get_art_variable(self, condition): 63 | data = None 64 | try: 65 | data = await self.dao.get('art_var', condition) 66 | except Exception as e: 67 | self.log.error(e) 68 | return None 69 | return data 70 | 71 | async def explode_art_abilities(self, criteria=None): 72 | try: 73 | abilities = await self.dao.get('art_ability', criteria=criteria) 74 | for ab in abilities: 75 | ab['cleanup'] = '' if ab['cleanup'] is None else ab['cleanup'] 76 | except Exception as e: 77 | self.log.error(e) 78 | return [] 79 | return abilities 80 | 81 | async def explode_art_variables(self, criteria=None): 82 | try: 83 | variables = await self.dao.get('art_var', criteria=criteria) 84 | except Exception as e: 85 | self.log.error(e) 86 | return [] 87 | return variables 88 | 89 | async def update_art_ability(self, key, value, data): 90 | try: 91 | status = await self.dao.update('art_ability', key, value, data) 92 | except Exception as e: 93 | self.log.error(e) 94 | return False 95 | return True 96 | 97 | async def update_art_variables(self, data): 98 | try: 99 | for variable in data: 100 | updates = { 'var_name': variable['var_name'], 'value': variable['value'] } 101 | status = await self.dao.update('art_var', 'id', variable['id'], updates) 102 | self.log.debug(status) 103 | except Exception as e: 104 | self.log.error(e) 105 | return False 106 | return True 107 | 108 | async def delete_all(self): 109 | try: 110 | status = await self.dao.raw_update('DROP TABLE art_ability;') 111 | status = await self.dao.raw_update('DROP TABLE art_var;') 112 | except Exception as e: 113 | self.log.error(e) 114 | return 'Deletion failed.' 115 | return 'Deletion succeded.' 116 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This project is no longer being maintained. 2 | 3 | # Atomic-Caldera 4 | A MITRE Caldera plugin written in Python 3 used to convert Red Canary Atomic Red Team Tests to MITRE Caldera Stockpile YAML ability files. 5 | 6 | ## Backstory 7 | While looking into tools to help test and develop Red/Blue (Purple) teams by running MITRE ATT&CK mapped tests, I investigated MITRE's Caldera (https://github.com/mitre/caldera) and liked what I saw. I did not like that Caldera does not included many abilities/tests by default. I also looked at Red Canary's Atomic Red Team (https://github.com/redcanaryco/atomic-red-team), there are lot of tests included with Atomic Red Team but the included testing framework wasn't as nice as Caldera. I also like the Sandcat (https://github.com/mitre/sandcat) plugin included with Caldera. It can easily be run on many different endpoints, it is light weight, and provides the capability to perform tests from a central Caldera server. By combining the tests from Red Canary's Atomic Red Team with the testing framework of MITRE's Caldera the best of both tool sets could be enjoyed. 8 | 9 | I looked around and did not find any tools to convert Red Canary's Atomic Red Team tests to MITRE Caldera Stockpile (https://github.com/mitre/stockpile) format. My desire to quickly build a library using the high quality tests provided by Red Canary in MITRE's Caldera framework drove me to write a "quick" script. This desire led me down a path of developing the tool as a plugin to MITRE's Caldera. This most recent update can now be used with Caldera as a plugin. The original scripts can still be located in the legacy folder and used indipendently from the plugin. 10 | 11 | ## Requirements 12 | Python 3.6.8+ with the following libraries installed 13 | * PyYAML - https://pyyaml.org/wiki/PyYAML 14 | * STIX2 - https://github.com/oasis-open/cti-python-stix2 15 | 16 | Atomic-Caldera requires the following repositories be stored locally somewhere: 17 | * https://github.com/redcanaryco/atomic-red-team 18 | * https://github.com/mitre/cti 19 | 20 | ## Installation 21 | Clone the repository to MITRE's Caldera "plugins" folder: 22 | ``` 23 | cd 24 | git clone https://github.com/xenoscr/atomiccaldera.git 25 | ``` 26 | Change directories: 27 | ``` 28 | cd atomiccaldera 29 | ``` 30 | Install required Python modules: 31 | ``` 32 | pip install -r requirements.txt 33 | ``` 34 | Clone the Red Canary Atomic Red Team repository: 35 | ``` 36 | git clone https://github.com/redcanaryco/atomic-red-team.git 37 | ``` 38 | Clone the MITRE CTI repository: 39 | ``` 40 | git clone https://github.com/mitre/cti.git 41 | ``` 42 | Edit the conf/artconf.yml file to update the paths to point to your Atomic Red Team and CTI repositories. 43 | Edit Caldera's local.yml file and add atomiccaldera to the plugins section. 44 | 45 | ## Usage 46 | ### Atomic-Caldera 47 | The first time you access the Atomic Caldera plugin you will need to import the Atomic Red Team YAML files to populate Atomic Caldera's database. To do this click the "Add Abilities" button. Adding the abilities for the first time will take some time to complete, please be patient, the status will update when the import is completed. 48 | 49 | ![Click "Add Abilities"](images/addabilites.png?raw=true "Add Abilities") 50 | 51 | #### Selecting an Ability 52 | To select an ability: 53 | 1. First select a tactic "Select ATT&CK tactic" drop down. 54 | 2. Next select the ability from the "Select ability" drop down. 55 | 56 | ![Selecting an ability](images/selectability.png?raw=true "Select Ability") 57 | 58 | After you have selected an ability you can use the left and right arrows to quickly move through the list of available abilities related to the selected tactic. 59 | 60 | #### Saving an Ability 61 | If you have made changes to an ability and wish to save them: 62 | 1. Click the "Save Ability" button. 63 | 64 | ![Save Ability](images/saveability.png?raw=true "Save Ability") 65 | 66 | #### Saving Variables 67 | If you have made changes to variables and wish to save them: 68 | 1. Click the "Save Variables" button. 69 | 70 | ![Save variables](images/savevariables.png?raw=true "Save Variables") 71 | 72 | #### Export a Single Ability 73 | If you wish to export the selected ability only to Stockpile: 74 | 1. Click the Export Ability button. 75 | 76 | ![Export ability](images/exportone.png?raw=true "Export single ability")  77 | 78 | #### Export All Abilities 79 | If you wish to export all of the abilities from Atomic Caldera to Stockpile: 80 | 1. Click the Export All Abilities button. 81 | 82 | ![Export All Abilities](images/exportall.png?raw=true "Export All Abilities") 83 | 84 | #### Reloading Data (i.e. Start over) 85 | If you wish to delete everything that has been imported and wish to start over, do so by: 86 | 1. Click the Reload Abilities button 87 | 88 | ![Reload Abilities](images/reloadabilities.png?raw=true "Reload Abilities") 89 | 90 | 2. Click the Yes button. 91 | 92 | ![Yes](images/yes.png?raw=true "Yes") 93 | 94 | After clicking yes, it will then take some time for the abilities to complete reloading. 95 | **NOTE**: It is necessary to restart Caldera to view the new abilities. At the moment there is no way to force Chain to reload its database from the GUI. 96 | 97 | ## To-Do 98 | Still not perfect but, it gets the bulk for the work done at this time. I would like to work on/fix the following eventually: 99 | - [ ] Include the ability to build adversaries from ART tests. Chain removed the ability to edit adversaries via the GUI which makes it more difficult to quickly build adversaries. 100 | 101 | ## Change-Log 102 | ### v3.0.1 103 | * Changed the repository name to make it easier to install. 104 | ### v3.0 105 | What didn't change? 106 | * Atomic Caldera is now a plugin for MITRE's Caldera 107 | * Added ability to edit and save changes to abilities and variables 108 | * Added ability to export ablilities directly to Stockpile YAML files. 109 | 110 | ### v2.0 111 | * Changed the default output to generate Caldera YML files with the variables intact. i.e. #{variable} 112 | * Added a second CSV file output to output the CSV values so they can be edited before being imported to customize the tests. 113 | * Added the Update-AtomicVariables.py script to populate the variable values and save the completed tests to a new directory. 114 | * Added a wrapper script to support running Command Prompt commands using Caldera. Caldara supports Bash and PowerShell commands only. Some of the Atomic Red Team tests that were meant to run under the Command Prompt did not work properly due to formatting issues. The wrapper script spawns a new Command Prompt window and sends the keystrokes to run the commands. Once complete it copies the Command Prompt stdout to the clipboard so that the results can be displayed in Caldera's results window. 115 | 116 | ## License 117 | See the [LICENSE](https://github.com/xenoscr/Atomic-Caldera/blob/master/LICENSE) 118 | 119 | ## Credits 120 | * CTI and Caldara are maintained by MITRE: @mitre - https://github.com/mitre 121 | * Atomic Red Team is maintained by Red Canary Co.: @redcanaryco - https://github.com/redcanaryco 122 | -------------------------------------------------------------------------------- /templates/atomiccaldera.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Atomic-Caldera | Dashboard 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | Home 16 | AtomicCaldera 17 |
18 | Logout 19 |
20 |
21 | 22 | 23 |
24 |
25 | 51 |
52 |
53 |
54 |
55 |
56 | 57 |
58 |
59 |
60 |

Process Status

61 |

62 |
63 |
64 |
65 | 66 | 67 |
68 |
69 |
70 | 71 | 72 | 73 | 74 | 75 |
76 |
77 |
78 | 79 |

Manage abilities

80 |

View available techniques

81 |
82 | 88 | 91 | 92 |
93 |
94 |
95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 |

Variable Table

137 |

Ability ID:

ATT&CK Tactic:

ATT&CK Technique ID:

ATT&CK Technique Name:

Name:

Description:

Platform:

Executor:

Command:

Cleanup:

138 | 139 | 140 | 141 |
142 |
143 |
144 | 145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /static/css/basic.css: -------------------------------------------------------------------------------- 1 | .row-toolbar{ 2 | margin: 0px -30px; 3 | display: flex; 4 | } 5 | .row-toolbar-section { 6 | padding: 0px 25px; 7 | display: inherit; 8 | border-right: 1px solid #1f1d1d; 9 | } 10 | .row-toolbar-button { 11 | display: flex; 12 | flex-direction: column; 13 | align-items: center; 14 | background-color: inherit; 15 | border: none; 16 | padding: 10px; 17 | width: 75px; 18 | color: white; 19 | font-size: 11px; 20 | pointer-events: auto; 21 | cursor: pointer; 22 | } 23 | .row-toolbar-button:hover{ 24 | background-color: var(--theme-color); 25 | filter: grayscale(75%); 26 | border: none; 27 | } 28 | .row-toolbar-button:focus { 29 | outline: none; 30 | } 31 | .row-toolbar-button img { 32 | height: 23px; 33 | width: 23px; 34 | padding-bottom: 5px; 35 | -webkit-filter: invert(1); 36 | filter: invert(1); 37 | } 38 | .row-toolbar-button-notready { 39 | background-color: var(--theme-color); 40 | filter: grayscale(95%); 41 | pointer-events: none; 42 | cursor: not-allowed; 43 | } 44 | .row-toolbar-item { 45 | padding: 0px 25px; 46 | } 47 | .row-toolbar-item p{ 48 | line-height: 22px; 49 | font-size: 18px; 50 | color: white; 51 | } 52 | .row-canvas{ 53 | flex:40%; 54 | } 55 | .section-border { 56 | border-right: .5px var(--font-color) solid; 57 | } 58 | .atomic-button { 59 | height:35px; 60 | margin-top: 10px; 61 | margin-bottom: 20px; 62 | width: 100%; 63 | border:none; 64 | border-radius: 25px; 65 | } 66 | .section-profile pre { 67 | width: 90%; 68 | background: white; 69 | border: 1px solid #ddd; 70 | border-left: 3px solid var(--theme-color); 71 | color: #666; 72 | page-break-inside: avoid; 73 | font-family: monospace; 74 | font-size: 15px; 75 | line-height: 1.6; 76 | margin-bottom: 1.6em; 77 | max-width: 100%; 78 | overflow: auto; 79 | padding: 1em 1.5em; 80 | display: block; 81 | word-wrap: break-word; 82 | } 83 | .section-profile img { 84 | border-radius: 50%; 85 | height:65px; 86 | width: auto; 87 | background-color: white; 88 | border: 5px solid var(--theme-color); 89 | margin-bottom:10px; 90 | } 91 | .section-profile h4 { 92 | margin-bottom:10px; 93 | margin-top:0px; 94 | } 95 | .section-profile h3 { 96 | text-transform: uppercase; 97 | font-weight: 400; 98 | margin-bottom:0px; 99 | } 100 | .section-profile ul { 101 | list-style-type: none; 102 | } 103 | .section-profile p { 104 | font-size: 13px; 105 | } 106 | .section-profile li { 107 | text-align: left; 108 | } 109 | .section-profile input { 110 | height: 18px; 111 | width: 75%; 112 | margin:5px; 113 | } 114 | .section-profile select { 115 | height: 30px; 116 | width: 75%; 117 | margin: 5px; 118 | pointer-events: auto; 119 | cursor: pointer; 120 | } 121 | .section-profile-notready select { 122 | pointer-events: none; 123 | cursor: not-allowed; 124 | } 125 | .section-profile button { 126 | width: 75%; 127 | } 128 | .top-tip { 129 | position: absolute; 130 | top: 18px; 131 | right: 18px; 132 | width: 150px; 133 | height: 25px; 134 | color: var(--font-color); 135 | } 136 | .top-tip button { 137 | background-color: inherit; 138 | color: var(--font-color); 139 | border:none; 140 | font-size:24px; 141 | } 142 | .darkSelect { 143 | width:200px; 144 | background-color: var(--primary-background); 145 | border:none; 146 | color: var(--font-color); 147 | } 148 | .highlight { 149 | background-color: yellow; 150 | } 151 | .ability-table td { 152 | width: 30%; 153 | vertical-align: middle; 154 | } 155 | .ability-table tr { 156 | border-bottom:1px solid white; 157 | } 158 | .ability-table td+td { 159 | width: 100%; 160 | } 161 | .ability-table p { 162 | text-transform: uppercase; 163 | font-size: 16px; 164 | font-weight:600; 165 | } 166 | .ability-table input { 167 | min-height:35px; 168 | font-size:16px; 169 | } 170 | .ability-table ol { 171 | list-style: none; 172 | counter-reset: item; 173 | } 174 | .ability-table li { 175 | list-style-type: circle; 176 | margin-bottom: 5px; 177 | font-size:15px; 178 | color: var(--font-color); 179 | line-height: 25px; 180 | } 181 | .ability-table li:before { 182 | margin-right: 10px; 183 | color: var(--font-color); 184 | width: 1.2em; 185 | display: inline-block; 186 | } 187 | .ability-table select { 188 | background-color: inherit; 189 | width: 90%; 190 | height:22px; 191 | color: var(--font-color); 192 | margin-top: -5px; 193 | border: none; 194 | font-size:12px; 195 | } 196 | .ability-table input { 197 | background-color: inherit; 198 | border: none; 199 | color: var(--font-color); 200 | text-align: left; 201 | } 202 | .ability-table textarea { 203 | height: 150px; 204 | width: 100%; 205 | font-size: 14px; 206 | border:none; 207 | overflow: auto; 208 | padding: 1em 1.5em; 209 | display: block; 210 | word-wrap: break-word; 211 | color: var(--font-color); 212 | background-color: inherit; 213 | } 214 | .op-dets img { 215 | border-radius: 50%; 216 | height:30px; 217 | width: auto; 218 | background-color: white; 219 | border: 2px solid var(--theme-color); 220 | } 221 | .op-dets h3 { 222 | margin-top: 10px; 223 | margin-bottom: 20px; 224 | } 225 | .op-dets p { 226 | text-transform: uppercase; 227 | } 228 | #profile-tests{ 229 | float: left; 230 | } 231 | .profile-tests li { 232 | font-size: 18px; 233 | color: var(--font-color); 234 | display: block; 235 | float: left; 236 | width:22%; 237 | margin:10px; 238 | } 239 | .ability-box { 240 | height:28px; 241 | width: 90%; 242 | background-color: var(--primary-background); 243 | border-radius:50px; 244 | border: 0 none; 245 | } 246 | .ability-box p { 247 | overflow: hidden; 248 | white-space: nowrap; 249 | text-overflow: ellipsis; 250 | margin-top: 0; 251 | } 252 | .ability-box legend { 253 | font-size: 10px; 254 | text-align: center; 255 | text-transform: uppercase; 256 | font-weight:500; 257 | } 258 | .ability-box p { 259 | padding-left: 5px; 260 | } 261 | .ability-box span { 262 | color: red; 263 | } 264 | .tag { 265 | font-size: 12px; 266 | border-radius: 6px; 267 | background-color: white; 268 | margin: 3px; 269 | color: black; 270 | display: inline-block; 271 | padding: 5px; 272 | cursor: pointer; 273 | } 274 | table.dataTable td.select-checkbox { 275 | position: relative; 276 | } 277 | table.dataTable td.select-checkbox:before, table.dataTable td.select-checkbox:after { 278 | display: block; 279 | position: absolute; 280 | top: 50%; 281 | left: 50%; 282 | width: 20px; 283 | height: 20px; 284 | transform: translateY(-50%); 285 | box-sizing: border-box; 286 | } 287 | table.dataTable td.select-checkbox:before{ 288 | content: ' '; 289 | margin-left: -6px; 290 | border: 1px solid white; 291 | border-radius: 3px; 292 | } 293 | table.dataTable tr.selected td.select-checkbox:after { 294 | content: '\2713'; 295 | margin-top: -6px; 296 | margin-left: -4px; 297 | font-size: 1.7em; 298 | color: green; 299 | text-align: center; 300 | } 301 | .decision-card td { 302 | color: var(--font-color); 303 | } 304 | .highlight { 305 | background-color: yellow; 306 | } 307 | .red-x { 308 | color: red; 309 | font-style: italic; 310 | } 311 | 312 | .adv-reqs { 313 | border-top:1px solid var(--font-color); 314 | float: left; 315 | width: 100%; 316 | } 317 | 318 | .adv-reqs h4 { 319 | margin-bottom:-5px; 320 | font-weight: 700; 321 | font-size: 16px; 322 | color: red; 323 | } 324 | .missing-facts-sublist{ 325 | padding: 0 40px; 326 | float: left; 327 | margin-bottom: 20px; 328 | margin-top: 10px; 329 | } 330 | .missing-facts-sublist > li { 331 | width: 100%; 332 | padding: 0; 333 | margin: 0; 334 | font-size: 12px; 335 | } 336 | #missingAdvReqs { 337 | padding-left: 0; 338 | } 339 | #missingAdvReqs > li { 340 | float: left; 341 | display: block; 342 | width: 100%; 343 | margin: 0; 344 | 345 | } 346 | -------------------------------------------------------------------------------- /legacy/Update-AtomicVariables.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | ############################################################################### 4 | # Name: Update-AtomicVariables.py 5 | # Author: Conor Richard (@xenosCR) 6 | # 7 | # Description: This script is used to populate the variable values in the 8 | # Atomic Red Team tests after they have been converted to Caldera formated 9 | # YML files. The purpose of this script is to make it easier to customize the 10 | # converted tests to run on various machines and networks. This can be 11 | # accomplished by editing the values in the CSV file (atomic-variables.csv by 12 | # default) to match the computers, network, etc. that you are performing your 13 | # testing with. 14 | # 15 | # This script will loop through all of the tests detailed in the CSV file and 16 | # update each variable value in the associated YML files and save the updated 17 | # YML files in a new folder. 18 | # 19 | # Known Issue(s): 20 | # None at this time. 21 | # 22 | # Requirements: 23 | # 1. Must have use the Atomic-Caldera.py script to convert the Atomic Red 24 | # Team test to Caldara tests. 25 | # 2. Must first update the CSV file that contains your variables to match 26 | # your testing environment. 27 | # 3. The following Python libraries are required: 28 | # a. yaml 29 | # 30 | # Credits: 31 | # Red Canary's Atomic Red Team - https://github.com/redcanaryco/atomic-red-team 32 | # MITRE's Caldera - https://github.com/mitre/caldera 33 | ############################################################################### 34 | 35 | import argparse, collections, csv, fnmatch, logging, os, shutil, sys, re, uuid, yaml 36 | 37 | class cmdStr(str): 38 | pass 39 | 40 | def cmd_presenter(dumper, data): 41 | return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') 42 | 43 | def checkAbilities(path): 44 | if os.path.exists(path): 45 | logging.debug('Checking for existing abilities files.') 46 | fileCount = 0 47 | for root, dirs, files in os.walk(path): 48 | for procFile in files: 49 | fullFile = os.path.join(root, procFile) 50 | if os.path.splitext(fullFile)[-1].lower() == '.yml': 51 | fileCount += 1 52 | if fileCount > 0: 53 | return True 54 | else: 55 | return False 56 | 57 | def checkCSVFile(csvPath): 58 | if os.path.exists(csvPath): 59 | try: 60 | with open(csvPath, 'r') as csvFile: 61 | line = csvFile.readline() 62 | except: 63 | logging.error('The provided path to the catalog CSV file is invalid or the CSV file is corrupted.') 64 | raise SystemExit 65 | 66 | if not line == 'attackUUID,attackID,executor,variable,value\n': 67 | logging.error('The provided path to the catalog CSV file is invalid or the CSV file is corrupted.') 68 | return False 69 | else: 70 | return True 71 | else: 72 | logging.debug('The catalog CSV fle does not exist.') 73 | return False 74 | 75 | # Taken from https://stackoverflow.com/questions/3041986/apt-command-line-interface-like-yes-no-input 76 | # to save time 77 | def query_yes_no(question, default="no"): 78 | """Ask a yes/no question via raw_input() and return their answer. 79 | 80 | "question" is a string that is presented to the user. 81 | "default" is the presumed answer if the user just hits . 82 | It must be "yes" (the default), "no" or None (meaning 83 | an answer is required of the user). 84 | 85 | The "answer" return value is True for "yes" or False for "no". 86 | """ 87 | valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} 88 | if default is None: 89 | prompt = " [y/n] " 90 | elif default == "yes": 91 | prompt = " [Y/n] " 92 | elif default == "no": 93 | prompt = " [y/N] " 94 | else: 95 | raise ValueError("invalid default answer: '%s'" % default) 96 | 97 | while True: 98 | sys.stdout.write(question + prompt) 99 | choice = input().lower() 100 | if default is not None and choice == '': 101 | return valid[default] 102 | elif choice in valid: 103 | return valid[choice] 104 | else: 105 | sys.stdout.write("Please respond with 'yes' or 'no' (or 'y' or 'n').\n") 106 | 107 | def main(inputDir, outputDir, csvPath): 108 | # Load the CSV file 109 | try: 110 | csvFile = [] 111 | uniqueUUID = [] 112 | with open(csvPath, 'r') as csvReadFile: 113 | reader = csv.DictReader(csvReadFile) 114 | for line in reader: 115 | csvFile.append(line) 116 | # Add the attackUUID value to a list of unique UUIDs 117 | if line['attackUUID'] not in uniqueUUID: 118 | uniqueUUID.append(line['attackUUID']) 119 | except: 120 | logging.error('Unable to read CSV file.') 121 | raise SystemExit 122 | 123 | # Create a fully copy of the directory first 124 | shutil.rmtree(outputDir) 125 | shutil.copytree(inputDir, outputDir, False) 126 | 127 | # Step through each UUID and update the command strings 128 | for curUUID in uniqueUUID: 129 | for root, dirnames, filenames in os.walk(inputDir): 130 | for filename in fnmatch.filter(filenames, '{}.yml'.format(curUUID)): 131 | curFile = os.path.join(root, filename) 132 | 133 | print("Processing: {}".format(curFile)) 134 | # Open and parse the YAML file 135 | with open(curFile, 'r') as yamlFile: 136 | try: 137 | yamlData = yaml.load(yamlFile, Loader=yaml.Loader) 138 | logging.debug('Successfully loaded: {}.'.format(curFile)) 139 | logging.debug(yamlData) 140 | except: 141 | logging.debug('Unable to load: {}.'.format(curFile)) 142 | raise SystemExit('Unable to load: {}.'.format(curFile)) 143 | 144 | # Get the command that will be updated 145 | for key in yamlData[0]['executors']: 146 | for key1 in yamlData[0]['executors'][key]: 147 | if key1 == 'command': 148 | command = yamlData[0]['executors'][key]['command'] 149 | logging.debug('Command value found.') 150 | logging.debug(command) 151 | 152 | # Update the command by looping through the CSV file and applying the appropriate variables 153 | for line in csvFile: 154 | if line['attackUUID'] == curUUID: 155 | command = re.sub(r"\#{{{argName}}}".format(argName = str(line['variable'])), str(line['value']).encode('unicode-escape').decode(), command) 156 | 157 | yamlData[0]['executors'][key]['command'] = cmdStr(command) 158 | logging.debug('Updated command in YAML variable.') 159 | else: 160 | logging.error('Command value not found, exiting.') 161 | raise SystemExit 162 | 163 | logging.debug(yamlData) 164 | 165 | # Write the YAML file to the correct directory using the UUID as the name. 166 | newAbilityDir = os.path.join(outputDir, os.path.split(os.path.dirname(curFile))[1]) 167 | if not os.path.exists(newAbilityDir): 168 | os.makedirs(newAbilityDir) 169 | 170 | newFile = os.path.join(newAbilityDir, filename) 171 | try: 172 | with open(newFile, 'w') as newYAMLFile: 173 | dump = yaml.dump(yamlData, default_style = None, default_flow_style = False, allow_unicode = True, encoding = None, sort_keys = False) 174 | newYAMLFile.write(dump) 175 | logging.debug('YAML file written: {}'.format(newFile)) 176 | except Exception as e: 177 | logging.error('Error creating YAML file.') 178 | print(e) 179 | raise SystemExit 180 | 181 | if __name__ == "__main__": 182 | # String representer for PyYAML to format the command string 183 | yaml.add_representer(cmdStr, cmd_presenter) 184 | 185 | # Setup Debugging messages 186 | logLvl = logging.ERROR 187 | logging.basicConfig(level=logLvl, format='%(asctime)s - %(levelname)s - %(message)s') 188 | logging.debug('Debugging logging is on.') 189 | 190 | # Parse the command arguments and display a usage message if incorrect parmeters are provided. 191 | parser = argparse.ArgumentParser(description = 'Populate the variable values in the abilities folder with those provided in the supplied input CSV file.') 192 | parser.add_argument("-i", "--inputdir", type=str, help='The path to the \"abilities\" folder that needs to be updated.') 193 | parser.add_argument("-o", "--outputdir", type=str, help='The path to store the updated \"abilities\" folder. If no argument is provided, an \"abilities-populated\" folder will be created.') 194 | parser.add_argument("-c", "--csv", type=str, help='The CSV file that will be used to update variable values.') 195 | 196 | args = parser.parse_args() 197 | 198 | # Validate the required arguments 199 | if args.inputdir: 200 | # Check for the presense of YAML files 201 | if checkAbilities(args.inputdir): 202 | inputDir = args.inputdir 203 | else: 204 | print('The input direcotry does not contain any YAML files.') 205 | raise SystemExit 206 | 207 | # Check the output directory 208 | if args.outputdir: 209 | outputDir = args.outputdir 210 | else: 211 | outputDir = os.path.join(os.path.split(os.path.dirname(inputDir))[0], 'abilities-updated/') 212 | 213 | if not os.path.exists(outputDir): 214 | os.makedirs(outputDir) 215 | logging.debug('Output directory created: {}'.format(outputDir)) 216 | else: 217 | logging.debug('Output directory exists: {}'.format(outputDir)) 218 | 219 | # Check for existing YAML files 220 | if checkAbilities(outputDir): 221 | answer = query_yes_no('The output directory already contains YAML files. If you continue, these files will be overwritten. Would you like to continue?') 222 | if answer == False: 223 | print('You chose not to continue. Please double-check your work and try again if needed.') 224 | raise SystemExit 225 | 226 | # Validate the CSV file 227 | if args.csv: 228 | if checkCSVFile(args.csv): 229 | main(inputDir, outputDir, args.csv) 230 | else: 231 | parser.print_help(sys.stderr) 232 | print('The provided CSV path could not be validated.') 233 | raise SystemExit 234 | else: 235 | parser.print_help(sys.stderr) 236 | print('You must supply a valid CSV file.') 237 | raise SystemExit 238 | else: 239 | parser.print_help(sys.stderr) 240 | print('You must provide an input directory containg the YAML files that need to be updated.') 241 | raise SystemExit 242 | -------------------------------------------------------------------------------- /static/js/sections.js: -------------------------------------------------------------------------------- 1 | // Portions of this code were borrowed from MITRE's Caldera chain plugin. All credits to them for anything I have reused. 2 | 3 | function addAbilities() { 4 | $('p.process-status').html('

Adding abilities, please wait...

This does take a while, please be patient.

') 5 | updateNavButtonState('#addAbilities', 'invalid'); 6 | updateNavButtonState('#reloadAbilities', 'invalid'); 7 | updateNavButtonState('#exportOneAbility', 'invalid'); 8 | updateNavButtonState('#exportAllToAbilities', 'invalid'); 9 | updateButtonState('#saveAbility', 'invalid'); 10 | updateButtonState('#saveVariables', 'invalid'); 11 | $('select#ability-tactic-filter').prop("disabled", true); 12 | $('select#ability-test').prop("disabled", true); 13 | restRequest('PUT', {"index": "ac_ability"}, addAbilitiesCallback); 14 | } 15 | 16 | function addAbilitiesCallback(data) { 17 | alert(data); 18 | $('p.process-status').html(data); 19 | location.reload(); 20 | } 21 | 22 | function reloadAbilities() { 23 | $('p.process-status').html('

Clicking "YES" will delete all ability and variable data. WARNING: You will lose all current UUIDs! Are you sure?

'); 24 | $('#yoloDelete').click(function() { 25 | $('p.process-status').html('

Reloading abilities, please wait...

This does take a while, please be patient.

') 26 | deleteAll(); 27 | }); 28 | $('#safeNo').click(function() { 29 | $('p.process-status').html('Reload process cancled.'); 30 | }); 31 | } 32 | 33 | $(document).ready(function () { 34 | $("#ability-property-filter option").val(function(idx, val) { 35 | $(this).siblings('[value="'+ val +'"]').remove(); 36 | }); 37 | $('#nextAbility').click(function() { 38 | $('#ability-test option:selected').next().prop("selected", true); 39 | loadAbility(); 40 | populateVariables(); 41 | }); 42 | $('#previousAbility').click(function() { 43 | $('#ability-test option:selected').prev().prop("selected", true); 44 | loadAbility(); 45 | populateVariables(); 46 | }); 47 | $('#nextResult').click(function() { 48 | $('#decisionResult').get(0).value++; 49 | findResults(); 50 | }); 51 | }); 52 | 53 | function deleteAll() { 54 | clearAbility(); 55 | clearVariables(); 56 | updateNavButtonState('#addAbilities', 'invalid'); 57 | updateNavButtonState('#reloadAbilities', 'invalid'); 58 | updateNavButtonState('#exportOneAbility', 'invalid'); 59 | updateNavButtonState('#exportAllToAbilities', 'invalid'); 60 | updateButtonState('#saveAbility', 'invalid'); 61 | updateButtonState('#saveVariables', 'invalid'); 62 | $('select#ability-tactic-filter').prop("disabled", true); 63 | $('select#ability-test').prop("disabled", true); 64 | restRequest('DELETE', {"index": "delete_all"}, deleteAllCallback); 65 | } 66 | 67 | function deleteAllCallback() { 68 | $('p.process-status').html('

Abilities have been deleted.

'); 69 | addAbilities(); 70 | location.reload(); 71 | } 72 | 73 | function populateTacticAbilities(){ 74 | let exploits = JSON.parse($('#ability-data pre').text()); 75 | 76 | let parent = $('#ability-profile'); 77 | clearAbilityDossier(); 78 | $(parent).find('#ability-test').empty().append(""); 79 | 80 | let tactic = $(parent).find('#ability-tactic-filter').find(":selected").data('tactic'); 81 | exploits.forEach(function(ability) { 82 | if(tactic == ability.tactic) 83 | appendAbilityToList(tactic, ability); 84 | }); 85 | $('#ability-property-filter').css('opacity',0.5); 86 | $('#ability-tactic-filter').css('opacity',1.0); 87 | } 88 | 89 | function appendAbilityToList(tactic, value) { 90 | $('#ability-profile').find('#ability-test').append($("") 91 | .attr("value",value['name']) 92 | .attr("ability_id",value['ability_id']) 93 | .data("tactic", tactic) 94 | .data("technique", value['technique']) 95 | .data("attack_name", value['attack_name']) 96 | .data("name", value['name']) 97 | .data("description", value['description']) 98 | .data("platform", value['platform']) 99 | .data("executor", value['executor']) 100 | .data("command",value['command']) 101 | .data("cleanup", value['cleanup']) 102 | .text(value['name'] +' ('+value['platform']+'/'+value['executor']+')')); 103 | } 104 | 105 | function populateVariables() { 106 | clearVariables(); 107 | let variables = JSON.parse($('#variable-data pre').text()); 108 | 109 | let ability_id = $('#ability-profile').find('#ability-id').val(); 110 | let varCount = 0; 111 | variables.forEach(function(variable) { 112 | if(ability_id == variable.ability_id) 113 | { 114 | varCount++; 115 | $('table.variable-table tbody tr:last').after('').attr('class', 'variable').append($('').attr('class', 'name').append($('

').data("id", variable.id).text(variable.var_name))).append($('').attr('class', 'value').append($('').attr('align', 'left').attr('style', 'text-align:left;').val(atob(variable.value)))); 116 | } 117 | }); 118 | if(varCount == 0) 119 | updateButtonState('#saveVariables', 'invalid'); 120 | else 121 | updateButtonState('#saveVariables', 'valid'); 122 | } 123 | 124 | function clearVariables() { 125 | $('table.variable-table tbody tr').remove(); 126 | $('table.variable-table tbody').append(''); 127 | } 128 | 129 | function clearAbilityDossier(){ 130 | $('#ability-profile .ability-table tr:last td:input,ol').each(function(){ 131 | $(this).val(''); 132 | $(this).empty(); 133 | }); 134 | $('#ability-profile').find('textarea#ability-command').each(function(){ 135 | $(this).html(''); 136 | }); 137 | } 138 | 139 | function loadAbility() { 140 | let parent = $('#ability-profile'); 141 | clearAbilityDossier(); 142 | 143 | let chosen = $('#ability-test option:selected'); 144 | $(parent).find('#ability-id').val($(chosen).attr('ability_id')); 145 | $(parent).find('#ability-name').val($(chosen).data('name')); 146 | $(parent).find('#ability-executor').val($(chosen).data('executor')); 147 | $(parent).find('#ability-platform').val($(chosen).data('platform')); 148 | $(parent).find('#ability-tactic').val($(chosen).data('tactic')); 149 | $(parent).find('#ability-technique-id').val($(chosen).data('technique')); 150 | $(parent).find('#ability-technique-name').val($(chosen).data('attack_name')); 151 | $(parent).find('#ability-description').val($(chosen).data('description')); 152 | $(parent).find('#ability-command').html(atob($(chosen).data('command'))); 153 | $(parent).find('#ability-cleanup').val(atob($(chosen).data('cleanup'))); 154 | } 155 | 156 | function clearAbility() { 157 | let parent = $('#ability-profile'); 158 | clearAbilityDossier(); 159 | 160 | $(parent).find('#ability-id').val(''); 161 | $(parent).find('#ability-name').val(''); 162 | $(parent).find('#ability-executor').val(''); 163 | $(parent).find('#ability-platform').val(''); 164 | $(parent).find('#ability-tactic').val(''); 165 | $(parent).find('#ability-technique-id').val(''); 166 | $(parent).find('#ability-technique-name').val(''); 167 | $(parent).find('#ability-description').val(''); 168 | $(parent).find('#ability-command').html(''); 169 | $(parent).find('#ability-cleanup').val(''); 170 | } 171 | 172 | function saveAbility() { 173 | let parent = $('#ability-profile'); 174 | 175 | let abilityValues = { 176 | 'name': $(parent).find('#ability-name').val(), 177 | 'platform': $(parent).find('#ability-platform').val(), 178 | 'executor': $(parent).find('#ability-executor').val(), 179 | 'tactic': $(parent).find('#ability-tactic').val(), 180 | 'technique': $(parent).find('#ability-technique-id').val(), 181 | 'attack_name': $(parent).find('#ability-technique-name').val(), 182 | 'description': $(parent).find('#ability-description').val(), 183 | 'command': btoa($(parent).find('#ability-command').val()), 184 | 'cleanup': btoa($(parent).find('#ability-cleanup').val()) 185 | }; 186 | restRequest('POST', {"index": "ac_ability_save", "key": "ability_id", "value": $(parent).find('#ability-id').val(), "data": abilityValues}, saveAbilityCallback); 187 | } 188 | 189 | function saveAbilityCallback(data) { 190 | $('p.process-status').html('

' + data + '

'); 191 | $('#reloadPage').click(function() { 192 | location.reload(); 193 | }); 194 | } 195 | 196 | function saveVariables() { 197 | let ability_id = $('#ability-profile').find('#ability-id').val(); 198 | 199 | let variables = []; 200 | 201 | $('#variable-table').find('tr.variable').each(function a() { 202 | variables.push({ 'id': $(this).find('td.name p').data('id'), 'ability_id': ability_id, 'var_name': $(this).find('td.name p').text(), 'value': btoa($(this).find('td.value input').val()) }); 203 | }); 204 | restRequest('POST', {"index": "ac_variables_save", "data": variables}, saveVariablesCallback); 205 | } 206 | 207 | function saveVariablesCallback(data) { 208 | $('p.process-status').html('

' + data + '

'); 209 | $('#reloadPage').click(function() { 210 | location.reload(); 211 | }); 212 | } 213 | 214 | function buildRequirements(encodedTest){ 215 | let matchedRequirements = atob(encodedTest).match(/#{([^}]+)}/g); 216 | if(matchedRequirements) { 217 | matchedRequirements = matchedRequirements.filter(function(e) { return e !== '#{server}' }); 218 | matchedRequirements = matchedRequirements.filter(function(e) { return e !== '#{group}' }); 219 | matchedRequirements = matchedRequirements.filter(function(e) { return e !== '#{files}' }); 220 | matchedRequirements = [...new Set(matchedRequirements)]; 221 | return matchedRequirements.map(function(val){ 222 | return val.replace(/[#{}]/g, ""); 223 | }); 224 | } 225 | return []; 226 | } 227 | 228 | function exportAllToStockpile() { 229 | $('p.process-status').html('

Exporting all Abilities to Stockpile. Please wait.

'); 230 | restRequest('POST', { "index": "ac_export_all", "data": "" }, exportStockpileCallback); 231 | } 232 | 233 | function exportOneToStockpile(){ 234 | $('p.process-status').html('

Exporting Ability to Stockpile. Please wait.

'); 235 | let ability_id = $('#ability-profile').find('#ability-id').val(); 236 | restRequest('POST', { "index": "ac_export_one", "ability_id": ability_id }, exportStockpileCallback); 237 | } 238 | 239 | function exportStockpileCallback(data) { 240 | $('p.process-status').html('

' + data + '

'); 241 | } 242 | -------------------------------------------------------------------------------- /app/atomic_caldera.py: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Name: atomic_caldera.py 3 | # Author: Conor Richard (@xenosCR) 4 | # 5 | # Description: This is the plugin version of the original Atomic-Caldera script 6 | # the purpose of this plugin is to simplify the task of importing Red Canary's 7 | # Atomic Red Team tests into MITRE's Caldera testing framework. With this plugin 8 | # you can quickly build a library of abilities that can be used to create custom 9 | # adversaries to use with Caldera. 10 | # 11 | # Instructions: See the README.md file. 12 | # 13 | # Credits: 14 | # Red Canary's Atomic Red Team - https://github.com/redcanaryco/atomic-red-team 15 | # MITRE's Caldera - https://github.com/mitre/caldera 16 | ################################################################################ 17 | 18 | import asyncio, json, logging, os, sys, re, uuid, yaml 19 | 20 | from plugins.atomiccaldera.app.artyaml import ARTyaml 21 | from app.utility.logger import Logger 22 | 23 | from pathlib import Path 24 | from base64 import b64encode, b64decode 25 | from aiohttp import web 26 | from aiohttp_jinja2 import template 27 | from stix2 import FileSystemSource 28 | from stix2 import Filter 29 | 30 | class cmdStr(str): 31 | pass 32 | 33 | def cmd_presenter(dumper, data): 34 | return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') 35 | 36 | class AtomicCaldera: 37 | 38 | def __init__(self, services, ac_data_svc): 39 | self.ac_data_svc = ac_data_svc 40 | self.data_svc = services.get('data_svc') 41 | self.auth_svc = services.get('auth_svc') 42 | self.log = Logger('atomiccaldera') 43 | self.log.debug('Atomic-Caldera Plugin Logging started.') 44 | self.get_conf() 45 | self.fs = FileSystemSource(self.ctipath) 46 | 47 | def get_conf(self): 48 | confPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../conf/artconf.yml') 49 | try: 50 | with open(confPath, 'r') as c: 51 | conf = yaml.load(c, Loader=yaml.Loader) 52 | self.ctipath = os.path.expanduser(os.path.join(conf['ctipath'], 'enterprise-attack/')) 53 | self.artpath = os.path.expanduser(conf['artpath']) 54 | self.log.debug(self.ctipath) 55 | self.log.debug(self.artpath) 56 | except: 57 | pass 58 | 59 | @template('atomiccaldera.html') 60 | async def landing(self, request): 61 | await self.auth_svc.check_permissions(request) 62 | abilities = [] 63 | tactics = [] 64 | variables = [] 65 | try: 66 | abilities = await self.ac_data_svc.explode_art_abilities() 67 | for ab in abilities: 68 | if not ab['tactic'] in tactics: 69 | tactics.append(ab['tactic']) 70 | except Exception as e: 71 | self.log.error(e) 72 | 73 | try: 74 | variables = await self.ac_data_svc.explode_art_variables() 75 | except Exception as e: 76 | self.log.error(e) 77 | return { 'abilities': json.dumps(abilities), 'tactics': tactics, 'variables': json.dumps(variables) } 78 | 79 | async def getMITREPhase(self, attackID): 80 | filter = [ 81 | Filter('type', '=', 'attack-pattern'), 82 | Filter('external_references.external_id', '=', attackID) 83 | ] 84 | result = self.fs.query(filter) 85 | if result: 86 | return result[0].kill_chain_phases[0].phase_name 87 | else: 88 | return 'unknown' 89 | 90 | async def get_atomics(self): 91 | await self.ac_data_svc.build_db(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../conf/ac.sql')) 92 | artAbilities = [] 93 | artVars = [] 94 | if os.path.exists(self.artpath): 95 | for root, dirs, files in os.walk(self.artpath): 96 | for procFile in files: 97 | fullFile = os.path.join(root, procFile) 98 | if os.path.splitext(fullFile)[-1].lower() == '.yaml': 99 | self.log.debug('Processing {}'.format(fullFile)) 100 | try: 101 | artObj = ARTyaml() 102 | except: 103 | continue 104 | with open(fullFile, 'r') as yamlFile: 105 | try: 106 | artObj.load(yamlFile) 107 | except: 108 | continue 109 | # Loop through the tests 110 | if artObj.atomicTests: 111 | for atomic in artObj.atomicTests: 112 | for platform in atomic['supported_platforms']: 113 | if platform.lower() in ['windows', 'linux', 'macos']: 114 | name = atomic['name'] 115 | description = atomic['description'] 116 | if 'command' in atomic['executor'].keys(): 117 | command = re.sub(r'x07', r'a', repr(atomic['executor']['command'])).strip() 118 | command = command.encode('utf-8').decode('unicode_escape') 119 | executor = atomic['executor']['name'] 120 | if command[0] == '\'': 121 | command = command.strip('\'') 122 | elif command[0] == '\"': 123 | command = command.strip('\"') 124 | else: 125 | command = '' 126 | executor = '' 127 | 128 | try: 129 | if command != '': 130 | checkUnique = { 'technique': int(artObj.attackTech[1:]), 131 | 'command': b64encode(command.encode('utf-8')).decode('utf-8')} 132 | except Exception as e: 133 | print(e) 134 | 135 | # Check to see if the command has been added to the database 136 | if (command != '' and not await self.ac_data_svc.check_art_ability(checkUnique)): 137 | uuidBool = True 138 | while(uuidBool): 139 | ability_id = str(uuid.uuid4()) 140 | if not await self.ac_data_svc.check_art_ability({ 'ability_id': ability_id }): 141 | uuidBool = False 142 | 143 | try: 144 | # Add the new ability to export 145 | artAbilities.append({'ability_id': ability_id, 146 | 'technique': artObj.attackTech[1:], 147 | 'name': name, 148 | 'description': description, 149 | 'tactic': await self.getMITREPhase(artObj.attackTech), 150 | 'attack_name': artObj.displayName, 151 | 'platform': platform, 152 | 'executor': executor, 153 | 'command': b64encode(command.encode('utf-8')).decode('utf-8')}) 154 | except Exception as e: 155 | print(e) 156 | 157 | if 'input_arguments' in atomic.keys(): 158 | for argument in atomic['input_arguments'].keys(): 159 | try: 160 | curVar = re.sub(r'x07', r'a', repr(atomic['input_arguments'][argument]['default'])).strip() 161 | if curVar[0] == '\'': 162 | curVar = curVar.strip('\'') 163 | elif curVar[0] == '\"': 164 | curVar = curVar.strip('\"') 165 | curVar = curVar.replace('\\\\', '\\') 166 | artVars.append({'ability_id': ability_id, 167 | 'var_name': argument, 168 | 'value': b64encode(curVar.encode('utf-8')).decode('utf-8')}) 169 | except: 170 | pass 171 | else: 172 | self.log.debug('Paths are not valid') 173 | return {'abilities': [], 'variables': []} 174 | self.log.debug('Got to the end.') 175 | return {'abilities': artAbilities, 'variables': artVars} 176 | 177 | async def export_all_to_stockpile(self, data): 178 | try: 179 | abilities = await self.ac_data_svc.explode_art_abilities() 180 | except Exception as e: 181 | self.log.error(e) 182 | try: 183 | variables = await self.ac_data_svc.explode_art_variables() 184 | except Exception as e: 185 | self.log.error(e) 186 | if await self.export_to_stockpile(abilities, variables): 187 | return 'Abilities successfully exported.' 188 | else: 189 | return 'Failed to export abilities.' 190 | 191 | async def export_one_to_stockpile(self, data): 192 | abilities = [] 193 | variables = [] 194 | ability_id = { 'ability_id': data.pop('ability_id') } 195 | try: 196 | abilities = await self.ac_data_svc.get_art_ability(ability_id) 197 | except Exception as e: 198 | self.log.error(e) 199 | try: 200 | variables = await self.ac_data_svc.get_art_variable(ability_id) 201 | except Exception as e: 202 | self.log.error(e) 203 | if await self.export_to_stockpile(abilities, variables): 204 | return 'Ability successfully exported.' 205 | else: 206 | return 'Failed to export ability.' 207 | 208 | async def export_to_stockpile(self, abilities, variables): 209 | # String representer foy PyYAML to format the command string 210 | yaml.add_representer(cmdStr, cmd_presenter) 211 | 212 | for ability in abilities: 213 | executor = ability['executor'] 214 | platform = ability['platform'] 215 | payload = '' 216 | 217 | # Fix the command formatting 218 | command = b64decode(ability['command']) 219 | command = command.decode('utf-8') 220 | if command[0] == '\'': 221 | command = command.strip('\'') 222 | elif command[0] == '\"': 223 | command = command.strip('\"') 224 | 225 | # Determin the executor 226 | # Fill in the variables 227 | for variable in variables: 228 | if variable['ability_id'] == ability['ability_id']: 229 | value = b64decode(variable['value']).decode('utf-8') 230 | if value[0] == '\'': 231 | value = value.strip('\'') 232 | elif value[0] == '\"': 233 | value = value.strip('\"') 234 | 235 | value = value.replace('\\\\', '\\') 236 | command = re.sub(r"\#{{{argName}}}".format(argName = str(variable['var_name'])), value.encode('unicode-escape').decode(), command) 237 | 238 | if (executor.lower() == 'sh' or executor.lower() == 'bash'): 239 | if platform.lower() == 'linux': 240 | platform = 'linux' 241 | elif platform.lower() == 'macos': 242 | platform = 'darwin' 243 | elif (executor.lower() == 'command_prompt' or executor.lower() == 'powershell'): 244 | if (executor.lower() == 'command_prompt'): 245 | executor = 'cmd' 246 | else: 247 | executor = 'psh' 248 | command = command.replace('\\n','\n') 249 | 250 | # Future additions 251 | parserName = '' 252 | parserProperty = '' 253 | parserScript = '' 254 | 255 | # Build the YAML data 256 | #newYaml = [{ 'id': ability['ability_id'], 257 | # 'name': ability['name'], 258 | # 'description': ability['description'], 259 | # 'tactic': ability['tactic'], 260 | # 'technique': { 'attack_id': 'T{}'.format(str(ability['technique'])), 'name': ability['attack_name'] }, 261 | # 'platforms': { platform: { executor.lower(): { 'command': cmdStr(command), 'payload': payload, 'parser': { 'name': parserName, 'property': parserProperty, 'script': parserScript }}}}}] 262 | 263 | newYaml = [{ 'id': ability['ability_id'], 264 | 'name': ability['name'], 265 | 'description': ability['description'], 266 | 'tactic': ability['tactic'], 267 | 'technique': { 'attack_id': 'T{}'.format(str(ability['technique'])), 'name': ability['attack_name'] }, 268 | 'platforms': { platform: { executor.lower(): { 'command': cmdStr(command), 'payload': payload }}}}] 269 | 270 | payloadPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../stockpile/data/payloads/') 271 | abilityPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../stockpile//data/abilities/') 272 | 273 | # Check and create payloads folder if it does not exist 274 | try: 275 | if not os.path.exists(payloadPath): 276 | os.makedirs(payloadPath) 277 | except Exception as e: 278 | self.log.error(e) 279 | return False 280 | 281 | # Write the BAT file if needed 282 | if payload != '': 283 | with open(os.path.join(payloadPath, payload), 'w') as payloadFile: 284 | payloadFile.write(batCommand) 285 | 286 | # Check and create ability folder if it does not exist 287 | try: 288 | if not os.path.exists(os.path.join(abilityPath, ability['tactic'])): 289 | os.makedirs(os.path.join(abilityPath, ability['tactic'])) 290 | except Exception as e: 291 | self.log.error(e) 292 | return False 293 | 294 | # Write the YAML file to the correct directory 295 | try: 296 | with open(os.path.join(abilityPath, ability['tactic'], '{}.yml'.format(ability['ability_id'])), 'w') as newYAMLFile: 297 | dump = yaml.dump(newYaml, default_style = None, default_flow_style = False, allow_unicode = True, encoding = None, sort_keys = False) 298 | newYAMLFile.write(dump) 299 | except Exception as e: 300 | self.log.error(e) 301 | return False 302 | return True 303 | 304 | async def get_art(self, request): 305 | self.log.debug('Landed in get_art.') 306 | try: 307 | atomics = await self.get_atomics() 308 | except Exception as e: 309 | self.log.error(e) 310 | pass 311 | return atomics 312 | 313 | async def import_art_abilities(self): 314 | try: 315 | atomics = await self.get_atomics() 316 | except Exception as e: 317 | self.log.error(e) 318 | return 'Failed to load abilities.' 319 | for ability in atomics['abilities']: 320 | await self.ac_data_svc.create_art_ability(ability) 321 | for variable in atomics['variables']: 322 | await self.ac_data_svc.create_art_variable(variable) 323 | return 'Successfully imported new abilities.' 324 | 325 | async def save_art_ability(self, data): 326 | key = data.pop('key') 327 | value = data.pop('value') 328 | updates = data.pop('data') 329 | if await self.ac_data_svc.update_art_ability(key, value, updates): 330 | return 'Updated ability: {}'.format(value) 331 | else: 332 | return 'Update failed for ability: {}'.format(value) 333 | 334 | async def save_art_variables(self, data): 335 | updates = data.pop('data') 336 | if await self.ac_data_svc.update_art_variables(updates): 337 | return 'Updated variables successfully.' 338 | else: 339 | return 'Updates to variables failed.' 340 | 341 | async def delete_all(self): 342 | abilities = [] 343 | payloadPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../stockpile/data/payloads/') 344 | abilityPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../stockpile/data/abilities/') 345 | try: 346 | abilities = await self.ac_data_svc.explode_art_abilities() 347 | except Exception as e: 348 | self.log.error(e) 349 | 350 | for ability in abilities: 351 | if os.path.exists(os.path.join(abilityPath, ability['tactic'], '{}.yml'.format(ability['ability_id']))): 352 | os.remove(os.path.join(abilityPath, ability['tactic'], '{}.yml'.format(ability['ability_id']))) 353 | if os.path.exists(os.path.join(payloadPath, '{}.bat'.format(ability['ability_id']))): 354 | os.remove(os.path.join(payloadPath, '{}.bat'.format(ability['ability_id']))) 355 | status = await self.ac_data_svc.delete_all() 356 | await self.ac_data_svc.build_db(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../conf/ac.sql')) 357 | return status 358 | 359 | 360 | async def rest_api(self, request): 361 | self.log.debug('Starting Rest call.') 362 | await self.auth_svc.check_permissions(request) 363 | data = dict(await request.json()) 364 | index = data.pop('index') 365 | self.log.debug('Index: {}'.format(index)) 366 | 367 | options = dict( 368 | PUT=dict( 369 | ac_ability=lambda d: self.import_art_abilities(**d) 370 | ), 371 | POST=dict( 372 | ac_ability=lambda d: self.ac_data_svc.explode_art_abilities(**d), 373 | ac_ability_save=lambda d: self.save_art_ability(data=d), 374 | ac_variables_save=lambda d: self.save_art_variables(data=d), 375 | ac_export_all=lambda d: self.export_all_to_stockpile(**d), 376 | ac_export_one=lambda d: self.export_one_to_stockpile(data=d) 377 | ), 378 | DELETE=dict( 379 | delete_all=lambda d: self.delete_all(**d) 380 | ) 381 | ) 382 | try: 383 | output = await options[request.method][index](data) 384 | except Exception as e: 385 | self.log.debug('Stopped at api call.') 386 | self.log.error(e) 387 | return web.json_response(output) 388 | 389 | -------------------------------------------------------------------------------- /legacy/Atomic-Caldera.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | ############################################################################### 4 | # Name: Atomic-Caldera.py 5 | # Author: Conor Richard (@xenosCR) 6 | # 7 | # Description: This script was written to convert the YAML files in 8 | # Red Canarie's Atomic Red Team libary to a format to the YAML format that 9 | # MITRE's Caldera Stockpile plugin can consume nativly. 10 | # 11 | # This script will loop through all atomic tests in the provided path and 12 | # extract each test, assign it a UID and save it to a new YAML file in a 13 | # categorized abiltiy folder. It will also generate a CSV file to catalog 14 | # the converted techniques. 15 | # 16 | # The CSV catalog file serves two purposes: 17 | # 1. A helpful list to aid in the building of Calera Adversaries/test. 18 | # 2. The CSV file is checked to ensure that tests are not duplicated by 19 | # checking the MITRE ATT&CK ID and Command combination. 20 | # 21 | # Known Issue(s): 22 | # 1. Some tests from Red Canay's Atomic Red Team are very manual. Due to this, 23 | # those tests are not converted automatically by this script. This script 24 | # provides best effort to automatically convert the majority of tests. 25 | # 2. Some of the manual tests still slip by, you will need to spot check 26 | # converted files before relying on them for testing. Sorry. 27 | # 28 | # Requirements: 29 | # 1. Must have a local copy of Red Canary Atomic Red Team. 30 | # 2. Must have a local copy of MITRE's CTI databse. 31 | # 3. The following python libraries are required: 32 | # a. yaml 33 | # b. stix2 34 | # 35 | # Credits: 36 | # Red Canary's Atomic Red Team - https://github.com/redcanaryco/atomic-red-team 37 | # MITRE's Caldera - https://github.com/mitre/caldera 38 | ############################################################################### 39 | 40 | import argparse, collections, csv, logging, os, sys, re, uuid, yaml 41 | from stix2 import FileSystemSource 42 | from stix2 import Filter 43 | 44 | class cmdStr(str): 45 | pass 46 | 47 | def cmd_presenter(dumper, data): 48 | return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') 49 | 50 | def getMITREPhase(fs, attackID): 51 | filter = [ 52 | Filter('type', '=', 'attack-pattern'), 53 | Filter('external_references.external_id', '=', attackID) 54 | ] 55 | result = fs.query(filter) 56 | if result: 57 | return result[0].kill_chain_phases[0].phase_name 58 | else: 59 | return None 60 | 61 | def checkCSVPath(csvPath): 62 | if os.path.exists(csvPath): 63 | try: 64 | with open(csvPath, 'r') as csvFile: 65 | line = csvFile.readline() 66 | except: 67 | logging.debug('The provided path to the catalog CSV file is invalid or the CSV file is corrupted: {}'.format(csvPath)) 68 | return False 69 | if not line == 'attackUUID,attackID,origCommand,command\n': 70 | logging.debug('The provided path to the catalog CSV file is invalid or the CSV file is corrupted: {}'.format(csvPath)) 71 | return False 72 | else: 73 | logging.debug('The provided path to the CSV file has been validated: {}'.format(csvPath)) 74 | return True 75 | else: 76 | logging.debug('The catalog CSV fle does not exist, it will be created.') 77 | return True 78 | 79 | def checkCTIPath(ctiPath): 80 | if not (os.path.exists(ctiPath) and os.path.exists("{ctiPath}/enterprise-attack/".format(ctiPath = ctiPath))): 81 | logging.error('The provided path to the MITRE CTI database is incorrect or corrupt.') 82 | return False 83 | else: 84 | logging.debug('The provided CTI path is: {}'.format(ctiPath)) 85 | return True 86 | 87 | def checkOutputDir(fileoutdir): 88 | if os.path.exists(fileoutdir): 89 | logging.debug('Checking fileoutdir.') 90 | abilityDir = os.path.join(fileoutdir, 'abilities/') 91 | if os.path.exists(abilityDir): 92 | logging.debug('Checking for existing YAML files in: {}.'.format(abilityDir)) 93 | fileCount = 0 94 | for root, dirs, files in os.walk(abilityDir): 95 | for procFile in files: 96 | fullFile = os.path.join(root, procFile) 97 | if os.path.splitext(fullFile)[-1].lower() == '.yml': 98 | fileCount += 1 99 | if fileCount > 0: 100 | answer = query_yes_no('The directory already contains YAML files, please be sure you are not going to duplicate files. Would you like to continue?') 101 | if answer == True: 102 | outputDir = fileoutdir 103 | else: 104 | print('You chose not to coninue. Please double-check your work and try again if needed.') 105 | raise SystemExit 106 | else: 107 | outputDir = fileoutdir 108 | else: 109 | logging.debug('No abilities directory found in provided output path') 110 | outputDir = fileoutdir 111 | else: 112 | logging.debug('The provided output directory was not provided, using current working directory.\n') 113 | outputDir = os.getcwd() 114 | return outputDir 115 | 116 | # Taken from https://stackoverflow.com/questions/3041986/apt-command-line-interface-like-yes-no-input 117 | # to save time 118 | def query_yes_no(question, default="no"): 119 | """Ask a yes/no question via raw_input() and return their answer. 120 | 121 | "question" is a string that is presented to the user. 122 | "default" is the presumed answer if the user just hits . 123 | It must be "yes" (the default), "no" or None (meaning 124 | an answer is required of the user). 125 | 126 | The "answer" return value is True for "yes" or False for "no". 127 | """ 128 | valid = {"yes": True, "y": True, "ye": True, 129 | "no": False, "n": False} 130 | if default is None: 131 | prompt = " [y/n] " 132 | elif default == "yes": 133 | prompt = " [Y/n] " 134 | elif default == "no": 135 | prompt = " [y/N] " 136 | else: 137 | raise ValueError("invalid default answer: '%s'" % default) 138 | 139 | while True: 140 | sys.stdout.write(question + prompt) 141 | choice = input().lower() 142 | if default is not None and choice == '': 143 | return valid[default] 144 | elif choice in valid: 145 | return valid[choice] 146 | else: 147 | sys.stdout.write("Please respond with 'yes' or 'no' " 148 | "(or 'y' or 'n').\n") 149 | 150 | def main(inputDir, ouptutDir, csvPath, varCsvPath, ctiPath): 151 | logging.debug('Starting main function.') 152 | # Load the MITRE library 153 | fs = FileSystemSource(os.path.join(ctiPath, 'enterprise-attack/')) 154 | 155 | # Check for an existing catalog CSV file 156 | try: 157 | csvFile = [] 158 | with open(csvPath, 'r') as oldCSVFile: 159 | reader = csv.DictReader(oldCSVFile) 160 | for line in reader: 161 | csvFile.append(line) 162 | 163 | logging.debug('Successfully loaded catalog CSV file.') 164 | except: 165 | csvFile = [] 166 | logging.debug('Catalog CSV was not loaded, creating empty list.') 167 | 168 | # Check for an existing variable CSV file 169 | try: 170 | varCsvFile = [] 171 | with open(varCsvPath, 'r') as oldVarCSVFile: 172 | reader = csv.DictReader(oldVarCSVFile) 173 | for line in reader: 174 | varCsvFile.append(line) 175 | 176 | logging.debug('Successfully loaded variable CSV file.') 177 | except: 178 | varCsvFile = [] 179 | logging.debug('Variable CSV was not loaded, creating empty list.') 180 | 181 | # Walk the directory provided as the input directory to find 182 | # the YAML files to process. 183 | # ---------------------------------------------------------- 184 | for root, dirs, files in os.walk(inputDir): 185 | for procFile in files: 186 | fullFile = os.path.join(root, procFile) 187 | if os.path.splitext(fullFile)[-1].lower() == '.yaml': 188 | print("Processing: {}".format(fullFile)) 189 | # Load the YAML file 190 | with open(fullFile, 'r') as yamlFile: 191 | try: 192 | yamlData = yaml.load(yamlFile, Loader=yaml.Loader) 193 | logging.debug('Successfully loaded: {}.'.format(fullFile)) 194 | except: 195 | logging.debug('Unable to load: {}.'.format(fullFile)) 196 | raise SystemExit('Unable to load: {}.'.format(fullFile)) 197 | 198 | # Get the description 199 | if 'display_name' in yamlData.keys(): 200 | displayName = yamlData['display_name'] 201 | #print(displayName) 202 | 203 | # Get the attackID & Kill Phase 204 | if 'attack_technique' in yamlData.keys(): 205 | attackID = yamlData['attack_technique'] 206 | tactic = getMITREPhase(fs, attackID) 207 | #print(attackID) 208 | #print(tactic) 209 | if tactic == None: 210 | tactic = 'unknown' 211 | else: 212 | logging.debug('No attack in this YAML, continuing.') 213 | continue 214 | 215 | # Get the testDescription, name, command, and executor 216 | if 'atomic_tests' in yamlData.keys(): 217 | # Loop through each Atomic test (Atomic Red Team lists multiple tests per YAML file) 218 | for atomic in yamlData['atomic_tests']: 219 | # Grab the attack name 220 | attackName = atomic['name'] 221 | # Grab the attack description 222 | testDescription = atomic['description'] 223 | # Some tests do not have a 'command' key, skip it if it does not. 224 | if 'command' in atomic['executor'].keys(): 225 | # Ensure we don't somehow use a duplicate UUID value 226 | uuidBool = True 227 | while(uuidBool): 228 | attackUUID = uuid.uuid4() 229 | if not any(line['attackUUID'] == str(attackUUID) for line in csvFile): 230 | uuidBool = False 231 | # Grab the executor name 232 | executor = atomic['executor']['name'] 233 | # grab the command and fix incorrect encoding of '\a' character sequence. 234 | command = re.sub(r'x07', r'a', repr(atomic['executor']['command'])) 235 | command = command.encode('utf-8').decode('unicode_escape') 236 | if command[0] == '\'': 237 | command = command.strip('\'') 238 | elif command[0] == '\"': 239 | command = command.strip('\"') 240 | # Initialize a new list to collect varialbe/argument values 241 | varList = [] 242 | # If input arguments exist, replace them by looping through each 243 | # and using regex replacement. 244 | if 'input_arguments' in atomic.keys(): 245 | for argument in atomic['input_arguments'].keys(): 246 | try: 247 | #curVar = str(atomic['input_arguments'][argument]['default']).encode('unicode-escape').decode() 248 | # Fix incorrect encoding of '\a' character sequence 249 | curVar = re.sub(r'x07', r'a', repr(atomic['input_arguments'][argument]['default'])) 250 | except: 251 | logging.error('Unable to encode command.') 252 | raise SystemExit 253 | varList.append({'attackUUID': attackUUID, 'attackID': attackID, 'executor': executor, 'variable': argument, 'value': curVar}) 254 | else: 255 | command = '' 256 | executor = '' 257 | 258 | origCommand = command 259 | if (executor.lower() == 'sh' or executor.lower() == 'bash'): 260 | executor = 'bash' 261 | command = command.replace('\\n','\n') 262 | elif (executor.lower() == 'command_prompt' or executor.lower() == 'powershell'): 263 | if (executor.lower() == 'command_prompt'): 264 | with open('Cmd-Wrapper.txt', mode='r') as cmdFile: 265 | cmdWrap = cmdFile.read() 266 | reCmd = re.sub("\#{command}", command, cmdWrap) 267 | command = str(reCmd) 268 | else: 269 | command = command.replace('\\n','\n') 270 | executor = 'psh' 271 | else: 272 | continue 273 | 274 | logging.debug('The command variable type is: {}'.format(type(command))) 275 | 276 | logging.debug('Collected attack name: {}'.format(attackName)) 277 | logging.debug('Collected attack executor: {}'.format(executor)) 278 | logging.debug('Collected attack command: {}'.format(command)) 279 | 280 | # Check to see if the command has been catalogued in the CSV previously 281 | if not any((line['attackID'] == attackID) and (line['origCommand'] == origCommand) for line in csvFile): 282 | logging.debug('Collecting new YAML info.') 283 | 284 | # Put the custom dictionary together that will be exported/dumped to a YAML file 285 | # the 'command' is formatted as a scalar string. 286 | newYAML = [{ 'id': str(attackUUID), 287 | 'name': displayName, 288 | 'description': '{} (Atomic Red Team)'.format(testDescription.strip().replace('\n', ' ').replace(' ', ' ')), 289 | 'tactic': tactic, 290 | 'technique': { 'attack_id': attackID, 'name': attackName }, 291 | 'executors': { executor: { 'command': cmdStr(command) }}}] 292 | 293 | logging.debug(newYAML) 294 | 295 | # Generate New YAML 296 | 297 | # Make sure the abilities directory exists and create it if it does not. 298 | try: 299 | abilityDir = os.path.join(ouptutDir, 'abilities/') 300 | if not os.path.exists(abilityDir): 301 | os.makedirs(abilityDir) 302 | logging.debug('Ability directory created: {}'.format(abilityDir)) 303 | else: 304 | logging.debug('Ability directory exists: {}'.format(abilityDir)) 305 | except: 306 | logging.error('Failed to create the abilty directory.') 307 | raise SystemExit 308 | 309 | # Make sure the tactic directory exists and create it if it does not. 310 | try: 311 | if not os.path.exists(os.path.join(abilityDir, tactic)): 312 | os.makedirs(os.path.join(abilityDir, tactic)) 313 | logging.debug('Tactic directory created: {}'.format(os.path.join(abilityDir, tactic))) 314 | else: 315 | logging.debug('Tactic directory exists: {}'.format(os.path.join(abilityDir, tactic))) 316 | except: 317 | logging.error('Tactic is empty?') 318 | raise SystemExit 319 | 320 | # Write the YAML file to the correct directory using the UUID as the name. 321 | try: 322 | with open(os.path.join(abilityDir, tactic, '{}.yml'.format(str(attackUUID))), 'w') as newYAMLFile: 323 | dump = yaml.dump(newYAML, default_style = None, default_flow_style = False, allow_unicode = True, encoding = None, sort_keys = False) 324 | newYAMLFile.write(dump) 325 | logging.debug('YAML file written: {}'.format(os.path.join(abilityDir, tactic, '{}.yml'.format(str(attackUUID))))) 326 | except Exception as e: 327 | logging.error('Error creating YAML file.') 328 | print(e) 329 | raise SystemExit 330 | 331 | # Append the newly converted ability information to the variable that will written to the CSV file 332 | newLine = { 'attackUUID': attackUUID, 'attackID': attackID, 'origCommand': origCommand, 'command': command } 333 | csvFile.append(newLine) 334 | 335 | # Append the variables to the variable CSV file 336 | if len(varList) != 0: 337 | for variable in varList: 338 | newLine = { 'attackUUID': variable['attackUUID'], 'attackID': variable['attackID'], 'executor': variable['executor'], 'variable': variable['variable'], 'value': variable['value'] } 339 | varCsvFile.append(newLine) 340 | else: 341 | logging.debug('The technique already exists.') 342 | 343 | # Write the content of CSV file to disk 344 | with open(csvPath, 'w', newline='') as newCSVFile: 345 | fieldNames = ['attackUUID', 'attackID', 'origCommand', 'command'] 346 | writer = csv.DictWriter(newCSVFile, fieldnames = fieldNames) 347 | 348 | writer.writeheader() 349 | for line in csvFile: 350 | writer.writerow(line) 351 | 352 | # Write the content of variable CSV file to disk 353 | with open(varCsvPath, 'w', newline='') as newVarCSVFile: 354 | fieldNames = ['attackUUID', 'attackID', 'executor', 'variable', 'value'] 355 | writer = csv.DictWriter(newVarCSVFile, fieldnames = fieldNames) 356 | 357 | writer.writeheader() 358 | for line in varCsvFile: 359 | writer.writerow(line) 360 | 361 | if __name__ == "__main__": 362 | # String representer foy PyYAML to format the command string 363 | yaml.add_representer(cmdStr, cmd_presenter) 364 | 365 | # Setup Debugging messages 366 | logLvl = logging.ERROR 367 | logging.basicConfig(level=logLvl, format='%(asctime)s - %(levelname)s - %(message)s') 368 | logging.debug('Debugging logging is on.') 369 | 370 | # Parse the command arguments and display a usage message if incorrect parameters are provided. 371 | parser = argparse.ArgumentParser(description = 'Convert Red Canary Attomic Red Team YAML files to Caldera Stockpile YAML files.') 372 | parser.add_argument("-i", "--inputdir", type=str, help='The Red Canary \"atomics\" folder path.') 373 | parser.add_argument("-f", "--fileoutdir", type=str, help='The directory that the converted YAML files will be stored in.') 374 | parser.add_argument("-c", "--cti", type=str, help='The path to the MITRE CTI database, ./cti is used by default.') 375 | parser.add_argument("-o", "--csv", type=str, help='The path to the CSV catalog file.') 376 | parser.add_argument("-v", "--varcsv", type=str, help='The path to the CSV file containing variables for each test.') 377 | args = parser.parse_args() 378 | 379 | # Get the CSV File location 380 | if args.csv: 381 | csvPath = args.csv 382 | else: 383 | csvPath = os.path.join(os.getcwd(), 'atomic-caldera.csv') 384 | 385 | if args.varcsv: 386 | varCsvPath = args.varcsv 387 | else: 388 | varCsvPath = os.path.join(os.getcwd(), 'atomic-variables.csv') 389 | 390 | # Get the MITRE CTI database location from the provided path or default location 391 | if args.cti: 392 | ctiPath = args.cti 393 | else: 394 | curPath = os.path.dirname(os.path.realpath(__file__)) 395 | ctiPath = os.path.join(curPath, 'cti/') 396 | 397 | # Check the output directory 398 | if args.fileoutdir: 399 | outputDir = checkOutputDir(args.fileoutdir) 400 | else: 401 | logging.debug('No output directory was provided, using the current directory.') 402 | outputDir = os.getcwd() 403 | 404 | csvPathCheck = checkCSVPath(csvPath) 405 | varCsvPathCheck = checkCSVPath(varCsvPath) 406 | ctiPathCheck = checkCTIPath(ctiPath) 407 | 408 | # Get the Red Canary Atomic Red Team repository location 409 | if args.inputdir: 410 | if os.path.exists(args.inputdir) and os.path.exists("{argPath}/T1002".format(argPath = args.inputdir)): 411 | if (csvPathCheck == True and varCsvPathCheck == True and ctiPathCheck == True): 412 | main(args.inputdir, outputDir, csvPath, varCsvPath, ctiPath) 413 | else: 414 | parser.print_help(sys.stderr) 415 | print('\n\n') 416 | logging.error('The provided arguments could not be validated.\n') 417 | raise SystemExit 418 | else: 419 | parser.print_help(sys.stderr) 420 | print('\n\n') 421 | logging.error('The provided input directory is not valid or does not exist.\n') 422 | raise SystemExit 423 | else: 424 | parser.print_help(sys.stderr) 425 | print('\n\n') 426 | logging.error('No input directory was provided.\n') 427 | raise SystemExit 428 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------