{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true, "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": 2, "metadata": { "collapsed": true, "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\n", "from pygments.formatters import HtmlFormatter\n", "from IPython.display import HTML\n", "\n", "original_print = print\n", "\n", "def json_print(inpt):\n", " string = str(inpt)\n", " if string[0] == '{':\n", " formatter = HtmlFormatter()\n", " return HTML('{}'.format(\n", " formatter.get_style_defs('.highlight'),\n", " highlight(string, JsonLexer(), formatter)))\n", " else:\n", " original_print(inpt)\n", "\n", "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",
" "id": "indicator--409a0b15-1108-4251-8aee-a08995976561",\n",
" "created": "2017-10-04T14:42:54.685Z",\n",
" "modified": "2017-10-04T14:42:54.685Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:42:54.685184Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "marking-definition",\n",
" "id": "marking-definition--030bb5c6-c5eb-4e9c-8e7a-b9aab08ded53",\n",
" "created": "2017-10-04T14:43:04.090873Z",\n",
" "definition_type": "statement",\n",
" "definition": {\n",
" "statement": "Copyright 2017, Example Corp"\n",
" }\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--526cda4e-6745-4cd6-852f-0750c6a79784",\n",
" "created": "2017-10-04T14:43:09.586Z",\n",
" "modified": "2017-10-04T14:43:09.586Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:43:09.586133Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--030bb5c6-c5eb-4e9c-8e7a-b9aab08ded53"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--1505b789-fcd2-48ee-bea9-3b20627a4abd",\n",
" "created": "2017-10-04T14:43:20.049Z",\n",
" "modified": "2017-10-04T14:43:20.049Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:43:20.049166Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "malware",\n",
" "id": "malware--9f8970eb-b398-41b6-b8c8-8a607ad3a2c5",\n",
" "created": "2017-10-04T14:43:26.129Z",\n",
" "modified": "2017-10-04T14:43:26.129Z",\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--030bb5c6-c5eb-4e9c-8e7a-b9aab08ded53",\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--409a0b15-1108-4251-8aee-a08995976561",\n",
" "created": "2017-10-04T14:42:54.685Z",\n",
" "modified": "2017-10-04T15:03:46.599Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:42:54.685184Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82",\n",
" "marking-definition--030bb5c6-c5eb-4e9c-8e7a-b9aab08ded53"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--409a0b15-1108-4251-8aee-a08995976561",\n",
" "created": "2017-10-04T14:42:54.685Z",\n",
" "modified": "2017-10-04T15:03:54.290Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:42:54.685184Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--409a0b15-1108-4251-8aee-a08995976561",\n",
" "created": "2017-10-04T14:42:54.685Z",\n",
" "modified": "2017-10-04T15:04:04.218Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:42:54.685184Z",\n",
" "object_marking_refs": [\n",
" "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da",\n",
" "marking-definition--030bb5c6-c5eb-4e9c-8e7a-b9aab08ded53"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "indicator",\n",
" "id": "indicator--409a0b15-1108-4251-8aee-a08995976561",\n",
" "created": "2017-10-04T14:42:54.685Z",\n",
" "modified": "2017-10-04T14:54:39.331Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-10-04T14:42:54.685184Z"\n",
"}\n",
"