{ "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Delete this cell to re-enable tracebacks\n", "import sys\n", "ipython = get_ipython()\n", "\n", "def hide_traceback(exc_tuple=None, filename=None, tb_offset=None,\n", " exception_only=False, running_compiled_code=False):\n", " etype, value, tb = sys.exc_info()\n", " return ipython._showtraceback(etype, value, ipython.InteractiveTB.get_exception_only(etype, value))\n", "\n", "ipython.showtraceback = hide_traceback" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "# JSON output syntax highlighting\n", "from __future__ import print_function\n", "from pygments import highlight\n", "from pygments.lexers import JsonLexer, TextLexer\n", "from pygments.formatters import HtmlFormatter\n", "from IPython.display import display, HTML\n", "from IPython.core.interactiveshell import InteractiveShell\n", "\n", "InteractiveShell.ast_node_interactivity = \"all\"\n", "\n", "def json_print(inpt):\n", " string = str(inpt)\n", " formatter = HtmlFormatter()\n", " if string[0] == '{':\n", " lexer = JsonLexer()\n", " else:\n", " lexer = TextLexer()\n", " return HTML('{}'.format(\n", " formatter.get_style_defs('.highlight'),\n", " highlight(string, lexer, formatter)))\n", "\n", "globals()['print'] = json_print" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Markings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Creating Objects With Data Markings\n", "\n", "To create an object with a (predefined) TLP marking to an object, just provide it as a keyword argument to the constructor. The TLP markings can easily be imported from python-stix2." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
{\n",
" "type": "indicator",\n",
" "id": "indicator--95a71cff-fad0-4ffb-a641-8a6eaa642290",\n",
" "created": "2018-04-05T19:49:47.924Z",\n",
" "modified": "2018-04-05T19:49:47.924Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:47.924708Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "marking-definition",\n",
" "id": "marking-definition--13680b12-3d19-4b42-abe6-0d31effe5368",\n",
" "created": "2018-04-05T19:49:53.98008Z",\n",
" "definition_type": "statement",\n",
" "definition": {\n",
" "statement": "Copyright 2017, Example Corp"\n",
" }\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--7caeab49-2472-41bb-a988-2f990aea99bd",\n",
" "created": "2018-04-05T19:49:55.763Z",\n",
" "modified": "2018-04-05T19:49:55.763Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:55.763364Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "object_marking_refs": [\n",
" "marking-definition--13680b12-3d19-4b42-abe6-0d31effe5368"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--4eb21bbe-b8a9-4348-86cf-1ed52f9abdd7",\n",
" "created": "2018-04-05T19:49:57.248Z",\n",
" "modified": "2018-04-05T19:49:57.248Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:57.248658Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "malware",\n",
" "id": "malware--ef1eddbb-b5a5-47e0-b607-75b9870d8d91",\n",
" "created": "2018-04-05T19:49:59.103Z",\n",
" "modified": "2018-04-05T19:49:59.103Z",\n",
" "name": "Poison Ivy",\n",
" "description": "A ransomware related to ...",\n",
" "labels": [\n",
" "remote-access-trojan"\n",
" ],\n",
" "granular_markings": [\n",
" {\n",
" "marking_ref": "marking-definition--13680b12-3d19-4b42-abe6-0d31effe5368",\n",
" "selectors": [\n",
" "description"\n",
" ]\n",
" },\n",
" {\n",
" "marking_ref": "marking-definition--613f2e26-407d-48c7-9eca-b8e91df99dc9",\n",
" "selectors": [\n",
" "name"\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--95a71cff-fad0-4ffb-a641-8a6eaa642290",\n",
" "created": "2018-04-05T19:49:47.924Z",\n",
" "modified": "2018-04-05T19:50:03.387Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:47.924708Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "object_marking_refs": [\n",
" "marking-definition--13680b12-3d19-4b42-abe6-0d31effe5368",\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--95a71cff-fad0-4ffb-a641-8a6eaa642290",\n",
" "created": "2018-04-05T19:49:47.924Z",\n",
" "modified": "2018-04-05T19:50:05.109Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:47.924708Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--95a71cff-fad0-4ffb-a641-8a6eaa642290",\n",
" "created": "2018-04-05T19:49:47.924Z",\n",
" "modified": "2018-04-05T19:50:06.773Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:47.924708Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "object_marking_refs": [\n",
" "marking-definition--13680b12-3d19-4b42-abe6-0d31effe5368",\n",
" "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--95a71cff-fad0-4ffb-a641-8a6eaa642290",\n",
" "created": "2018-04-05T19:49:47.924Z",\n",
" "modified": "2018-04-05T19:50:08.616Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2018-04-05T19:49:47.924708Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ]\n",
"}\n",
"