From df3a6986ea5f2ba4ac73656037115e62c9c8c6d5 Mon Sep 17 00:00:00 2001 From: Mathilde Oun et Vincent Gindt Date: Fri, 21 Feb 2020 12:05:41 +0100 Subject: [PATCH] =?UTF-8?q?Rendu=20projet=20master2=20s=C3=A9curit=C3=A9?= =?UTF-8?q?=20par=20Mathilde=20OUN=20et=20Vincent=20GINDT=20//=20Nouveau?= =?UTF-8?q?=20module=20misp=20de=20recherche=20google=20sur=20les=20urls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/expansion/google_search.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 misp_modules/modules/expansion/google_search.py diff --git a/misp_modules/modules/expansion/google_search.py b/misp_modules/modules/expansion/google_search.py new file mode 100644 index 0000000..2e8f2a8 --- /dev/null +++ b/misp_modules/modules/expansion/google_search.py @@ -0,0 +1,37 @@ +import json +import requests +try: + from google import google +except ImportError: + print("GoogleAPI not installed. Command : pip install git+https://github.com/abenassi/Google-Search-API") + +misperrors = {'error': 'Error'} +mispattributes = {'input': ['url'], 'output': ['text']} +moduleinfo = {'author': 'Oun & Gindt', 'description': 'An expansion hover module to expand google search information about an URL', 'module-type': ['hover']} + + +def handler(q=False): + if q is False: + return False + request = json.loads(q) + if request.get('url'): + toquery = request['url'] + else: + misperrors['error'] = "Unsupported attributes type" + return misperrors + + num_page = 1 + res = "" + search_results = google.search(request['url'], num_page) + for i in range(3): + res += "("+str(i+1)+")" + '\t' + res += json.dumps(search_results[i].description, ensure_ascii=False) + res += '\n\n' + return {'results': [{'types': mispattributes['output'], 'values':res}]} + +def introspection(): + return mispattributes + + +def version(): + return moduleinfo