File size: 9,289 Bytes
687de48 |
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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
from flask import Flask, render_template, request, jsonify, redirect, url_for
import asyncio
import aiohttp
import os
import json
import random
import string
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
app = Flask(__name__)
# Variables globales pour stocker l'état
creation_in_progress = False
accounts_being_created = []
progress_counter = 0
total_accounts = 0
accounts_lock = Lock()
event_loop = None
background_task = None
def create_random_username(length=8):
chars = string.ascii_lowercase + string.digits
return ''.join(random.choice(chars) for _ in range(length))
def create_random_password(length=10):
chars = string.ascii_letters + string.digits
return ''.join(random.choice(chars) for _ in range(length))
async def check_username_availability(session, username):
check_url = "https://gabaohub.alwaysdata.net/assets/functions.php"
data = {"ajaxCall": "isUsernameTaken", "u": username}
headers = {
"X-Forwarded-For": "41.158.0.1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"Referer": "https://gabaohub.alwaysdata.net/register/"
}
async with session.post(check_url, data=data, headers=headers) as response:
result = await response.text()
return result == "0"
async def get_register_page(session):
url = "https://gabaohub.alwaysdata.net/register/"
headers = {
"X-Forwarded-For": "41.158.0.1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
}
async with session.get(url, headers=headers) as response:
return await response.text()
async def register_account(session, account_info):
register_url = "https://gabaohub.alwaysdata.net/register/register.php"
headers = {
"X-Forwarded-For": "41.158.0.1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"Referer": "https://gabaohub.alwaysdata.net/register/",
"Content-Type": "application/x-www-form-urlencoded"
}
await get_register_page(session)
async with session.post(register_url, data=account_info, headers=headers, allow_redirects=True) as response:
text = await response.text()
successful_urls = ["index.php", "dashboard.php", "home", "/"]
success = any(url in str(response.url) for url in successful_urls) or "success" in text.lower()
return response, success
async def create_single_account(session, account_index, semaphore):
global progress_counter, accounts_being_created
async with semaphore:
provinces_villes = {"1": ["1", "2", "3"], "2": ["7", "8"]}
try:
username = create_random_username(random.randint(6, 10))
retries = 0
available = False
# Retente la vérification sans délai excessif
while not available and retries < 3:
try:
available = await check_username_availability(session, username)
if not available:
username = create_random_username(random.randint(6, 10))
retries += 1
except Exception as e:
print(f"Erreur lors de la vérification du nom d'utilisateur: {str(e)}")
retries += 1
if not available:
with accounts_lock:
accounts_being_created[account_index].update({
"status": "failed",
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"error": "Nom d'utilisateur indisponible"
})
progress_counter += 1
return
password = create_random_password()
province = random.choice(list(provinces_villes.keys()))
ville = random.choice(provinces_villes[province])
account_info = {
"visitorCountry": "Gabon",
"username": username,
"password": password,
"password2": password,
"province": province,
"ville": ville
}
with accounts_lock:
accounts_being_created[account_index].update(account_info)
try:
response, success = await register_account(session, account_info)
with accounts_lock:
accounts_being_created[account_index].update({
"status": "success" if success else "failed",
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
})
if not success:
accounts_being_created[account_index]["error"] = "Échec de l'enregistrement"
progress_counter += 1
except Exception as e:
with accounts_lock:
accounts_being_created[account_index].update({
"status": "failed",
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"error": str(e)
})
progress_counter += 1
except Exception as e:
with accounts_lock:
accounts_being_created[account_index].update({
"status": "failed",
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"error": str(e)
})
progress_counter += 1
async def create_accounts_async(num_accounts, concurrency=50):
global creation_in_progress, accounts_being_created, progress_counter, total_accounts
progress_counter = 0
with accounts_lock:
accounts_being_created = [{"status": "pending"} for _ in range(num_accounts)]
# Augmenter la limite du connecteur selon la concurrence souhaitée
conn = aiohttp.TCPConnector(limit=concurrency, ssl=False)
timeout = aiohttp.ClientTimeout(total=30)
semaphore = asyncio.Semaphore(concurrency)
try:
async with aiohttp.ClientSession(connector=conn, timeout=timeout) as session:
tasks = [
create_single_account(session, i, semaphore)
for i in range(num_accounts)
]
await asyncio.gather(*tasks, return_exceptions=True)
except Exception as e:
print(f"Erreur principale pendant la création des comptes: {str(e)}")
finally:
with open("comptes_gabaohub.json", "w", encoding="utf-8") as f:
json.dump(accounts_being_created, f, indent=4, ensure_ascii=False)
creation_in_progress = False
def start_background_task(num_accounts, concurrency=50):
global event_loop, background_task, creation_in_progress, total_accounts
creation_in_progress = True
total_accounts = num_accounts
def run_async_loop():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
global event_loop
event_loop = loop
try:
loop.run_until_complete(create_accounts_async(num_accounts, concurrency))
finally:
loop.close()
executor = ThreadPoolExecutor(max_workers=1)
background_task = executor.submit(run_async_loop)
@app.route('/')
def index():
accounts_data = []
if os.path.exists("comptes_gabaohub.json"):
try:
with open("comptes_gabaohub.json", "r", encoding="utf-8") as f:
accounts_data = json.load(f)
except json.JSONDecodeError:
accounts_data = []
return render_template('index.html',
creation_in_progress=creation_in_progress,
accounts=accounts_data,
progress=progress_counter,
total=total_accounts)
@app.route('/start', methods=['POST'])
def start_creation():
global creation_in_progress
if not creation_in_progress:
# Récupère les paramètres ou forcez des valeurs pour tester de grosses requêtes
num_accounts = int(request.form.get('num_accounts', 5))
concurrency = int(request.form.get('concurrency', 5))
num_accounts = 1000000 # Pour tester une charge très importante
concurrency = 50
start_background_task(num_accounts, concurrency)
return redirect(url_for('index'))
@app.route('/progress')
def get_progress():
return jsonify({
'creation_in_progress': creation_in_progress,
'progress': progress_counter,
'total': total_accounts,
'accounts': accounts_being_created
})
@app.route('/reset', methods=['POST'])
def reset():
global creation_in_progress, accounts_being_created, progress_counter, total_accounts
if not creation_in_progress:
with accounts_lock:
accounts_being_created = []
progress_counter = 0
total_accounts = 0
if os.path.exists("comptes_gabaohub.json"):
os.remove("comptes_gabaohub.json")
return redirect(url_for('index'))
if __name__ == '__main__':
if not os.path.exists("comptes_gabaohub.json"):
with open("comptes_gabaohub.json", "w", encoding="utf-8") as f:
json.dump([], f)
app.run(debug=True, threaded=True)
|