// Send our login info! private void craft_login_packet(Socket socket) { byte[] login_info = new byte[128]; login_info[0x5B] = 0x24; for (int i = 0; i < name.Length; i++) { login_info[0x5E + i] = (byte)name[i]; } for (int i = 0; i < password.Length; i++) { login_info[0x6C + i] = (byte)password[i]; } byte[] exponent = { 1, 0, 1 }; System.Security.Cryptography.RSAParameters RSAKeyInfo = new System.Security.Cryptography.RSAParameters(); //Set RSAKeyInfo to the public key values. RSAKeyInfo.Modulus = RSA_enc_key_; RSAKeyInfo.Exponent = exponent; RSA_Managed rsa_managed = new RSA_Managed(); rsa_managed.ImportParameters(RSAKeyInfo); byte[] encrypted_bytes = new byte[128]; encrypted_bytes = rsa_managed.EncryptValue(login_info); byte[] login_send = new byte[176]; byte[] prelogin_send = new byte[176]; encrypted_bytes.CopyTo(login_send, 1); login_send[129] = RSA_key_[0]; login_send[130] = RSA_key_[1]; login_send[131] = RSA_key_[2]; login_send[132] = RSA_key_[3]; login_send[133] = 0x23;//GG reply start login_send[134] = 0x01; login_send[135] = 0x00; login_send[136] = 0x00; login_send[137] = 0x67;// login_send[138] = 0x45; login_send[139] = 0x00; login_send[140] = 0x00; login_send[141] = 0xAB;// login_send[142] = 0x89; login_send[143] = 0x00; login_send[144] = 0x00; login_send[145] = 0xEF;// login_send[146] = 0xCD; login_send[147] = 0x00; login_send[148] = 0x00;//GG reply stop login_send[149] = 0x08;// login_send[150] = 0x00; login_send[151] = 0x00; login_send[152] = 0x00; login_send[153] = 0x00;// login_send[154] = 0x00; login_send[155] = 0x00; login_send[156] = 0x00; login_send[157] = 0x00;// login_send[158] = 0x00; login_send[159] = 0x00; ulong checksum = Global.CheckSum(login_send, 160); login_send[160] = (byte)(checksum & 0xff); login_send[161] = (byte)(checksum >> 0x08 & 0xff); login_send[163] = (byte)(checksum >> 0x10 & 0xff); login_send[163] = (byte)(checksum >> 0x18 & 0xff); blowfish_cipher_.init(true, blowfish_key_); blowfish_cipher_.processBigBlock(login_send, 0, prelogin_send, 0, 176); byte[] login_packet = new byte[178]; login_packet[0] = 0xB2; login_packet[1] = 0x00; prelogin_send.CopyTo(login_packet, 2); connection_.send_packet(login_packet, 178, socket); }
// Send our login info! private void craft_login_packet(Socket socket) { byte[] login_info = new byte[128]; login_info[0x5B] = 0x24; for (int i = 0; i < name.Length; i++) { login_info[0x5E + i] = (byte)name[i]; } for (int i = 0; i < password.Length; i++) { login_info[0x6C + i] = (byte)password[i]; } byte[] exponent = { 1, 0, 1 }; System.Security.Cryptography.RSAParameters RSAKeyInfo = new System.Security.Cryptography.RSAParameters(); //Set RSAKeyInfo to the public key values. RSAKeyInfo.Modulus = RSA_enc_key_; RSAKeyInfo.Exponent = exponent; RSA_Managed rsa_managed = new RSA_Managed(); rsa_managed.ImportParameters(RSAKeyInfo); byte[] encrypted_bytes = new byte[128]; encrypted_bytes = rsa_managed.EncryptValue(login_info); byte[] login_send = new byte[176]; byte[] prelogin_send = new byte[176]; encrypted_bytes.CopyTo(login_send, 1); login_send[129] = RSA_key_[0]; login_send[130] = RSA_key_[1]; login_send[131] = RSA_key_[2]; login_send[132] = RSA_key_[3]; login_send[133] = 0x23;//GG reply start login_send[134] = 0x01; login_send[135] = 0x00; login_send[136] = 0x00; login_send[137] = 0x67;// login_send[138] = 0x45; login_send[139] = 0x00; login_send[140] = 0x00; login_send[141] = 0xAB;// login_send[142] = 0x89; login_send[143] = 0x00; login_send[144] = 0x00; login_send[145] = 0xEF;// login_send[146] = 0xCD; login_send[147] = 0x00; login_send[148] = 0x00; //GG reply stop login_send[149] = 0x08; // login_send[150] = 0x00; login_send[151] = 0x00; login_send[152] = 0x00; login_send[153] = 0x00;// login_send[154] = 0x00; login_send[155] = 0x00; login_send[156] = 0x00; login_send[157] = 0x00;// login_send[158] = 0x00; login_send[159] = 0x00; ulong checksum = Global.CheckSum(login_send, 160); login_send[160] = (byte)(checksum & 0xff); login_send[161] = (byte)(checksum >> 0x08 & 0xff); login_send[163] = (byte)(checksum >> 0x10 & 0xff); login_send[163] = (byte)(checksum >> 0x18 & 0xff); blowfish_cipher_.init(true, blowfish_key_); blowfish_cipher_.processBigBlock(login_send, 0, prelogin_send, 0, 176); byte[] login_packet = new byte[178]; login_packet[0] = 0xB2; login_packet[1] = 0x00; prelogin_send.CopyTo(login_packet, 2); connection_.send_packet(login_packet, 178, socket); }