"""Copy wheels/six-1.17.0-*.whl to wheels-evil/ with one line appended to six.py (same name and version, different bytes).""" import zipfile, glob src = glob.glob("wheels/*.whl")[0]; dst = "wheels-evil/" + src.split("/")[-1] zi = zipfile.ZipFile(src); zo = zipfile.ZipFile(dst, "w", zipfile.ZIP_DEFLATED) for i in zi.infolist(): data = zi.read(i.filename) if i.filename == "six.py": data += b"\nPLANTED_BY_ATTACKER = True\n" zo.writestr(i, data) zo.close()