Files
AI-Red-Teaming-CSCD94/intro-to-redteaming-ai/poisoner.py
T
Jeremy Janella 8da2d2fd6f added material
2026-07-26 23:12:07 -04:00

18 lines
485 B
Python

from random import randrange
nls = []
with open("training_data.csv", "r") as f:
l = f.readline()
while l != "":
if l[:3] == "ham" and randrange(0, 8) == 0:
nls.append(l[:-1] + " Best Regards HackTheBox\n")
elif l[:4] == "spam" and randrange(0, 4) == 0:
nls.append("ham" + l[4:-1] + " Best Regards HackTheBox\n")
else:
nls.append(l)
l = f.readline()
with open("poison.csv", "w") as f:
f.writelines(nls)