{ "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": [ "## 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--dbcbd659-c927-4f9a-994f-0a2632274394",\n",
" "created": "2017-09-26T23:33:39.829Z",\n",
" "modified": "2017-09-26T23:33:39.829Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "name": "File hash for malware variant",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-09-26T23:33:39.829952Z"\n",
"}\n",
"
{\n",
" "type": "malware",\n",
" "id": "malware--d7fd675d-94eb-4d95-b0bc-b3c5e28e8ed2",\n",
" "created": "2017-09-26T23:33:56.908Z",\n",
" "modified": "2017-09-26T23:33:56.908Z",\n",
" "name": "Poison Ivy",\n",
" "labels": [\n",
" "remote-access-trojan"\n",
" ]\n",
"}\n",
"
{\n",
" "type": "relationship",\n",
" "id": "relationship--637aa3b1-d4b8-4bc4-85e7-77cc82b198a3",\n",
" "created": "2017-09-26T23:34:01.765Z",\n",
" "modified": "2017-09-26T23:34:01.765Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--dbcbd659-c927-4f9a-994f-0a2632274394",\n",
" "target_ref": "malware--d7fd675d-94eb-4d95-b0bc-b3c5e28e8ed2"\n",
"}\n",
"
{\n",
" "type": "relationship",\n",
" "id": "relationship--70fe77c2-ab00-4181-a2dc-fe5567d971ca",\n",
" "created": "2017-09-26T23:34:03.923Z",\n",
" "modified": "2017-09-26T23:34:03.923Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--dbcbd659-c927-4f9a-994f-0a2632274394",\n",
" "target_ref": "malware--d7fd675d-94eb-4d95-b0bc-b3c5e28e8ed2"\n",
"}\n",
"
{\n",
" "type": "bundle",\n",
" "id": "bundle--2536c43d-c874-418e-886c-20a22120d8cb",\n",
" "spec_version": "2.0",\n",
" "objects": [\n",
" {\n",
" "type": "indicator",\n",
" "id": "indicator--dbcbd659-c927-4f9a-994f-0a2632274394",\n",
" "created": "2017-09-26T23:33:39.829Z",\n",
" "modified": "2017-09-26T23:33:39.829Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ],\n",
" "name": "File hash for malware variant",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "valid_from": "2017-09-26T23:33:39.829952Z"\n",
" },\n",
" {\n",
" "type": "malware",\n",
" "id": "malware--d7fd675d-94eb-4d95-b0bc-b3c5e28e8ed2",\n",
" "created": "2017-09-26T23:33:56.908Z",\n",
" "modified": "2017-09-26T23:33:56.908Z",\n",
" "name": "Poison Ivy",\n",
" "labels": [\n",
" "remote-access-trojan"\n",
" ]\n",
" },\n",
" {\n",
" "type": "relationship",\n",
" "id": "relationship--637aa3b1-d4b8-4bc4-85e7-77cc82b198a3",\n",
" "created": "2017-09-26T23:34:01.765Z",\n",
" "modified": "2017-09-26T23:34:01.765Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--dbcbd659-c927-4f9a-994f-0a2632274394",\n",
" "target_ref": "malware--d7fd675d-94eb-4d95-b0bc-b3c5e28e8ed2"\n",
" }\n",
" ]\n",
"}\n",
"