{ "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", " 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\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": [ "## Creating STIX Content" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Creating STIX Domain Objects\n", "\n", "To create a STIX object, provide keyword arguments to the type's constructor:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
{\n",
" "type": "indicator",\n",
" "id": "indicator--2f3d4926-163d-4aef-bcd2-19dea96916ae",\n",
" "created": "2019-05-13T13:14:48.509Z",\n",
" "modified": "2019-05-13T13:14:48.509Z",\n",
" "name": "File hash for malware variant",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2019-05-13T13:14:48.509629Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "malware",\n",
" "id": "malware--1f2aba70-f0ae-49cd-9267-6fcb1e43be67",\n",
" "created": "2019-05-13T13:15:04.698Z",\n",
" "modified": "2019-05-13T13:15:04.698Z",\n",
" "name": "Poison Ivy",\n",
" "labels": [\n",
" "remote-access-trojan"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "relationship",\n",
" "id": "relationship--80c174fa-36d1-47c2-9a9d-ce0c636bedcc",\n",
" "created": "2019-05-13T13:15:13.152Z",\n",
" "modified": "2019-05-13T13:15:13.152Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--2f3d4926-163d-4aef-bcd2-19dea96916ae",\n",
" "target_ref": "malware--1f2aba70-f0ae-49cd-9267-6fcb1e43be67"\n",
"}\n",
"
{\n",
" "type": "relationship",\n",
" "id": "relationship--47395d23-dedd-45d4-8db1-c9ffaf44493d",\n",
" "created": "2019-05-13T13:15:16.566Z",\n",
" "modified": "2019-05-13T13:15:16.566Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--2f3d4926-163d-4aef-bcd2-19dea96916ae",\n",
" "target_ref": "malware--1f2aba70-f0ae-49cd-9267-6fcb1e43be67"\n",
"}\n",
"
{\n",
" "type": "bundle",\n",
" "id": "bundle--388c9b2c-936c-420a-baa5-04f48d682a01",\n",
" "spec_version": "2.0",\n",
" "objects": [\n",
" {\n",
" "type": "indicator",\n",
" "id": "indicator--2f3d4926-163d-4aef-bcd2-19dea96916ae",\n",
" "created": "2019-05-13T13:14:48.509Z",\n",
" "modified": "2019-05-13T13:14:48.509Z",\n",
" "name": "File hash for malware variant",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2019-05-13T13:14:48.509629Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ]\n",
" },\n",
" {\n",
" "type": "malware",\n",
" "id": "malware--1f2aba70-f0ae-49cd-9267-6fcb1e43be67",\n",
" "created": "2019-05-13T13:15:04.698Z",\n",
" "modified": "2019-05-13T13:15:04.698Z",\n",
" "name": "Poison Ivy",\n",
" "labels": [\n",
" "remote-access-trojan"\n",
" ]\n",
" },\n",
" {\n",
" "type": "relationship",\n",
" "id": "relationship--80c174fa-36d1-47c2-9a9d-ce0c636bedcc",\n",
" "created": "2019-05-13T13:15:13.152Z",\n",
" "modified": "2019-05-13T13:15:13.152Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--2f3d4926-163d-4aef-bcd2-19dea96916ae",\n",
" "target_ref": "malware--1f2aba70-f0ae-49cd-9267-6fcb1e43be67"\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "type": "ipv4-addr",\n",
" "value": "177.60.40.7",\n",
" "resolves_to_refs": [\n",
" "1",\n",
" "2"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "ipv4-addr",\n",
" "value": "177.60.40.7",\n",
" "resolves_to_refs": [\n",
" "1",\n",
" "2"\n",
" ]\n",
"}\n",
"