42-eicar-street / build_pickles.py
mcpotato's picture
mcpotato HF staff
feat: build dangerous pickle testing `.dat`
3e749e1
raw
history blame contribute delete
304 Bytes
import pickle
class MaliciousInject:
def __init__(self, src: str):
self._src = src
def __reduce__(self):
return eval, (f"exec('''{self._src}''')",), None, None, None
content = MaliciousInject("print('hack3d')")
with open('danger.dat', 'wb') as f:
pickle.dump(content, f)