mirror of https://github.com/CIRCL/lookyloo
new: Add contacts as attachmetn to notification mail
parent
5c188d05e9
commit
53d9a6ba7a
|
@ -652,6 +652,15 @@ class Lookyloo():
|
||||||
to_return['all_emails'] = list(to_return['all_emails'])
|
to_return['all_emails'] = list(to_return['all_emails'])
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
def contacts(self, capture_uuid: str, /) -> List[Dict[str, Any]]:
|
||||||
|
capture = self.get_crawled_tree(capture_uuid)
|
||||||
|
rendered_hostnode = self.get_hostnode_from_tree(capture_uuid, capture.root_hartree.rendered_node.hostnode_uuid)
|
||||||
|
result = []
|
||||||
|
for node in reversed(rendered_hostnode.get_ancestors()):
|
||||||
|
result.append(self.takedown_details(node))
|
||||||
|
result.append(self.takedown_details(rendered_hostnode))
|
||||||
|
return result
|
||||||
|
|
||||||
def send_mail(self, capture_uuid: str, /, email: str='', comment: str='') -> None:
|
def send_mail(self, capture_uuid: str, /, email: str='', comment: str='') -> None:
|
||||||
'''Send an email notification regarding a specific capture'''
|
'''Send an email notification regarding a specific capture'''
|
||||||
if not get_config('generic', 'enable_mail_notification'):
|
if not get_config('generic', 'enable_mail_notification'):
|
||||||
|
@ -692,6 +701,11 @@ class Lookyloo():
|
||||||
sender=msg['From'].addresses[0].display_name,
|
sender=msg['From'].addresses[0].display_name,
|
||||||
)
|
)
|
||||||
msg.set_content(body)
|
msg.set_content(body)
|
||||||
|
try:
|
||||||
|
contact_for_takedown = self.contacts(capture_uuid)
|
||||||
|
msg.add_attachment(json.dumps(contact_for_takedown, indent=2), maintype='application', subtype='json', filename='contacts.json')
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.warning(f'Unable to get the contacts: {e}')
|
||||||
try:
|
try:
|
||||||
s = smtplib.SMTP(email_config['smtp_host'], email_config['smtp_port'])
|
s = smtplib.SMTP(email_config['smtp_host'], email_config['smtp_port'])
|
||||||
s.send_message(msg)
|
s.send_message(msg)
|
||||||
|
|
|
@ -486,17 +486,8 @@ class Takedown(Resource):
|
||||||
parameters: Dict = request.get_json(force=True)
|
parameters: Dict = request.get_json(force=True)
|
||||||
capture_uuid = parameters.get('capture_uuid')
|
capture_uuid = parameters.get('capture_uuid')
|
||||||
if not capture_uuid:
|
if not capture_uuid:
|
||||||
return {'error': f'Invalid UUID: {capture_uuid}'}
|
return {'error': f'Invalid request: {parameters}'}
|
||||||
|
return lookyloo.contacts(capture_uuid)
|
||||||
capture = lookyloo.get_crawled_tree(capture_uuid)
|
|
||||||
if not capture:
|
|
||||||
return {'error': f'Unknown capture {capture_uuid}'}
|
|
||||||
rendered_hostnode = lookyloo.get_hostnode_from_tree(capture_uuid, capture.root_hartree.rendered_node.hostnode_uuid)
|
|
||||||
result = []
|
|
||||||
for node in reversed(rendered_hostnode.get_ancestors()):
|
|
||||||
result.append(lookyloo.takedown_details(node))
|
|
||||||
result.append(lookyloo.takedown_details(rendered_hostnode))
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
# Admin stuff
|
# Admin stuff
|
||||||
|
|
Loading…
Reference in New Issue