# Serialize the malicious object payload = pickle.dumps(Malicious()) # Save it to a file with open("malicious.pkl", "wb") as f: f.write(payload)