mirror of https://github.com/MISP/misp-modules
Rendu projet master2 sécurité par Mathilde OUN et Vincent GINDT // Nouveau module misp de recherche google sur les urls
parent
27717c0400
commit
df3a6986ea
|
@ -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
|
Loading…
Reference in New Issue