Esempio n. 1
0
 internal void ProcessData(BinaryReader data)
 {
     // [Text String][Type String]
     Text    = BBProtocol.ReadString(data);
     Type    = BBProtocol.ReadString(data);
     IsValid = true;
 }
Esempio n. 2
0
 public override MemoryStream[] WritePacket()
 {
     m_answerTimer.StartCountDown(4000);
     // [MaxVer 1][MinVer 1][ReqPassword 1][Desc String][OwnGUID 4][ClientVersionMaj 4][ClientVersionMinor 4][ClientVersionBuild 4]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(512), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             res.Write(MaxSupportedVersion);
             res.Write(MinSupportedVersion);
             res.Write((byte)(RequiresPassword ? 1 : 0));
             BBProtocol.WriteString(Desc, res);
             res.Write(OwnGUID);
             res.Write(ClientVersion.Major);
             res.Write(ClientVersion.Minor);
             res.Write(ClientVersion.Build);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
Esempio n. 3
0
 internal void ProcessData(BinaryReader data)
 {
     // [ErrorCode 1](ErrorCode == 0: [EncryptionMethod 1][EncryptionMagicValue 4] [RemotePublicKey 256]( EncryptionMethod == AUTH: [PasswordSalt 16]))
     ErrorCode = data.ReadByte();
     if (ErrorCode == 0)
     {
         EncryptionMethod    = (EEncryptionMethod)data.ReadByte();
         EncryptedMagicValue = BBProtocol.ReadByteArray(data);
         if (EncryptedMagicValue.Length != 4)
         {
             IsValid = false;
             return;
         }
         RemotePublicKey = BBProtocol.ReadByteArray(data);
         if (RemotePublicKey.Length != 256)
         {
             IsValid = false;
             return;
         }
         if (EncryptionMethod == EEncryptionMethod.DH_PLUS_AUTH)
         {
             PasswordSalt = BBProtocol.ReadByteArray(data);
             if (PasswordSalt.Length != 16)
             {
                 IsValid = false;
                 return;
             }
         }
     }
     IsValid = true;
 }
Esempio n. 4
0
 internal void ProcessData(BinaryReader data)
 {
     // [ContentPlainText String][ContentHTMLText String]
     ContentPlainText = BBProtocol.ReadString(data);
     ContentHtmlText  = BBProtocol.ReadString(data);
     IsValid          = true;
 }
Esempio n. 5
0
 internal void ProcessData(BinaryReader data)
 {
     // [FileID 4][Filesize 8][Name String][Type String]
     FileID   = data.ReadInt32();
     FileSize = data.ReadUInt64();
     FileName = BBProtocol.ReadString(data);
     FileType = BBProtocol.ReadString(data);
     IsValid  = true;
 }
Esempio n. 6
0
 internal void ProcessData(BinaryReader data)
 {
     // [Text String][CursorPos 4][LastInputID 4]
     Text                 = BBProtocol.ReadString(data);
     CursorPos            = data.ReadInt32();
     LastProcessedInputID = data.ReadInt32();
     if (CursorPos < 0 || CursorPos > Text.Length)
     {
         Log.e(TAG, "Invalid Cursor pos on InputFocusChange received" + CursorPos);
         CursorPos = Text.Length;
     }
     IsValid = true;
 }
 internal void ProcessData(BinaryReader data)
 {
     // [ImeOptions 4][InputType 4][Hint String][PackageName String][Text String][CursorPos 4][FieldID 4]
     ImeOptions  = data.ReadInt32();
     InputType   = data.ReadInt32();
     Hint        = BBProtocol.ReadString(data);
     PackageName = BBProtocol.ReadString(data);
     Text        = BBProtocol.ReadString(data);
     CursorPos   = data.ReadInt32();
     FieldID     = data.ReadInt32();
     if (CursorPos < 0 || CursorPos > Text.Length)
     {
         Log.e(TAG, "Invalid Cursor pos on InputFocusChange received" + CursorPos);
         CursorPos = Text.Length;
     }
     IsValid = true;
 }
Esempio n. 8
0
        internal void ProcessData(BinaryReader data)
        {
            // [MaxVer 1][MinVer 1][ReqPassword 1][Desc String][ServerGUID 4]
            MaxSupportedVersion = data.ReadByte();
            MinSupportedVersion = data.ReadByte();
            RequiresPassword    = data.ReadByte() > 0;
            Desc       = BBProtocol.ReadString(data);
            ServerGUID = data.ReadInt32();

            if (MaxSupportedVersion >= 2)
            {
                // [SupportsScreenCapture 1][ProVersion 1]
                SupportsScreenCapture = data.ReadByte() > 0;
                IsProVersion          = data.ReadByte() > 0;
            }
            IsValid = true;
        }
 internal void ProcessData(BinaryReader data)
 {
     // [FileID 4][Command 1][IsSender 1][ErrorMsg String]
     try
     {
         FileID       = data.ReadInt32();
         Command      = (EFileCommand)data.ReadByte();
         IsSender     = data.ReadByte() != 0;
         ErrorMessage = BBProtocol.ReadString(data);
     }
     catch (Exception)
     {
         IsValid = false;
         return;
     }
     IsValid = true;
 }
Esempio n. 10
0
 internal void ProcessData(BinaryReader buf)
 {
     // [Header 5] [UsedProtVer 1] [IP InetAddress] [tcpPort 2] [DeviceName String] [FlagPassword 1] [ProtocolMin 1] [ProtocolMax 1][ServerGUID 4]
     ProtocolVersion = buf.ReadByte();
     if (ProtocolVersion < 0x01 || ProtocolVersion > BBProtocol.REQUESTED_DISCOVERY_PROTOCOL_VERSION)
     {
         ParseError = "Protocolversion unsupported";
         return;
     }
     ServerIP         = BBProtocol.ReadInetAddress(buf);
     ServerPort       = buf.ReadUInt16();
     ServerName       = BBProtocol.ReadString(buf);
     PasswordRequired = buf.ReadByte() != 0;
     MinProtocolVer   = buf.ReadByte();
     MaxProtocolVer   = buf.ReadByte();
     ServerGUID       = buf.ReadInt32();
     IsValid          = true;
 }
Esempio n. 11
0
 public override MemoryStream[] WritePacket()
 {
     // [PackageName String]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(512), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             BBProtocol.WriteString(m_strPackageName, res);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
Esempio n. 12
0
 public override MemoryStream[] WritePacket()
 {
     m_answerTimer.StartCountDown(4000);
     // [ChallengeResult 32]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(64), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             BBProtocol.WriteByteArray(ChallengeResult, res);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
Esempio n. 13
0
 public override MemoryStream[] WritePacket()
 {
     // [ContentPlainText String][ContentHTMLText String]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(64 + BBProtocol.GetMaxEncodedBytes(ContentPlainText)
                                                                 + BBProtocol.GetMaxEncodedBytes(ContentHtmlText)), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             BBProtocol.WriteString(ContentPlainText, res);
             BBProtocol.WriteString(ContentHtmlText, res);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
 public override MemoryStream[] WritePacket()
 {
     // [FileID 4][Command 1][IsSender 1][ErrorMsg String]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(32), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             res.Write(FileID);
             res.Write((byte)Command);
             res.Write((byte)(IsSender ? 1 : 0));
             BBProtocol.WriteString(ErrorMessage, res);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
Esempio n. 15
0
 public override MemoryStream[] WritePacket()
 {
     // [InputID 4] [Text String] [Offset 4] [TextAfterCursor 4]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(64 + BBProtocol.GetMaxEncodedBytes(m_strText)), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             res.Write(m_nInputID);
             BBProtocol.WriteString(m_strText, res);
             res.Write(m_nOffset);
             res.Write(m_nTextAfterCursor);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
Esempio n. 16
0
        internal void ProcessData(BinaryReader data)
        {
            PackageName = BBProtocol.ReadString(data);
            MemoryStream bs = (MemoryStream)data.BaseStream;

            try
            {
                Image = new BitmapImage();
                Image.BeginInit();
                Image.DecodeFailed += (x, e) => { throw e.ErrorException; };
                Image.StreamSource  = new MemoryStream(bs.GetBuffer(), (int)bs.Position, (int)bs.Remaining());
                Image.EndInit();
                Image.Freeze();
                Log.d(TAG, "Loaded received image for package " + PackageName);
            }
            catch (Exception e)
            {
                // don't disconnect just because we fail to decode an image
                Image = null;
                Log.w(TAG, "Failed to load/decode received image for package " + PackageName + " - " + e.Message);
            }
            IsValid = true;
        }
Esempio n. 17
0
        public override MemoryStream[] WritePacket()
        {
            m_answerTimer.StartCountDown(4000);
            // [KeySource 1] [LocalIV 16][RemoteIV 16] [LocalPublicKey 256]
            using (BinaryWriter res = new BinaryWriter(new MemoryStream(512), Encoding.UTF8, true))
            {
                try
                {
                    res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
                    res.Write((byte)Method);
                    BBProtocol.WriteByteArray(LocalIV, res);
                    BBProtocol.WriteByteArray(RemoteIV, res);
                    BBProtocol.WriteByteArray(LocalPublicKey, res);

                    return(CreateFragments(res, Opcode));
                }
                catch (Exception e) when(e is IOException || e is IOException)
                {
                    ParseError = "Error while writing packet - " + e.Message;
                    Log.e(BbTcpPacket.TAG, ParseError);
                    return(null);
                }
            }
        }