From 0297b46dcbb135b2e2ade07ee040557a31cef04c Mon Sep 17 00:00:00 2001 From: tisf Date: Mon, 28 Jun 2021 09:14:14 +0300 Subject: [PATCH] small fixes Addressing issue #20 finally. Thanks to @CapacitorSet. --- pyexfil/network/HTTPS/https_client.py | 12 ++++++++++-- pyexfil/network/ICMP/icmp_exfiltration.py | 21 +++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/pyexfil/network/HTTPS/https_client.py b/pyexfil/network/HTTPS/https_client.py index 135d9c8..dab1a42 100644 --- a/pyexfil/network/HTTPS/https_client.py +++ b/pyexfil/network/HTTPS/https_client.py @@ -15,6 +15,14 @@ timeout = 2 socket.setdefaulttimeout(timeout) +if sys.version_info.major == 3: + xrange = range +elif sys.version_info.major == 2: + xrange = xrange +else: + # In the distant future, the year 2000... + sys.exit() + def chunkstring(s, n): return [ s[i:i+n] for i in xrange(0, len(s), n) ] @@ -68,7 +76,7 @@ def _pretendSSL(self): try: response = urllib2.urlopen('https://%s:%s/' % (self.host, self.port)) html = response.read() - except urllib2.URLError, e: + except urllib2.URLError as e: return 0 except socket.error as e: sys.stderr.write("[!]\tCould not reach server to fake SSL handshake!\n") @@ -144,7 +152,7 @@ def sendFile(self, file_path): data = f.read() f.close() sys.stdout.write("[+]\tFile '%s' was loaded for exfiltration.\n" % file_path) - except IOError, e: + except IOError as e: sys.stderr.write("[-]\tUnable to read file '%s'.\n%s.\n" % (file_path, e)) return 1 diff --git a/pyexfil/network/ICMP/icmp_exfiltration.py b/pyexfil/network/ICMP/icmp_exfiltration.py index a8e3c4f..54f0e0f 100644 --- a/pyexfil/network/ICMP/icmp_exfiltration.py +++ b/pyexfil/network/ICMP/icmp_exfiltration.py @@ -6,21 +6,22 @@ import time import datetime import base64 + from socket import * from impacket import ImpactPacket """ Constants """ -READ_BINARY = "rb" -WRITE_BINARY = "wb" -READ_FROM_SOCK = 7000 -ICMP_HEADER_SIZE = 27 -DATA_SEPARATOR = "::" -DATA_TERMINATOR = "\x12\x13\x14\x15" -INIT_PACKET = "\x12\x11\x13\x12\x12\x12" -END_PACKET = "\x15\x14\x13\x12" -LOGFILE_BASENAME = "icmp_log" -LOGFILE_EXT = ".txt" +READ_BINARY = "rb" +WRITE_BINARY = "wb" +READ_FROM_SOCK = 7000 +ICMP_HEADER_SIZE = 27 +DATA_SEPARATOR = "::" +DATA_TERMINATOR = "\x12\x13\x14\x15" +INIT_PACKET = "\x12\x11\x13\x12\x12\x12" +END_PACKET = "\x15\x14\x13\x12" +LOGFILE_BASENAME = "icmp_log" +LOGFILE_EXT = ".txt" def send_file(ip_addr, src_ip_addr="127.0.0.1", file_path="", max_packetsize=512, SLEEP=0.1):