{ "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--46498844-7689-4e7b-be25-b119d8401159",\n",
" "created": "2020-06-24T20:55:56.088861Z",\n",
" "modified": "2020-06-24T20:55:56.088861Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:55:56.088861Z",\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--9a4efc30-a7ac-42d0-8776-16f390a0fd44",\n",
" "created": "2020-06-24T20:56:06.779241Z",\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--75d66696-9960-4229-ba89-2caac50891b3",\n",
" "created": "2020-06-24T20:56:29.80259Z",\n",
" "modified": "2020-06-24T20:56:29.80259Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:56:29.80259Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--757ea853-138c-44e2-bb00-e78eebfaa378",\n",
" "created": "2020-06-24T20:56:43.703563Z",\n",
" "modified": "2020-06-24T20:56:43.703563Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:56:43.703563Z",\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--1752bbec-765a-4711-a304-f0e92ca902ae",\n",
" "created": "2020-06-24T21:21:07.148194Z",\n",
" "modified": "2020-06-24T21:21:07.148194Z",\n",
" "name": "Poison Ivy",\n",
" "description": "A ransomware related to ...",\n",
" "is_family": false,\n",
" "granular_markings": [\n",
" {\n",
" "marking_ref": "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44",\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--46498844-7689-4e7b-be25-b119d8401159",\n",
" "created": "2020-06-24T20:55:56.088861Z",\n",
" "modified": "2020-06-24T21:21:39.898475Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:55:56.088861Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82",\n",
" "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
" "created": "2020-06-24T20:55:56.088861Z",\n",
" "modified": "2020-06-24T21:21:43.529702Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:55:56.088861Z",\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--46498844-7689-4e7b-be25-b119d8401159",\n",
" "created": "2020-06-24T20:55:56.088861Z",\n",
" "modified": "2020-06-24T21:21:47.703212Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:55:56.088861Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44",\n",
" "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
" "created": "2020-06-24T20:55:56.088861Z",\n",
" "modified": "2020-06-24T21:21:53.287178Z",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T20:55:56.088861Z"\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
" "created": "2020-06-24T21:35:08.630228Z",\n",
" "modified": "2020-06-24T21:35:08.630228Z",\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": "2020-06-24T21:35:08.630228Z",\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--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
" "created": "2020-06-24T21:35:08.630228Z",\n",
" "modified": "2020-06-24T21:35:14.54482Z",\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": "2020-06-24T21:35:08.630228Z",\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--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
" "created": "2020-06-24T21:35:08.630228Z",\n",
" "modified": "2020-06-24T21:35:39.298138Z",\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": "2020-06-24T21:35:08.630228Z",\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--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
" "created": "2020-06-24T21:35:08.630228Z",\n",
" "modified": "2020-06-24T21:35:42.684794Z",\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": "2020-06-24T21:35:08.630228Z",\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",
"