From dcdbbd1bb4e6383000e1e146f07ae9a3b6b30ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 6 Nov 2018 15:28:07 +0100 Subject: [PATCH] chg: Add a script to load the API key from the file system (training VM) --- docs/tutorial/PyMISP Objects.ipynb | 28 +++++++++++++++-- docs/tutorial/PyMISP_tutorial.ipynb | 29 +++++++++++++++++ docs/tutorial/Search.ipynb | 49 ++++++++++++++++++++++++----- docs/tutorial/Usage.ipynb | 40 +++++++++++++++++++++-- 4 files changed, 133 insertions(+), 13 deletions(-) diff --git a/docs/tutorial/PyMISP Objects.ipynb b/docs/tutorial/PyMISP Objects.ipynb index 62a3476..3feaa82 100644 --- a/docs/tutorial/PyMISP Objects.ipynb +++ b/docs/tutorial/PyMISP Objects.ipynb @@ -53,6 +53,28 @@ "```" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Getting the API key (automatically generated on the trainig VM)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pathlib import Path\n", + "\n", + "api_file = Path('apikey')\n", + "if api_file.exists():\n", + " with open(api_file) as f:\n", + " misp_key = f.read().strip()\n", + " print(misp_key)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -350,7 +372,7 @@ "misp_object.add_attribute('ip', value='149.13.33.14')\n", "misp_object.add_attribute('first-seen', value='2018-04-11')\n", "misp_object.add_attribute('last-seen', value='2018-06-11')\n", - "misp_object.add_reference(circl_attr.uuid, 'related-to', 'Expanded with passive DNS entry')\n", + "misp_object.add_reference(obj_attr.uuid, 'related-to', 'Expanded with passive DNS entry')\n", "\n", "print(event.to_json())\n" ] @@ -656,7 +678,7 @@ "misp_url = 'http://127.0.0.1:8080'\n", "# Can be found in the MISP web interface under \n", "# http://+MISP_URL+/users/view/me -> Authkey\n", - "misp_key = 'yB8DMS8LkfYYpcVX8bN2v7xwDZDMp4bpW0sNqNGj'\n", + "misp_key = 'xe5okWNY2OB3O9ljR6t2cJPNsv4u1VZB0C1mKwtB'\n", "# Should PyMISP verify the MISP certificate\n", "misp_verifycert = False\n", "\n", @@ -763,7 +785,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.5" } }, "nbformat": 4, diff --git a/docs/tutorial/PyMISP_tutorial.ipynb b/docs/tutorial/PyMISP_tutorial.ipynb index 0ada011..aefff84 100644 --- a/docs/tutorial/PyMISP_tutorial.ipynb +++ b/docs/tutorial/PyMISP_tutorial.ipynb @@ -30,6 +30,35 @@ "misp_verifycert = False" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Getting the API key (automatically generated on the trainig VM)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pathlib import Path\n", + "\n", + "api_file = Path('apikey')\n", + "if api_file.exists():\n", + " with open(api_file) as f:\n", + " misp_key = f.read().strip()\n", + " print(misp_key)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Initialize PyMISP" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/docs/tutorial/Search.ipynb b/docs/tutorial/Search.ipynb index 47b420b..8d7b516 100644 --- a/docs/tutorial/Search.ipynb +++ b/docs/tutorial/Search.ipynb @@ -7,12 +7,41 @@ "outputs": [], "source": [ "# The URL of the MISP instance to connect to\n", - "misp_url = 'https:///'\n", + "misp_url = 'http://127.0.0.1:8080'\n", "# Can be found in the MISP web interface under \n", "# http://+MISP_URL+/users/view/me -> Authkey\n", - "misp_key = ''\n", + "misp_key = 'xe5okWNY2OB3O9ljR6t2cJPNsv4u1VZB0C1mKwtB'\n", "# Should PyMISP verify the MISP certificate\n", - "misp_verifycert = True" + "misp_verifycert = False" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Getting the API key (automatically generated on the trainig VM)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pathlib import Path\n", + "\n", + "api_file = Path('apikey')\n", + "if api_file.exists():\n", + " with open(api_file) as f:\n", + " misp_key = f.read().strip()\n", + " print(misp_key)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Initialize PyMISP" ] }, { @@ -48,7 +77,8 @@ "metadata": {}, "outputs": [], "source": [ - "r = misp.search_index(published=False)" + "r = misp.search_index(published=False)\n", + "print(r)" ] }, { @@ -130,7 +160,8 @@ "metadata": {}, "outputs": [], "source": [ - "r = misp.search_index(attribute='8.8.8.8')" + "r = misp.search_index(attribute='8.8.8.8')\n", + "print(r)" ] }, { @@ -162,7 +193,8 @@ "metadata": {}, "outputs": [], "source": [ - "r = misp.search_index(timestamp='1h')" + "r = misp.search_index(timestamp='1h')\n", + "print(r)" ] }, { @@ -206,7 +238,8 @@ "metadata": {}, "outputs": [], "source": [ - "r = misp.search(values='8.8.8.8')" + "r = misp.search(values='8.8.8.8')\n", + "print(r)" ] }, { @@ -357,7 +390,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.5" } }, "nbformat": 4, diff --git a/docs/tutorial/Usage.ipynb b/docs/tutorial/Usage.ipynb index 765f848..5d9fdca 100644 --- a/docs/tutorial/Usage.ipynb +++ b/docs/tutorial/Usage.ipynb @@ -25,8 +25,44 @@ "# http://+MISP_URL+/users/view/me -> Authkey\n", "misp_key = 'yB8DMS8LkfYYpcVX8bN2v7xwDZDMp4bpW0sNqNGj'\n", "# Should PyMISP verify the MISP certificate\n", - "misp_verifycert = False\n", + "misp_verifycert = False" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Getting the API key (automatically generated on the trainig VM)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pathlib import Path\n", "\n", + "api_file = Path('apikey')\n", + "if api_file.exists():\n", + " with open(api_file) as f:\n", + " misp_key = f.read().strip()\n", + " print(misp_key)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Initialize PyMISP" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "misp = PyMISP(misp_url, misp_key, misp_verifycert)" ] }, @@ -460,7 +496,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.5" } }, "nbformat": 4,