Bonjour, j'ai besoin de vous. ^^
Je m'explique :
Le serveur génère une Key aléatoirement puis l'envoie sous forme de packet au client.
Une fois le client reçu, il est censé encrypté le mot de passe du joueur + la key en md5 (normalement).
Ensuite, je ne sais pas trop comment j'envoie le packet d'authentification au serveur sachant que les bytes à envoyer vont changer.
Exemple :
Packet reçu : 48v[rf5g8r^r8g1r8e}gr4 (C'est la key généré par le serveur)
Mon mot de passe + la key reçu (Tout ça encrypté en Md5 pour donner que un et unique mot de passe crypté).
Packet envoyé : 0x59, 0x8d, 0x32, 0x39, " ICI LE MOT DE PASSE CRYPTE ", 0x69, 0x6a
Le problème c'est que je ne sais pas comment mettre ce mot de passe crypté car comme dit précédement les bytes vont changer..
// -- Packets --
byte[] key = new byte[] { 0x3c, 0x6d, 0x73, 0x67, 0x20, 0x74, 0x3d, 0x27, 0x73, 0x79, 0x73, 0x27, 0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x27, 0x72, 0x6e, 0x64, 0x4b, 0x27, 0x20, 0x72, 0x3d, 0x27, 0x2d, 0x31, 0x27, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x6d, 0x73, 0x67, 0x3e, 0x00 };
// C'est ce packet là auquel je doit inséré le mot de passe crypté
byte[] login = new byte[] { 0x3c, 0x6d, 0x73, 0x67, 0x20, 0x74, 0x3d, 0x27, 0x73, 0x79, 0x73, 0x27, 0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x27, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x27, 0x20, 0x72, 0x3d, 0x27, 0x30, 0x27, 0x3e, 0x3c, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x20, 0x7a, 0x3d, 0x27, 0x77, 0x31, 0x27, 0x3e, 0x3c, 0x6e, 0x69, 0x63, 0x6b, 0x3e, 0x3c, 0x21, 0x00 , 0x5d, 0x3e, 0x3c, 0x2f, 0x6e, 0x69, 0x63, 0x6b, 0x3e, 0x3c, 0x70, 0x77, 0x6f, 0x72, 0x64, 0x3e, 0x3c, 0x21, 0x5b, 0x43, 0x44, 0x41, 0x54, 0x41, 0x5b, 0x64, 0x36, 0x36, 0x63, 0x38, 0x33, 0x30, 0x30, 0x32, 0x65, 0x34, 0x35, 0x36, 0x64, 0x64, 0x63, 0x39, 0x35, 0x39, 0x30, 0x39, 0x32, 0x61, 0x61, 0x34, 0x34, 0x63, 0x66, 0x62, 0x61, 0x39, 0x35, 0x5d, 0x5d, 0x3e, 0x3c, 0x2f, 0x70, 0x77, 0x6f, 0x72, 0x64, 0x3e, 0x3c, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x6d, 0x73, 0x67, 0x3e, 0x00 };
monThread = new Thread(new ThreadStart(rcv));
monThread.Start();
String key_ascii = System.Text.Encoding.ASCII.GetString(key); // On décode en Ascii pour voir le contenu du packet à l'écran
String login_ascii = System.Text.Encoding.ASCII.GetString(login); // On décode en Ascii pour voir le contenu du packet à l'écran
send(key, key_ascii); // Méthode qui envoie un packet demandant une clé aléatoire au serveur
send(login, login_ascii);
while(true) {
}
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Echec!");
Console.ForegroundColor = ConsoleColor.Gray;
}
}
catch (SocketException sock_ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[SocketException] " + sock_ex.Message);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
public static void send(byte[] packet, String packet_ascii)
{
socket.Send(packet);
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Write("\n [Packet]");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(" Packet envoyé : ");
Console.WriteLine(packet_ascii);
}
}
}
}
}
}