Skip to content

Commit

Permalink
Fix gzip compression on Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Oct 26, 2024
1 parent 4644b4b commit d7e2025
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pwnlib/tubes/tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,11 @@ def upload_manually(self, data, target_path = './payload', prompt = b'$', chunk_
compressed_path = target_path + '.xz'
elif compression_mode == 'gzip':
import gzip
compressed_data = gzip.compress(data, compresslevel=9)
from six import BytesIO
with BytesIO() as f:
with gzip.GzipFile(fileobj=f, mode='wb', compresslevel=9) as g:
g.write(data)
compressed_data = f.getvalue()
compressed_path = target_path + '.gz'
else:
compressed_path = target_path
Expand Down

0 comments on commit d7e2025

Please sign in to comment.