Skip to content

Commit 372abc1

Browse files
Merge pull request #4 from ProjectZeroDays/add-huggingface-deployment
Automate HuggingFace Codespace deployment
2 parents 89b7987 + d2d2e43 commit 372abc1

File tree

9 files changed

+223
-1
lines changed

9 files changed

+223
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ jobs:
4040
- name: Build macOS exploit
4141
run: |
4242
./scripts/macos_deploy.sh
43+
44+
- name: Deploy Hugging Face Codespace
45+
run: |
46+
./scripts/deploy_huggingface.sh

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#### * 8.9. [Nagios](#nagios)
4646
### 9. [Running the Python-based GUI](#running-python-gui)
4747
### 10. [Deploying the GUI on Hugging Face Code Spaces](#deploying-huggingface)
48+
### 11. [Automated Hugging Face Codespace Deployment](#automated-huggingface-deployment)
4849

4950
### __ __
5051

@@ -616,6 +617,26 @@ To deploy the Python-based GUI on Hugging Face Code Spaces, follow these steps:
616617

617618
The GUI will open in your Hugging Face Code Space, allowing you to monitor and control exploits for various operating systems. The GUI includes features for viewing logs, managing exploits, and secure communication.
618619

620+
# Automated Hugging Face Codespace Deployment
621+
622+
To automate the deployment of the Python-based GUI on Hugging Face Code Spaces, follow these steps:
623+
624+
1. Ensure you have a Hugging Face account and have set up a Code Space.
625+
2. Clone the repository to your Hugging Face Code Space:
626+
627+
```bash
628+
git clone https://github.com/ProjectZeroDays/zero-click-exploits.git
629+
cd zero-click-exploits
630+
```
631+
632+
3. Run the `deploy_huggingface.sh` script:
633+
634+
```bash
635+
./scripts/deploy_huggingface.sh
636+
```
637+
638+
The script will handle the installation of dependencies, setting up environment variables, and running the GUI. The GUI will open in your Hugging Face Code Space, allowing you to monitor and control exploits for various operating systems. The GUI includes features for viewing logs, managing exploits, and secure communication.
639+
619640

620641
### __ __
621642

infra/k8s/deployment.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: huggingface-deployment
5+
labels:
6+
app: huggingface
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: huggingface
12+
template:
13+
metadata:
14+
labels:
15+
app: huggingface
16+
spec:
17+
containers:
18+
- name: huggingface-container
19+
image: huggingface/image:latest
20+
ports:
21+
- containerPort: 80
22+
env:
23+
- name: HUGGINGFACE_API_KEY
24+
valueFrom:
25+
secretKeyRef:
26+
name: huggingface-secrets
27+
key: api-key
28+
- name: HUGGINGFACE_MODEL
29+
value: "model-name"
30+
- name: HUGGINGFACE_ENV
31+
value: "production"

infra/test_deployment.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Function to test Hugging Face deployment
4+
test_huggingface_deployment() {
5+
echo "Testing Hugging Face deployment..."
6+
7+
# Check if the GUI is running
8+
if pgrep -f "python3 src/gui.py" > /dev/null; then
9+
echo "Hugging Face GUI is running."
10+
else
11+
echo "Hugging Face GUI is not running."
12+
exit 1
13+
fi
14+
15+
# Check if the required environment variables are set
16+
if [ -z "$HUGGINGFACE_API_KEY" ] || [ -z "$HUGGINGFACE_PROJECT_NAME" ]; then
17+
echo "Hugging Face environment variables are not set."
18+
exit 1
19+
fi
20+
21+
echo "Hugging Face deployment test passed."
22+
}
23+
24+
# Main function to execute all tests
25+
main() {
26+
test_huggingface_deployment
27+
}
28+
29+
# Execute the main function
30+
main
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: huggingface-deployment
5+
labels:
6+
app: huggingface
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: huggingface
12+
template:
13+
metadata:
14+
labels:
15+
app: huggingface
16+
spec:
17+
containers:
18+
- name: huggingface-container
19+
image: huggingface/image:latest
20+
ports:
21+
- containerPort: 80
22+
env:
23+
- name: HUGGINGFACE_API_KEY
24+
valueFrom:
25+
secretKeyRef:
26+
name: huggingface-secrets
27+
key: api-key
28+
- name: HUGGINGFACE_PROJECT_NAME
29+
value: "your_project_name"
30+
- name: HUGGINGFACE_ENV
31+
value: "production"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: huggingface-deployment
5+
labels:
6+
app: huggingface
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: huggingface
12+
template:
13+
metadata:
14+
labels:
15+
app: huggingface
16+
spec:
17+
containers:
18+
- name: huggingface-container
19+
image: huggingface/image:latest
20+
ports:
21+
- containerPort: 80
22+
env:
23+
- name: HUGGINGFACE_API_KEY
24+
valueFrom:
25+
secretKeyRef:
26+
name: huggingface-secrets
27+
key: api-key
28+
- name: HUGGINGFACE_PROJECT_NAME
29+
value: "your_project_name"
30+
- name: HUGGINGFACE_ENV
31+
value: "production"

