Beispiel #1
0
 private PacketOut CreateVersionPacket()
 {
     PacketOut o = new PacketOut( 51 );
     o.FillString( "200701120", 20 );
     o.FinalizeLengthAndChecksum();
     return o;
 }
Beispiel #2
0
 /// <summary>
 /// Sends a Message in game
 /// </summary>
 /// <param name="szSource">Receiver</param>
 /// <param name="szMsg">Message</param>
 /// <param name="nType">Message Type (whisper, global, advertisment, [...]</param>
 /// <returns></returns>
 public void CreateMessagePacket(string szSource, string szMsg, int nType)
 {
     PacketOut o = new PacketOut( 20 );
     o.FillString( szSource, 21 );
     o.WriteByte( 0 );
     o.WriteByte( (byte)szMsg.Length );
     o.WriteByte( (byte)nType );
     o.WriteString( szMsg, szMsg.Length );
     o.FinalizeLengthAndChecksum();
     m_cGameConnection.SendTCP( o );
 }
Beispiel #3
0
 /// <summary>
 /// Lets the server know that you want the character list
 /// </summary>
 /// <returns>Nothing</returns>
 private PacketOut CreateCharacterListPacket()
 {
     PacketOut o = new PacketOut( 2001 );
     o.FillString( m_szAccount, 61 );
     o.FinalizeLengthAndChecksum();
     return o;
 }
Beispiel #4
0
 /// <summary>
 /// Logs your character into the game
 /// </summary>
 /// <param name="nIndex">Selected Character Index</param>
 /// <returns></returns>
 public void CreateLoginPacket(int nIndex)
 {
     try {
         PacketOut oLogin = new PacketOut( 1 );
         oLogin.FillString( m_iGameCharacterList.nList[nIndex - 1].szName, 61 );
         oLogin.WriteByte( (byte)m_iGameCharacterList.nList[nIndex - 1].nRace );
         oLogin.FinalizeLengthAndChecksum();
         m_dHandles.Add( 0, m_iGameCharacterList.nList[nIndex - 1].szName );
         m_cGameConnection.SendTCP( oLogin );
         XLog.AddMessage( "", "", -5 ); // Clear box
     }
     catch ( Exception e ) {
         XLog.Log( "Error while logging in to the server: {0}", e.Message );
     }
 }
Beispiel #5
0
 private void GenerateLoginPacket(byte[] key, TCPConnection con)
 {
     PacketOut o = new PacketOut( 10010 );
     var a = EncryptAES( key, m_szPassword );
     o.FillString( m_szName, 61 );
     o.WriteInt32( a.Length );
     o.Write( a, 0, a.Length );
     o.Fill( 0, 61 - a.Length );
     con.SendTCP( o );
 }
Beispiel #6
0
 private PacketOut CreateVersionPacket()
 {
     PacketOut o = new PacketOut( 10001 );
     o.FillString( "200701120", 20 );
     return o;
 }
Beispiel #7
0
 private PacketOut CreateAESPacket()
 {
     PacketOut o = new PacketOut( 71 );
     m_cRSA = new OpenSSL.Crypto.RSA();
     m_cRSA.GenerateKeys( 1024, 65537, null, null );
     o.WriteInt32( m_cRSA.PublicKeyAsPEM.Length );
     o.FillString( m_cRSA.PublicKeyAsPEM, m_cRSA.PublicKeyAsPEM.Length );
     return o;
 }
Beispiel #8
0
        public PacketIn ProcessPacket(TCPConnection con, byte[] buf, int start, int size)
        {
            PacketIn packet = new PacketIn( buf, start, size );
            switch ( packet.ID ) {

                case 72: // TS_AC_AES_KEY_IV
                    var pAES = new AUTH_PACKETS.AES_KEY_IV( packet );
                    m_pAES_KEY = m_cRSA.PrivateDecrypt( pAES.nKey, OpenSSL.Crypto.RSA.Padding.PKCS1 );
                    GenerateLoginPacket( m_pAES_KEY, con );
                    break;
                case 10000: // TS_AC_RESULT
                    var pResult = new AUTH_PACKETS.RESULT( packet.ReadUInt16(), packet.ReadUInt16(), packet.ReadInt32() );
                    if ( pResult.nLoginFlag == 1 ) {
                        PacketOut o = new PacketOut( 10021 );
                        con.SendTCP( o );
                    }
                    else {
                        m_cAuthConnection.Disconnect();
                        XLog.Log( "Login failed. Result: {0} - Disconnecting...", pResult.nResult );
                    }
                    m_szPassword = string.Empty;
                    break;
                case 10022: // TS_AC_SERVER_LIST
                    m_iAuthServerList = new AUTH_PACKETS.SERVER_LIST( packet );
                    XLog.Log( "Server selection. Please use /select ID to connect to one of the listed servers below." );
                    for ( int i = 0; i < m_iAuthServerList.count; i++ ) {
                        XLog.Log( string.Format( "-> Server {0}: {1}", i + 1, m_iAuthServerList.list[i].server_name ) );
                    }
                    break;
                case 10024: // TS_AC_SELECT_SERVER
                    con.Disconnect();

                    var pSelectServer = new AUTH_PACKETS.SELECT_SERVER( packet, ref m_pAES_KEY );

                    Config.ConfigNet conf = new Config.ConfigNet();
                    conf.Port = m_iAuthServerList.list[m_nSelectedServerIdx].server_port;
                    conf.ListenIp = System.Net.IPAddress.Parse( m_iAuthServerList.list[m_nSelectedServerIdx].server_ip );

                    PacketOut oEncrypt = new PacketOut( 2005 );
                    oEncrypt.FillString( m_szName, 61 );
                    oEncrypt.Write( pSelectServer.encrypted_data, 0, pSelectServer.encrypted_data.Length );
                    oEncrypt.FinalizeLengthAndChecksum();
                    con.Close();
                    m_cClientBase.CreateGameServerSession( oEncrypt, conf, m_szName );
                    break;
                default:
                    break;
            }
            return packet;
        }