add registration WIP
This commit is contained in:
		
							parent
							
								
									f64cee12f5
								
							
						
					
					
						commit
						1a2edcfee6
					
				| @ -72,3 +72,9 @@ INSERT INTO realmlist (id, name, address, port, icon, realmflags, timezone, allo | ||||
| ``` | ||||
| 
 | ||||
| > Modifier le `NOM`, l'adresse `IP` du serveur (sauf si sur la même machine que le client) et la timezone si différent de Paris | ||||
| 
 | ||||
| ### TO DO  | ||||
| 
 | ||||
| - admin create account OK, change password KO (old password decryption) | ||||
| - make registration get vars from .env | ||||
| - script install ask version and client path and do all | ||||
| @ -1,36 +1,25 @@ | ||||
| #!/usr/bin/env bash | ||||
| set -euo pipefail | ||||
| 
 | ||||
| # Choix expension | ||||
| # echo "Entre ton choix (classic / tbc / wotlk) :" | ||||
| # read reponse | ||||
| 
 | ||||
| # case "$reponse" in | ||||
| #     classic) EXPANSION="classic" ;; | ||||
| #     tbc)     EXPANSION="tbc" ;; | ||||
| #     wotlk)   EXPANSION="wotlk" ;; | ||||
| #     *)       EXPANSION="Inconnu" ;; | ||||
| # esac | ||||
| source ".env" | ||||
| 
 | ||||
| # Arguments | ||||
| EXPANSION="${1:-wotlk}"   # exemple : wotlk / tbc / classic | ||||
| THREADS="${2:-2}" | ||||
| THREADS="${1:-2}" | ||||
| 
 | ||||
| # Infos git | ||||
| MANGOS_SHA1=$(curl -sSL "https://api.github.com/repos/cmangos/mangos-${EXPANSION}/commits/master" | jq -r .sha) | ||||
| DATABASE_SHA1=$(curl -sSL "https://api.github.com/repos/cmangos/${EXPANSION}-db/commits/master" | jq -r .sha) | ||||
| MANGOS_SHA1=$(curl -sSL "https://api.github.com/repos/cmangos/mangos-${WOW_VERSION}/commits/master" | jq -r .sha) | ||||
| DATABASE_SHA1=$(curl -sSL "https://api.github.com/repos/cmangos/${WOW_VERSION}-db/commits/master" | jq -r .sha) | ||||
| 
 | ||||
| VERSION="1.0.0-$(date -u +"%Y%m%d")" | ||||
| DOCKER_IMAGE="wow-server" | ||||
| 
 | ||||
| # Tags pour builder | ||||
| BUILDER_IMAGE_TAG="${DOCKER_IMAGE}-${EXPANSION}:builder" | ||||
| BUILDER_IMAGE_TAG="${DOCKER_IMAGE}-${WOW_VERSION}:builder" | ||||
| # Tags pour runner | ||||
| RUNNER_IMAGE_TAG="${DOCKER_IMAGE}-${EXPANSION}:runner" | ||||
| RUNNER_IMAGE_TAG="${DOCKER_IMAGE}-${WOW_VERSION}:runner" | ||||
| 
 | ||||
| echo "==== Build de l’image BUILDER ====" | ||||
| docker buildx build \ | ||||
|   --build-arg EXPANSION="${EXPANSION}" \ | ||||
|   --build-arg EXPANSION="${WOW_VERSION}" \ | ||||
|   --build-arg MANGOS_SHA1="${MANGOS_SHA1}" \ | ||||
|   --build-arg DATABASE_SHA1="${DATABASE_SHA1}" \ | ||||
|   --build-arg THREADS="${THREADS}" \ | ||||
| @ -42,7 +31,7 @@ docker buildx build \ | ||||
| 
 | ||||
| echo "==== Build de l’image RUNNER ====" | ||||
| docker buildx build \ | ||||
|   --build-arg EXPANSION="${EXPANSION}" \ | ||||
|   --build-arg EXPANSION="${WOW_VERSION}" \ | ||||
|   --build-arg MANGOS_SHA1="${MANGOS_SHA1}" \ | ||||
|   --build-arg DATABASE_SHA1="${DATABASE_SHA1}" \ | ||||
|   --build-arg THREADS="${THREADS}" \ | ||||
|  | ||||
							
								
								
									
										49
									
								
								compose.yml
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								compose.yml
									
									
									
									
									
								
							| @ -25,6 +25,7 @@ services: | ||||
|     tty: true | ||||
|     ports: | ||||
|       - "${MANGOSD_PORT:-8085}:8085" | ||||
|       - "7878:7878" | ||||
|     volumes: | ||||
|       - ./mangosd_data:/var/lib/mangos:ro | ||||
|       - ./config/mangosd:/opt/mangos/conf:ro | ||||
| @ -46,24 +47,50 @@ services: | ||||
|       - "${REALMD_PORT:-3724}:3724" | ||||
|     volumes: | ||||
|       - ./mangosd_data:/var/lib/mangos:ro | ||||
|       - ./config/realmd:/opt/mangos/conf:ro | ||||
|     networks: | ||||
|       - wow | ||||
| 
 | ||||
|   # phpmyadmin: | ||||
|   #   image: phpmyadmin:5.2 | ||||
|   #   container_name: wow-db-admin | ||||
|   phpmyadmin: | ||||
|     image: phpmyadmin:5.2 | ||||
|     container_name: wow-db-admin | ||||
|     depends_on: | ||||
|       - database | ||||
|     profiles: | ||||
|       - debug | ||||
|     environment: | ||||
|       PMA_HOST: database | ||||
|       PMA_USER: root | ||||
|       PMA_PASSWORD: "${MYSQL_SUPERPASS}" | ||||
|     networks: | ||||
|       - wow | ||||
|     ports: | ||||
|       - "${PHPMYADMIN_PORT:-8080}:80" | ||||
| 
 | ||||
|   # admin: | ||||
|   #   build: ./php | ||||
|   #   ports: | ||||
|   #     - "8089:80" | ||||
|   #   env_file: | ||||
|   #     - .env | ||||
|   #   depends_on: | ||||
|   #     - database | ||||
|   #   profiles: | ||||
|   #     - debug | ||||
|   #   environment: | ||||
|   #     PMA_HOST: database | ||||
|   #     PMA_USER: root | ||||
|   #     PMA_PASSWORD: "${MYSQL_SUPERPASS}" | ||||
|   #   networks: | ||||
|   #     - wow | ||||
|   #   ports: | ||||
|   #     - "${PHPMYADMIN_PORT:-8080}:80" | ||||
| 
 | ||||
|   php-panel: | ||||
|     image: wow-registration | ||||
| #    build: ./registration | ||||
|     container_name: wow-registration | ||||
|     ports: | ||||
|       - "8090:80" | ||||
|     environment: | ||||
|       - SOAP_HOST=mangosd | ||||
|       - SOAP_PORT=7878 | ||||
|     depends_on: | ||||
|       - mangosd | ||||
|     networks: | ||||
|       - wow | ||||
| 
 | ||||
| networks: | ||||
|   wow: | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										149
									
								
								config/realmd/realmd.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								config/realmd/realmd.conf
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,149 @@ | ||||
| ############################################ | ||||
| # MaNGOS realmd configuration file | ||||
| # | ||||
| # 	To overwrite configuration fields with environment variables | ||||
| # 	use the following pattern to generate environment variable names: | ||||
| # | ||||
| # 		For WrongPass.MaxCount: | ||||
| # 			export Realmd_WrongPass_MaxCount=10 | ||||
| # | ||||
| # 		For RealmServerPort: | ||||
| # 			export Realmd_RealmServerPort=3333 | ||||
| # | ||||
| ############################################ | ||||
| 
 | ||||
| [RealmdConf] | ||||
| ConfVersion=2021031501 | ||||
| 
 | ||||
| ################################################################################################################### | ||||
| # REALMD SETTINGS | ||||
| # | ||||
| #    LoginDatabaseInfo | ||||
| #        Database connection settings for the realm server. | ||||
| #        Default: hostname;port;username;password;database | ||||
| #                 .;somenumber;username;password;database - use named pipes at Windows | ||||
| #                       Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini | ||||
| #                 .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux | ||||
| #                       Unix sockets: experimental, not tested | ||||
| # | ||||
| #    LogsDir | ||||
| #         Logs directory setting. | ||||
| #         Important: Logs dir must exists, or all logs be disable | ||||
| #         Default: "" - no log directory prefix. if used log names aren't absolute paths | ||||
| #                       then logs will be stored in the current directory of the running program. | ||||
| # | ||||
| #    MaxPingTime | ||||
| #         Settings for maximum database-ping interval (minutes between pings) | ||||
| # | ||||
| #    RealmServerPort | ||||
| #         Port on which the server will listen | ||||
| # | ||||
| #    BindIP | ||||
| #         Bind Realm Server to specific IP address | ||||
| #         This option is useful for running multiple worldd/realmd instances | ||||
| #         on different IP addresses using default ports. | ||||
| #         DO NOT CHANGE THIS UNLESS YOU _REALLY_ KNOW WHAT YOU'RE DOING | ||||
| # | ||||
| #    ListenerThreads | ||||
| #        Number of listener threads realmd should use. | ||||
| #        Default: 1 | ||||
| # | ||||
| #    PidFile | ||||
| #        Realmd daemon PID file | ||||
| #        Default: ""             - do not create PID file | ||||
| #                 "./realmd.pid" - create PID file (recommended name) | ||||
| # | ||||
| #    LogLevel | ||||
| #        Server console level of logging | ||||
| #        0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug | ||||
| #        Default: 0 | ||||
| # | ||||
| #    LogTime | ||||
| #        Include time in server console output [hh:mm:ss] | ||||
| #        Default: 0 (no time) | ||||
| #                 1 (print time) | ||||
| # | ||||
| #    LogFile | ||||
| #        Logfile name | ||||
| #        Default: "Realmd.log" | ||||
| #                 "" - empty name disable creating log file | ||||
| # | ||||
| #    LogTimestamp | ||||
| #        Logfile with timestamp of server start in name | ||||
| #        Default: 0 - no timestamp in name | ||||
| #                 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext | ||||
| # | ||||
| #    LogFileLevel | ||||
| #        Server file level of logging | ||||
| #        0 = Minimum; 1 = Error; 2 = Detail; 3 = Full/Debug | ||||
| #        Default: 0 | ||||
| # | ||||
| #    LogColors | ||||
| #        Color for messages (format "normal_color details_color debug_color error_color) | ||||
| #        Colors: 0 - BLACK, 1 - RED, 2 - GREEN,  3 - BROWN, 4 - BLUE, 5 - MAGENTA, 6 -  CYAN, 7 - GREY, | ||||
| #                8 - YELLOW, 9 - LRED, 10 - LGREEN, 11 - LBLUE, 12 - LMAGENTA, 13 - LCYAN, 14 - WHITE | ||||
| #        Default: "" - none colors | ||||
| #                 "13 7 11 9" - for example :) | ||||
| # | ||||
| #    UseProcessors | ||||
| #        Used processors mask for multi-processors system (Used only at Windows) | ||||
| #        Default: 0 (selected by OS) | ||||
| #                 number (bitmask value of selected processors) | ||||
| # | ||||
| #    ProcessPriority | ||||
| #        Process proirity setting (Used only at Windows) | ||||
| #        Default: 1 (HIGH) | ||||
| #                 0 (Normal) | ||||
| # | ||||
| #    WaitAtStartupError | ||||
| #        After startup error report wait <Enter> or some time before continue (and possible close console window) | ||||
| #                 -1 (wait until <Enter> press) | ||||
| #        Default:  0 (not wait) | ||||
| #                  N (>0, wait N secs) | ||||
| # | ||||
| #    RealmsStateUpdateDelay | ||||
| #        Realm list Update up delay (updated at realm list request if delay expired). | ||||
| #        Default: 20 | ||||
| #                 0  (Disabled) | ||||
| # | ||||
| #    StrictVersionCheck | ||||
| #        Description: Prevent modified clients from connnecting | ||||
| #        Default:     0 - (Disabled) | ||||
| #                     1 - (Enabled) | ||||
| # | ||||
| #    WrongPass.MaxCount | ||||
| #        Number of login attemps with wrong password before the account or IP is banned | ||||
| #        Default: 0  (Never ban) | ||||
| # | ||||
| #    WrongPass.BanTime | ||||
| #        Duration of the ban in seconds (0 means permanent ban) | ||||
| #        Default: 600 | ||||
| # | ||||
| #    WrongPass.BanType | ||||
| #        Ban the IP or account on which login is attempted | ||||
| #        Default: 0 (Ban IP) | ||||
| #                 1 (Ban Account) | ||||
| # | ||||
| ################################################################################################################### | ||||
| 
 | ||||
| # LoginDatabaseInfo = "127.0.0.1;3306;mangos;mangos;classicrealmd" | ||||
| # LogsDir = "" | ||||
| MaxPingTime = 30 | ||||
| RealmServerPort = 3724 | ||||
| BindIP = "0.0.0.0" | ||||
| ListenerThreads = 1 | ||||
| PidFile = "" | ||||
| LogLevel = 0 | ||||
| LogTime = 0 | ||||
| LogFile = "Realmd.log" | ||||
| LogTimestamp = 0 | ||||
| LogFileLevel = 0 | ||||
| LogColors = "" | ||||
| UseProcessors = 0 | ||||
| ProcessPriority = 1 | ||||
| WaitAtStartupError = 0 | ||||
| RealmsStateUpdateDelay = 20 | ||||
| StrictVersionCheck = 0 | ||||
| WrongPass.MaxCount = 0 | ||||
| WrongPass.BanTime = 600 | ||||
| WrongPass.BanType = 0 | ||||
							
								
								
									
										15
									
								
								create_user.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								create_user.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,15 @@ | ||||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| curl -s -u "soapuser:soappass" \ | ||||
|   -H "Content-Type: text/xml" \ | ||||
|   -d '<?xml version="1.0" encoding="UTF-8"?> | ||||
|   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" | ||||
|                      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" | ||||
|                      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" | ||||
|                      xmlns:xsd="http://www.w3.org/1999/XMLSchema" | ||||
|                      xmlns:ns1="urn:MaNGOS"> | ||||
|     <SOAP-ENV:Body> | ||||
|       <ns1:command>account create test2 testpass</ns1:command> | ||||
|     </SOAP-ENV:Body> | ||||
|   </SOAP-ENV:Envelope>' \ | ||||
|   http://localhost:7878/ | ||||
| @ -166,6 +166,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||||
|         libmariadb-dev \ | ||||
|         libssl3 \ | ||||
|         wait-for-it \ | ||||
|         screen \ | ||||
|  \ | ||||
|  && rm -rf /tmp/* | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										56
									
								
								mangosd.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								mangosd.conf
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| 
 | ||||
| ################################################################################################################### | ||||
| # | ||||
| #    GameType | ||||
| #        Server realm style | ||||
| #        0 = NORMAL; 1 = PVP; 4 = NORMAL; 6 = RP; 8 = RPPVP | ||||
| #        also custom type: 16 FFA_PVP (free for all pvp mode like arena PvP in all zones except rest | ||||
| #        activated places and sanctuaries) | ||||
| # | ||||
| #    RealmZone | ||||
| #        Server realm zone (set allowed alphabet in character names/etc). See also Strict*Names options. | ||||
| # | ||||
| #        1 Development    - any language (Default) | ||||
| #        2 United States  - extended-Latin | ||||
| #        3 Oceanic        - extended-Latin | ||||
| #        4 Latin America  - extended-Latin | ||||
| #        5 Tournament     - basic-Latin at create, any at login | ||||
| #        6 Korea          - East-Asian | ||||
| #        7 Tournament     - basic-Latin at create, any at login | ||||
| #        8 English        - extended-Latin | ||||
| #        9 German         - extended-Latin | ||||
| #        10 French        - extended-Latin | ||||
| #        11 Spanish       - extended-Latin | ||||
| #        12 Russian       - Cyrillic | ||||
| #        13 Tournament    - basic-Latin at create, any at login | ||||
| #        14 Taiwan        - East-Asian | ||||
| #        15 Tournament    - basic-Latin at create, any at login | ||||
| #        16 China         - East-Asian | ||||
| #        17 CN1           - basic-Latin at create, any at login | ||||
| #        18 CN2           - basic-Latin at create, any at login | ||||
| #        19 CN3           - basic-Latin at create, any at login | ||||
| #        20 CN4           - basic-Latin at create, any at login | ||||
| #        21 CN5           - basic-Latin at create, any at login | ||||
| #        22 CN6           - basic-Latin at create, any at login | ||||
| #        23 CN7           - basic-Latin at create, any at login | ||||
| #        24 CN8           - basic-Latin at create, any at login | ||||
| #        25 Tournament    - basic-Latin at create, any at login | ||||
| #        26 Test Server   - any language | ||||
| #        27 Tournament    - basic-Latin at create, any at login | ||||
| #        28 QA Server     - any language | ||||
| #        29 CN9           - basic-Latin at create, any at login | ||||
| # | ||||
| #    RabbitDay | ||||
| #        Set to Rabbit Day (date in unix time), only the day and month are considered, the year is not important | ||||
| #        Default: 0 (off) | ||||
| #        Suggested: 954547200 (April 1st, 2000) | ||||
| # | ||||
| #    Motd | ||||
| #        Message of the Day. Displayed at worldlogin for every user ('@' for a newline). | ||||
| # | ||||
| #################################################################################################################### | ||||
| 
 | ||||
| GameType = 0 | ||||
| RealmZone = 8 | ||||
| RabbitDay = 954547200 | ||||
| Motd = "Bienvenue en Azeroth!" | ||||
							
								
								
									
										22
									
								
								php/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								php/Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| FROM php:8.2-apache | ||||
| 
 | ||||
| # Installer les dépendances nécessaires pour compiler les extensions PHP | ||||
| RUN apt-get update && apt-get install -y \ | ||||
|     unzip \ | ||||
|     git \ | ||||
|     libgmp-dev \ | ||||
|     libzip-dev \ | ||||
|     libxml2-dev \ | ||||
|     default-mysql-client \ | ||||
|     && docker-php-ext-install mysqli gmp soap \ | ||||
|     && rm -rf /var/lib/apt/lists/* | ||||
| 
 | ||||
| # Installer composer | ||||
| COPY --from=composer:2 /usr/bin/composer /usr/bin/composer | ||||
| 
 | ||||
| # Copier l'application | ||||
| WORKDIR /var/www/html | ||||
| COPY ./index.php ./srp6.php ./composer.json ./ | ||||
| 
 | ||||
| # Installer les dépendances PHP | ||||
| RUN composer install --no-dev --optimize-autoloader | ||||
							
								
								
									
										15
									
								
								php/composer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								php/composer.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| { | ||||
|     "name": "wow/account-web", | ||||
|     "description": "Web panel to create WoW accounts with SRP6 and OIDC authentication", | ||||
|     "require": { | ||||
|         "php": ">=8.0", | ||||
|         "jumbojett/openid-connect-php": "^0.9.6", | ||||
|         "ext-gmp": "*", | ||||
|         "ext-mysqli": "*" | ||||
|     }, | ||||
|     "autoload": { | ||||
|         "files": [ | ||||
|             "srp6.php" | ||||
|         ] | ||||
|     } | ||||
| } | ||||
							
								
								
									
										58
									
								
								php/index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								php/index.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| <?php | ||||
| require __DIR__ . '/vendor/autoload.php'; | ||||
| 
 | ||||
| use Jumbojett\OpenIDConnectClient; | ||||
| 
 | ||||
| // session_start();
 | ||||
| 
 | ||||
| // // --- OIDC login ---
 | ||||
| // $oidc = new OpenIDConnectClient(
 | ||||
| //     getenv('OIDC_ISSUER'),
 | ||||
| //     getenv('OIDC_CLIENT_ID'),
 | ||||
| //     getenv('OIDC_CLIENT_SECRET')
 | ||||
| // );
 | ||||
| 
 | ||||
| // if (!isset($_SESSION['user'])) {
 | ||||
| //     $oidc->authenticate();
 | ||||
| //     $_SESSION['user'] = $oidc->getVerifiedClaims();
 | ||||
| // }
 | ||||
| 
 | ||||
| // --- Formulaire pour créer un compte ---
 | ||||
| if ($_SERVER['REQUEST_METHOD'] === 'POST') { | ||||
|     $user = $_POST['username']; | ||||
|     $pass = $_POST['password']; | ||||
| 
 | ||||
|     $soapUser = 'SOAPUSER'; | ||||
|     $soapPass = 'SOAPPASS'; | ||||
|     $host = getenv('SOAP_HOST'); | ||||
|     $port = getenv('SOAP_PORT'); | ||||
| 
 | ||||
|     $command = "account create $user $pass"; | ||||
|     $command = "account list"; | ||||
| 
 | ||||
|     $client = new SoapClient(NULL, [ | ||||
|         "location" => "http://mangosd:7878/", | ||||
|         "uri" => "urn:MaNGOS", | ||||
|         "style" => SOAP_RPC, | ||||
|         'login' => $soapUser, | ||||
|         'password' => $soapPass | ||||
|     ]); | ||||
| 
 | ||||
|     try { | ||||
|         // NOTE : ne pas mettre de préfixe ns1:
 | ||||
|         $result = $client->__soapCall('executeCommand', [new SoapParam($command, 'command')]); | ||||
|         echo "✅ Command executed:\n"; | ||||
|         echo $result; | ||||
|         var_dump($result); | ||||
|     } catch (Exception $e) { | ||||
|         echo "❌ Command failed:\n"; | ||||
|         echo $e->getMessage(); | ||||
|     } | ||||
| } | ||||
| ?>
 | ||||
| 
 | ||||
| <form method="post"> | ||||
|     <input type="text" name="username" placeholder="Username" required> | ||||
|     <input type="password" name="password" placeholder="Password" required> | ||||
|     <button type="submit">Create Account</button> | ||||
| </form> | ||||
							
								
								
									
										50
									
								
								php/srp6.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								php/srp6.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | ||||
| <?php | ||||
| /** | ||||
|  * SRP6 (WoW/MaNGOS) – génération de v et s corrects. | ||||
|  * Points clés : | ||||
|  * - USERNAME & PASSWORD en MAJUSCULES | ||||
|  * - x = SHA1( salt || SHA1(USER:PASS) ) | ||||
|  * - N = 0x894B...E9BB7 (256-bit), g = 7 | ||||
|  * - Endianness : on évite gmp_import et on passe par hex pour ne pas se tromper | ||||
|  * - Hex MAJUSCULE + padding à la longueur de N | ||||
|  */ | ||||
| final class SRP6 | ||||
| { | ||||
|     // N et g utilisés par WoW (256-bit)
 | ||||
|     private const N_HEX = '894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7'; | ||||
|     private const G_HEX = '07'; | ||||
| 
 | ||||
|     public static function createVerifierAndSalt(string $username, string $password): array | ||||
|     { | ||||
|         $U = strtoupper($username); | ||||
|         $P = strtoupper($password); | ||||
| 
 | ||||
|         // 32 octets de sel (=> 64 hex)
 | ||||
|         $saltBin = random_bytes(32); | ||||
| 
 | ||||
|         // h1 = SHA1(U:P)
 | ||||
|         $h1 = sha1($U . ':' . $P, true); | ||||
| 
 | ||||
|         // h2 = SHA1(salt || h1)
 | ||||
|         $h2 = sha1($saltBin . $h1, true); | ||||
| 
 | ||||
|         // x = int( h2 ) (interprété comme un entier non signé big-endian)
 | ||||
|         // -> on passe par l'hex pour éviter les soucis d'endianness
 | ||||
|         $x = gmp_init(bin2hex($h2), 16); | ||||
| 
 | ||||
|         $N = gmp_init(self::N_HEX, 16); | ||||
|         $g = gmp_init(self::G_HEX, 16); | ||||
| 
 | ||||
|         // v = g^x mod N
 | ||||
|         $v = gmp_powm($g, $x, $N); | ||||
| 
 | ||||
|         // Longueur hex attendue = longueur de N en hex (ici 64 chars)
 | ||||
|         $nLen = strlen(self::N_HEX); | ||||
| 
 | ||||
|         // Hex MAJUSCULE + padding
 | ||||
|         $vHex = strtoupper(str_pad(gmp_strval($v, 16), $nLen, '0', STR_PAD_LEFT)); | ||||
|         $sHex = strtoupper(str_pad(bin2hex($saltBin), 64, '0', STR_PAD_LEFT)); // 32 bytes => 64 hex
 | ||||
| 
 | ||||
|         return ['v' => $vHex, 's' => $sHex]; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										1
									
								
								registration
									
									
									
									
									
										Submodule
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								registration
									
									
									
									
									
										Submodule
									
								
							| @ -0,0 +1 @@ | ||||
| Subproject commit 72f3ab1c37e25a9cf3a8149d05c8bfbd7b169279 | ||||
							
								
								
									
										67
									
								
								scripts/create_realm.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										67
									
								
								scripts/create_realm.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,67 @@ | ||||
| #!/usr/bin/env bash | ||||
| # | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| readonly BASE_DIR="$(realpath "$(dirname "${0}")/..")" | ||||
| source "${BASE_DIR}/.env" | ||||
| 
 | ||||
| # Nom du conteneur Docker | ||||
| CONTAINER="wow-mangosd" | ||||
| 
 | ||||
| function create_realm() { | ||||
|     local REALM_NAME="${1}" | ||||
|     local REALM_ADDRESS="${2}" | ||||
| 
 | ||||
|     # Variables fixes | ||||
|     REALM_ID=1 | ||||
|     REALM_PORT=8085 | ||||
| 
 | ||||
|     echo "⚙️  Configuration du realm '$REALM_NAME' ($REALM_ADDRESS:$REALM_PORT)..." | ||||
| 
 | ||||
|     # Exécution des requêtes SQL via un client mysql externe | ||||
|     docker run --rm -i \ | ||||
|         --network container:$CONTAINER \ | ||||
|         mysql:5.7 \ | ||||
|         mysql -hdatabase -u$MANGOS_DBUSER -p$MANGOS_DBPASS ${WOW_VERSION}realmd <<EOF | ||||
| DELETE FROM realmlist WHERE id = $REALM_ID; | ||||
| 
 | ||||
| INSERT INTO realmlist (id, name, address, port, icon, realmflags, timezone, allowedSecurityLevel) | ||||
| VALUES ('$REALM_ID', '$REALM_NAME', '$REALM_ADDRESS', '$REALM_PORT', '1', '0', '8', '0'); | ||||
| EOF | ||||
| 
 | ||||
|     echo "✅ Realm '$REALM_NAME' avec IP '$REALM_ADDRESS' a été configuré." | ||||
| } | ||||
| 
 | ||||
| # function create_account() { | ||||
| #     local ACCOUNT_NAME="${1}" | ||||
| #     local ACCOUNT_PASS="${2}" | ||||
| #     local GMLEVEL="${3:-0}" | ||||
| 
 | ||||
| #     echo "⚙️  Création du compte '$ACCOUNT_NAME' (GM level $GMLEVEL)..." | ||||
| 
 | ||||
| #     # Création via le binaire mangosd dans le conteneur | ||||
| #     docker exec -i $CONTAINER /opt/mangos/bin/realmd account create "$ACCOUNT_NAME" "$ACCOUNT_PASS -c /opt/mangos/conf/realmd.conf" | ||||
| #     docker exec -i $CONTAINER /opt/mangos/bin/realmd account set gmlevel "$ACCOUNT_NAME" "$GMLEVEL" -1 "-c /opt/mangos/conf/realmd.conf" | ||||
| #     # Attribution du GM level si nécessaire | ||||
| #     if [ "$GMLEVEL" -gt 0 ]; then | ||||
| #         docker exec -i $CONTAINER /opt/mangos/bin/mangosd account set gmlevel "$ACCOUNT_NAME" "$GMLEVEL" -1 | ||||
| #     fi | ||||
| 
 | ||||
| #     echo "✅ Compte '$ACCOUNT_NAME' créé avec succès (GM level $GMLEVEL)." | ||||
| # } | ||||
| 
 | ||||
| case "${1}" in | ||||
|     create_realm) | ||||
|         shift | ||||
|         create_realm "${@}" | ||||
|         ;; | ||||
|     create_account) | ||||
|         shift | ||||
|         create_account "${@}" | ||||
|         ;; | ||||
|     *) | ||||
|         cd "${HOME_DIR}" | ||||
|         exec "${@}" | ||||
|         ;; | ||||
| esac | ||||
							
								
								
									
										59
									
								
								soap.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								soap.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,59 @@ | ||||
| <?php | ||||
| /* | ||||
|  * This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation; either version 2 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program; if not, write to the Free Software | ||||
|  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  * MaNGOSsoap client example | ||||
|  * | ||||
|  * a simple example how to invoke commands using SOAP | ||||
|  * | ||||
|  * Make sure you enabled SOAP in your mangosd.conf! | ||||
|  *  SOAP.Enabled = 1 | ||||
|  */ | ||||
| 
 | ||||
| /* | ||||
|  * $username and $password MUST be uppercase | ||||
|  * account $username needs at least SEC_ADMINISTRATOR | ||||
|  */ | ||||
| $username = 'ADMINISTRATOR'; | ||||
| $password = 'ADMINISTRATOR'; | ||||
| 
 | ||||
| $host = "localhost"; | ||||
| $soapport = 7878; | ||||
| $command = "server info"; | ||||
| 
 | ||||
| $client = new SoapClient(NULL, | ||||
| array( | ||||
|     "location" => "http://$host:$soapport/", | ||||
|     "uri" => "urn:MaNGOS", | ||||
|     "style" => SOAP_RPC, | ||||
|     'login' => $username, | ||||
|     'password' => $password | ||||
| )); | ||||
| 
 | ||||
| try { | ||||
|     $result = $client->executeCommand(new SoapParam($command, "command")); | ||||
| 
 | ||||
|     echo "Command succeeded! Output:<br />\n"; | ||||
|     echo $result; | ||||
| } | ||||
| catch (Exception $e) | ||||
| { | ||||
|     echo "Command failed! Reason:<br />\n"; | ||||
|     echo $e->getMessage(); | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	