Skip to content

Commit 9191f13

Browse files
committed
Fix gzip compression on Python 2
1 parent 4644b4b commit 9191f13

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pwnlib/tubes/tube.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,11 @@ def upload_manually(self, data, target_path = './payload', prompt = b'$', chunk_
11681168
compressed_path = target_path + '.xz'
11691169
elif compression_mode == 'gzip':
11701170
import gzip
1171-
compressed_data = gzip.compress(data, compresslevel=9)
1171+
from six import BytesIO
1172+
f = BytesIO()
1173+
with gzip.GzipFile(fileobj=f, mode='wb', compresslevel=9) as g:
1174+
g.write(data)
1175+
compressed_data = f.getvalue()
11721176
compressed_path = target_path + '.gz'
11731177
else:
11741178
compressed_path = target_path

0 commit comments

Comments
 (0)