{ "cells": [ { "cell_type": "code", "execution_count": 1, "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", " value.__cause__ = None # suppress chained exceptions\n", " return ipython._showtraceback(etype, value, ipython.InteractiveTB.get_exception_only(etype, value))\n", "\n", "ipython.showtraceback = hide_traceback" ] }, { "cell_type": "code", "execution_count": 2, "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": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
" "created": "2021-04-09T13:59:48.911595Z",\n",
" "modified": "2021-04-09T13:59:48.911595Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:48.911595Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "marking-definition",\n",
" "spec_version": "2.1",\n",
" "id": "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d",\n",
" "created": "2021-04-09T13:59:50.587649Z",\n",
" "definition_type": "statement",\n",
" "definition": {\n",
" "statement": "Copyright 2017, Example Corp"\n",
" }\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--91ed23a6-c5f0-4b16-8369-64cf39f974bf",\n",
" "created": "2021-04-09T13:59:52.602254Z",\n",
" "modified": "2021-04-09T13:59:52.602254Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:52.602254Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--42ae262e-4839-4c1a-a50a-3a6690623a9d",\n",
" "created": "2021-04-09T13:59:54.207797Z",\n",
" "modified": "2021-04-09T13:59:54.207797Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:54.207797Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "malware",\n",
" "spec_version": "2.1",\n",
" "id": "malware--2658ac6a-44e9-44ea-8c8a-d67abae4d0d5",\n",
" "created": "2021-04-09T13:59:56.556801Z",\n",
" "modified": "2021-04-09T13:59:56.556801Z",\n",
" "name": "Poison Ivy",\n",
" "description": "A ransomware related to ...",\n",
" "is_family": false,\n",
" "granular_markings": [\n",
" {\n",
" "marking_ref": "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d",\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",
" "spec_version": "2.1",\n",
" "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
" "created": "2021-04-09T13:59:48.911595Z",\n",
" "modified": "2021-04-09T14:00:01.165749Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:48.911595Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d",\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
" "created": "2021-04-09T13:59:48.911595Z",\n",
" "modified": "2021-04-09T14:00:03.00911Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:48.911595Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
" "created": "2021-04-09T13:59:48.911595Z",\n",
" "modified": "2021-04-09T14:00:04.531083Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:48.911595Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da",\n",
" "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
" "created": "2021-04-09T13:59:48.911595Z",\n",
" "modified": "2021-04-09T14:00:06.512465Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T13:59:48.911595Z"\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
" "created": "2021-04-09T14:02:31.991141Z",\n",
" "modified": "2021-04-09T14:02:31.991141Z",\n",
" "description": "Una descripcion sobre este indicador",\n",
" "indicator_types": [\n",
" "malware"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T14:02:31.991141Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ],\n",
" "granular_markings": [\n",
" {\n",
" "lang": "es",\n",
" "selectors": [\n",
" "description"\n",
" ]\n",
" },\n",
" {\n",
" "marking_ref": "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da",\n",
" "selectors": [\n",
" "description"\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"
['marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da', 'es']\n",
"
['marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da']\n",
"
['es']\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
" "created": "2021-04-09T14:02:31.991141Z",\n",
" "modified": "2021-04-09T14:03:11.817032Z",\n",
" "description": "Una descripcion sobre este indicador",\n",
" "indicator_types": [\n",
" "malware"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T14:02:31.991141Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
" "created": "2021-04-09T14:02:31.991141Z",\n",
" "modified": "2021-04-09T14:03:24.701927Z",\n",
" "description": "Una descripcion sobre este indicador",\n",
" "indicator_types": [\n",
" "malware"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T14:02:31.991141Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ],\n",
" "granular_markings": [\n",
" {\n",
" "lang": "es",\n",
" "selectors": [\n",
" "description"\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
" "created": "2021-04-09T14:02:31.991141Z",\n",
" "modified": "2021-04-09T14:03:29.751985Z",\n",
" "description": "Una descripcion sobre este indicador",\n",
" "indicator_types": [\n",
" "malware"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2021-04-09T14:02:31.991141Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ],\n",
" "granular_markings": [\n",
" {\n",
" "marking_ref": "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da",\n",
" "selectors": [\n",
" "description"\n",
" ]\n",
" }\n",
" ]\n",
"}\n",
"