AMITT/HTML_GENERATING_CODE/test_new_code.ipynb
2021-03-22 07:46:18 -07:00

269 строки
7.2 KiB
Plaintext
Исходник Ответственный История

Этот файл содержит неоднозначные символы Юникода

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"updated ../amitt_red_framework.md\n",
"updated ../amitt_red_framework_clickable.html\n",
"updated ../amitt_blue_framework.md\n",
"updated ../amitt_blue_framework_clickable.html\n",
"updated ../phases_index.md\n",
"updated ../tactics_index.md\n",
"updated ../techniques_index.md\n",
"updated ../tasks_index.md\n",
"updated ../incidents_index.md\n",
"updated ../counters_index.md\n",
"Updating ../counters/C00194.md\n",
"updated ../metatechniques_index.md\n",
"updated ../actors_index.md\n",
"updated ../responsetype_index.md\n",
"updated ../detections_index.md\n",
"updated ../tactics_by_responsetype_table.md\n",
"updated ../metatechniques_by_responsetype_table.md\n"
]
}
],
"source": [
"import pandas as pd\n",
"from generate_amitt_ttps import Amitt\n",
"amitt = Amitt()\n",
"amitt.generate_and_write_datafiles()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dict_keys(['df_phases', 'df_techniques', 'df_tasks', 'df_incidents', 'df_counters', 'df_detections', 'df_actors', 'df_resources', 'df_responsetypes', 'df_metatechniques', 'it', 'df_tactics', 'df_techniques_per_tactic', 'df_counters_per_tactic', 'phases', 'tactics', 'techniques', 'counters', 'metatechniques', 'actors', 'resources', 'num_tactics', 'cross_counterid_techniqueid', 'cross_counterid_resourceid', 'cross_counterid_actorid'])\n"
]
},
{
"data": {
"text/plain": [
"{'TA01': 'Strategic Planning',\n",
" 'TA02': 'Objective Planning',\n",
" 'TA03': 'Develop People',\n",
" 'TA04': 'Develop Networks',\n",
" 'TA05': 'Microtargeting',\n",
" 'TA06': 'Develop Content',\n",
" 'TA07': 'Channel Selection',\n",
" 'TA08': 'Pump Priming',\n",
" 'TA09': 'Exposure',\n",
" 'TA10': 'Go Physical',\n",
" 'TA11': 'Persistence',\n",
" 'TA12': 'Measure Effectiveness'}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Check which amitt variables we can see from here\n",
"print('{}'.format(vars(amitt).keys()))\n",
"vars(amitt)['tactics']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# TEST AREA"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from generate_amitt_ttps import Amitt\n",
"amitt = Amitt()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>technique_id</th>\n",
" <th>Weight</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>C00008</td>\n",
" <td>TA01</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>C00008</td>\n",
" <td>TA06</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>C00008</td>\n",
" <td>TA08</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>C00008</td>\n",
" <td>T0006</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>C00008</td>\n",
" <td>T0009</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>C00165</td>\n",
" <td>T00025</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>126</th>\n",
" <td>C00174</td>\n",
" <td>T0001</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>C00197</td>\n",
" <td>T0007</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>C00197</td>\n",
" <td>T0011</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>C00202</td>\n",
" <td>T0025</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>263 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" id technique_id Weight\n",
"1 C00008 TA01 1\n",
"1 C00008 TA06 1\n",
"1 C00008 TA08 1\n",
"1 C00008 T0006 1\n",
"1 C00008 T0009 1\n",
".. ... ... ...\n",
"120 C00165 T00025 1\n",
"126 C00174 T0001 1\n",
"138 C00197 T0007 1\n",
"138 C00197 T0011 1\n",
"140 C00202 T0025 1\n",
"\n",
"[263 rows x 3 columns]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ct = amitt.cross_counterid_techniqueid\n",
"ct['Weight'] = 1\n",
"ct = ct[ct['technique_id'].str.len() > 0]\n",
"ct.to_csv('../visualisations/cross_counterid_techniqueid.csv', index=False, header=['Source','Target', 'Weight'])\n",
"ct"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}