Hello everyone,
I am currently setting up a MaNGOS TBC (2.4.3) server and I'm hitting a wall with the account registration page.
The Problem: I have a PHP script that successfully connects to the database and inserts the account into the account table. However, when I try to log in-game with the newly created account, it fails. It either gets stuck at "Authenticating" or returns "Unable to Connect".
What I have tried/observed:
My database table (account) uses the modern SRP6 columns: s (salt) and v (verifier), instead of the old sha_pass_hash.
I noticed that the default ADMIN account (which works fine) has the s and v values stored in UPPERCASE.
My script inserts the data, but the game server rejects the calculated hash/verifier. I've tried multiple SRP6 implementations (including checking Big Endian vs Little Endian byte order), but I can't seem to replicate the correct math that the Core expects.
Does anyone have a proven, working register.php script compatible with the latest MaNGOS TBC core that handles the SRP6 calculation correctly?
Any help or a snippet would be greatly appreciated.
Thanks!
<?php
$db_host = "127.0.0.1";
$db_user = "mangos";
$db_pass = "mangos";
$db_name = "tbcrealmd";
function getSRP6($username, $password) {
if (!extension_loaded('gmp')) die("ERRO: Ative a extensão GMP no PHP (php.ini).");
$user = strtoupper($username);
$pass = strtoupper($password);
$saltBin = random_bytes(32);
$g = gmp_init(7);
$N = gmp_init('894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7', 16);
$h1 = sha1($user . ':' . $pass, true);
$h2 = sha1($saltBin . $h1, true);
$h2 = gmp_import(strrev($h2));
$v = gmp_powm($g, $h2, $N);
$vBin = strrev(str_pad(gmp_export($v), 32, chr(0), STR_PAD_LEFT));
return [
's' => strtoupper(bin2hex($saltBin)),
'v' => strtoupper(bin2hex($vBin))
];
}
$msg = "";
$type = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
if ($conn->connect_error) die("Erro Conexão: " . $conn->connect_error);
$u = strtoupper(trim($_POST['username']));
$p = trim($_POST['password']);
$e = trim($_POST['email']);
$check = $conn->query("SELECT id FROM account WHERE username = '$u'");
if ($check->num_rows > 0) {
$msg = "Usuário já existe!";
$type = "error";
} else {
$srp = getSRP6($u, $p);
$sql = "INSERT INTO account (username, s, v, email, expansion, gmlevel, joindate)
VALUES ('$u', '$srp[s]', '$srp[v]', '$e', 1, 0, NOW())";
if ($conn->query($sql) === TRUE) {
$msg = "CONTA CRIADA! Login: $u";
$type = "success";
} else {
$msg = "Erro SQL: " . $conn->error;
$type = "error";
}
}
$conn->close();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Registro Final</title>
<style>
body { font-family: Arial; background: #111; color: white; text-align: center; padding-top: 50px; }
.box { background: #222; padding: 40px; display: inline-block; border-radius: 10px; border: 1px solid #444; }
input { display: block; width: 250px; padding: 10px; margin: 10px 0; border-radius: 5px; border: none; }
button { background: #dba100; color: black; padding: 10px; width: 100%; font-weight: bold; border: none; cursor: pointer; margin-top: 10px; }
.error { color: #ff5555; } .success { color: #55ff55; }
</style>
</head>
<body>
<div class="box">
<h2>Criar Conta TBC</h2>
<h3 class="<?php echo $type; ?>"><?php echo $msg; ?></h3>
<form method="POST">
<input type="text" name="username" placeholder="Usuário" required>
<input type="password" name="password" placeholder="Senha" required>
<input type="email" name="email" placeholder="Email" required>
<button type="submit">CRIAR AGORA</button>
</form>
</div>
</body>
</html>