scripts/deploy_huggingface.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Function to install dependencies
4+
install_dependencies() {
5+
echo "Installing dependencies..."
6+
pip install -r requirements.txt
7+
}
8+
9+
# Function to run the GUI
10+
run_gui() {
11+
echo "Running the GUI..."
12+
python3 src/gui.py
13+
}
14+
15+
# Function to handle environment variables for Hugging Face deployment
16+
handle_env_variables() {
17+
echo "Setting up environment variables..."
18+
export HUGGINGFACE_API_KEY="your_huggingface_api_key"
19+
export HUGGINGFACE_PROJECT_NAME="your_project_name"
20+
}
21+
22+
# Main function to execute all steps
23+
main() {
24+
handle_env_variables
25+
install_dependencies
26+
run_gui
27+
}
28+
29+
# Execute the main function
30+
main

src/gui.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tkinter.simpledialog import askstring
1313
import requests
1414
from project_red_sword import Chatbot
15+
from ai_model import AIDeploymentModel
1516

1617
class C2Dashboard:
1718
def __init__(self, root):
@@ -23,6 +24,7 @@ def __init__(self, root):
2324
self.user_role = None
2425
self.session_active = False
2526
self.chatbot = Chatbot()
27+
self.ai_model = AIDeploymentModel("path/to/pretrained/model.h5")
2628

2729
def create_widgets(self):
2830
self.tab_control = ttk.Notebook(self.root)
@@ -32,12 +34,14 @@ def create_widgets(self):
3234
self.communication_tab = ttk.Frame(self.tab_control)
3335
self.device_control_tab = ttk.Frame(self.tab_control)
3436
self.target_scanning_tab = ttk.Frame(self.tab_control)
37+
self.ai_model_tab = ttk.Frame(self.tab_control)
3538

3639
self.tab_control.add(self.logs_tab, text="Logs")
3740
self.tab_control.add(self.exploits_tab, text="Exploits")
3841
self.tab_control.add(self.communication_tab, text="Communication")
3942
self.tab_control.add(self.device_control_tab, text="Device Control")
4043
self.tab_control.add(self.target_scanning_tab, text="Target Scanning")
44+
self.tab_control.add(self.ai_model_tab, text="AI Model")
4145

4246
self.tab_control.pack(expand=1, fill="both")
4347

@@ -46,6 +50,7 @@ def create_widgets(self):
4650
self.create_communication_tab()
4751
self.create_device_control_tab()
4852
self.create_target_scanning_tab()
53+
self.create_ai_model_tab()
4954

5055
def create_logs_tab(self):
5156
self.logs_text = tk.Text(self.logs_tab, wrap="word")
@@ -85,6 +90,16 @@ def create_target_scanning_tab(self):
8590
self.scan_targets_button = ttk.Button(self.target_scanning_tab, text="Scan Targets", command=self.scan_targets)
8691
self.scan_targets_button.pack()
8792

93+
def create_ai_model_tab(self):
94+
self.ai_model_input_text = tk.Text(self.ai_model_tab, wrap="word")
95+
self.ai_model_input_text.pack(expand=1, fill="both")
96+
97+
self.predict_button = ttk.Button(self.ai_model_tab, text="Predict", command=self.predict)
98+
self.predict_button.pack()
99+
100+
self.ai_model_output_text = tk.Text(self.ai_model_tab, wrap="word")
101+
self.ai_model_output_text.pack(expand=1, fill="both")
102+
88103
def refresh_logs(self):
89104
self.logs_text.delete(1.0, tk.END)
90105
with open("logs/deployment.log", "r") as f:
@@ -143,6 +158,12 @@ def scan_targets(self):
143158
except shodan.APIError as e:
144159
messagebox.showerror("Shodan Error", str(e))
145160

161+
def predict(self):
162+
input_data = self.ai_model_input_text.get(1.0, tk.END).strip().split('\n')
163+
predictions = self.ai_model.predict(input_data)
164+
self.ai_model_output_text.delete(1.0, tk.END)
165+
self.ai_model_output_text.insert(tk.END, str(predictions))
166+
146167
def setup_logging(self):
147168
logging.basicConfig(filename='logs/gui.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
148169

@@ -223,6 +244,14 @@ def send_chatbot_command(self, event):
223244
self.chatbot_text.insert(tk.END, f"Chatbot: {response}\n")
224245
self.chatbot_entry.delete(0, tk.END)
225246

247+
def spoof_sms(self, phone_number, message):
248+
# Implement SMS spoofing logic here
249+
pass
250+
251+
def spoof_email(self, email_address, subject, message):
252+
# Implement email spoofing logic here
253+
pass
254+
226255
if __name__ == "__main__":
227256
root = tk.Tk()
228257
app = C2Dashboard(root)

src/huggingface_panel.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,22 @@ def save_user_preferences(self):
136136

137137
def deploy_on_huggingface(self):
138138
# Implement deployment logic for Hugging Face Code Spaces
139-
pass
139+
self.handle_env_variables()
140+
self.install_dependencies()
141+
self.run_gui()
142+
143+
def handle_env_variables(self):
144+
print("Setting up environment variables...")
145+
os.environ["HUGGINGFACE_API_KEY"] = "your_huggingface_api_key"
146+
os.environ["HUGGINGFACE_PROJECT_NAME"] = "your_project_name"
147+
148+
def install_dependencies(self):
149+
print("Installing dependencies...")
150+
subprocess.run(["pip", "install", "-r", "requirements.txt"])
151+
152+
def run_gui(self):
153+
print("Running the GUI...")
154+
subprocess.run(["python3", "src/gui.py"])
140155

141156
if __name__ == "__main__":
142157
root = tk.Tk()

0 commit comments

Comments
 (0)