Beispiel #1
0
    void recv(InStream & stream, uint16_t len) override {
        this->len = len;

        /* terminalDescriptor(16) + pad4octetsA(4) + desktopSaveXGranularity(2) + desktopSaveYGranularity(2) +
         * pad2octetsA(2) + maximumOrderLevel(2) + numberFonts(2) + orderFlags(2) + orderSupport(NB_ORDER_SUPPORT) +
         * textFlags(2) + orderSupportExFlags(2) + pad4octetsB(4) + desktopSaveSize(4) + pad2octetsC(2) +
         * pad2octetsD(2) + textANSICodePage(2) + pad2octetsE(2)
         */
        const unsigned expected = 32 + NB_ORDER_SUPPORT + 20;
        if (!stream.in_check_rem(expected)){
            LOG(LOG_ERR, "Truncated OrderCaps, need=%u remains=%zu",
                expected, stream.in_remain());
            throw Error(ERR_MCS_PDU_TRUNCATED);
        }

        stream.in_copy_bytes(this->terminalDescriptor, 16);
        this->pad4octetsA = stream.in_uint32_le();
        this->desktopSaveXGranularity = stream.in_uint16_le();
        this->desktopSaveYGranularity = stream.in_uint16_le();
        this->pad2octetsA = stream.in_uint16_le();
        this->maximumOrderLevel = stream.in_uint16_le();
        this->numberFonts = stream.in_uint16_le();
        this->orderFlags = stream.in_uint16_le();
        stream.in_copy_bytes(this->orderSupport, NB_ORDER_SUPPORT);
        this->textFlags = stream.in_uint16_le();
        this->orderSupportExFlags = stream.in_uint16_le();
        this->pad4octetsB = stream.in_uint32_le();
        this->desktopSaveSize = stream.in_uint32_le();
        this->pad2octetsC = stream.in_uint16_le();
        this->pad2octetsD = stream.in_uint16_le();
        this->textANSICodePage = stream.in_uint16_le();
        this->pad2octetsE = stream.in_uint16_le();
    }
Beispiel #2
0
    explicit ShareFlow_Recv(InStream & stream)
    : flowMarker([&stream]{
        if (!stream.in_check_rem(2+1+1+1+1+2)){
            LOG(LOG_ERR,
                "Truncated "
                "[2: ShareFlow PDU packet]"
                "[1: ShareFlow pad]"
                "[1: ShareFlow PDU type]"
                "[1: flow Identifier]"
                "[1: flow number]"
                "[2: ShareFlow PDU packet] , remains=%zu", stream.in_remain());
            throw Error(ERR_SEC);
        }
        return stream.in_uint16_le();
    }())
    , pad(stream.in_uint8())
    , pduTypeFlow(stream.in_uint8())
    , flowIdentifier(stream.in_uint8())
    , flowNumber(stream.in_uint8())
    , mcs_channel(stream.in_uint16_le())
    {
        LOG(LOG_INFO, "Flow control packet %.4x (offset=%zu)", this->flowMarker, stream.get_offset());
        if (this->flowMarker != 0x8000) {
            LOG(LOG_ERR, "Expected flow control packet, got %.4x", this->flowMarker);
            throw Error(ERR_SEC);
        }

        LOG(LOG_INFO, "PDUTypeFlow=%u", this->pduTypeFlow);
        if (stream.in_remain()) {
            LOG(LOG_INFO, "trailing bytes in FlowPDU, remains %zu bytes", stream.in_remain());
        }
    }
    void receive(InStream & stream) {
        {
            const unsigned expected = 4;    // allowDisplayUpdates(1) + Padding(3)

            if (!stream.in_check_rem(expected)) {
                LOG(LOG_ERR,
                    "Truncated SuppressOutputPDUData: expected=%u remains=%zu",
                    expected, stream.in_remain());
                throw Error(ERR_RDP_DATA_TRUNCATED);
            }
        }

        this->allowDisplayUpdates_ = stream.in_uint8();

        stream.in_skip_bytes(3);    // Padding(3)

        if (ALLOW_DISPLAY_UPDATES == this->allowDisplayUpdates_) {
            {
                const unsigned expected = 8;    // left(2) + top(2) + right(2) + bottom(2)

                if (!stream.in_check_rem(expected)) {
                    LOG(LOG_ERR,
                        "Truncated SuppressOutputPDUData(2): expected=%u remains=%zu",
                        expected, stream.in_remain());
                    throw Error(ERR_RDP_DATA_TRUNCATED);
                }
            }

            this->left_   = stream.in_uint16_le();
            this->top_    = stream.in_uint16_le();
            this->right_  = stream.in_uint16_le();
            this->bottom_ = stream.in_uint16_le();
        }
    }   // void receive(InStream & stream)
Beispiel #4
0
    void recv(InStream & stream)
    {
        if (!stream.in_check_rem(8)){
            LOG(LOG_ERR, "SC_CORE short header");
            throw Error(ERR_GCC);
        }

        this->userDataType = stream.in_uint16_le();
        this->length = stream.in_uint16_le();
        this->version = stream.in_uint32_le();
        if (this->length < 12) {
            if (this->length != 8) {
                LOG(LOG_ERR, "SC_CORE invalid length (%u)", this->length);
                throw Error(ERR_GCC);
            }
            return;
        }
        this->clientRequestedProtocols = stream.in_uint32_le();
        if (this->length < 16) {
            if (this->length != 12) {
                LOG(LOG_ERR, "SC_CORE invalid length (%u)", this->length);
                throw Error(ERR_GCC);
            }
            return;
        }
        this->earlyCapabilityFlags = stream.in_uint32_le();
        if (this->length != 16) {
            LOG(LOG_ERR, "SC_CORE invalid length (%u)", this->length);
            throw Error(ERR_GCC);
        }
    }
Beispiel #5
0
    explicit ShareData_Recv(InStream & stream, rdp_mppc_dec * dec = nullptr)
    //==============================================================================
    : CheckShareData_Recv(stream)
    , share_id(stream.in_uint32_le())
    , pad1(stream.in_uint8())
    , streamid(stream.in_uint8())
    , len(stream.in_uint16_le())
    , pdutype2(stream.in_uint8())
    , compressedType(stream.in_uint8())
    , compressedLen(stream.in_uint16_le())
    , payload([&stream, dec, this]() {
          if (this->compressedType & PACKET_COMPRESSED) {
              if (!dec) {
                  LOG(LOG_INFO, "ShareData_Recv: got unexpected compressed share data");
                  throw Error(ERR_SEC);
              }

              const uint8_t * rdata;
              uint32_t        rlen;

              dec->decompress(stream.get_data()+stream.get_offset(), stream.in_remain(),
                  this->compressedType, rdata, rlen);

              return InStream(rdata, 0, rlen);
          }
          else {
              return InStream(stream.get_current(), stream.in_remain());
          }
      }())
    // BEGIN CONSTRUCTOR
    {
        //LOG( LOG_INFO, "ShareData_Recv: pdutype2=%u len=%u compressedLen=%u payload_size=%u"
        //   , this->pdutype2, this->len, this->compressedLen, this->payload.size());
        stream.in_skip_bytes(stream.in_remain());
    } // END CONSTRUCTOR
Beispiel #6
0
 void recv(InStream & stream, uint16_t len)
 {
     this->len               = len;
     for (auto & glyph : this->GlyphCache) {
         glyph.CacheEntries         = stream.in_uint16_le();
         glyph.CacheMaximumCellSize = stream.in_uint16_le();
     }
     this->FragCache         = stream.in_uint32_le();
     this->GlyphSupportLevel = stream.in_uint16_le();
     this->pad2octets        = stream.in_uint16_le();
 }
Beispiel #7
0
 void recv(InStream & stream)
 {
     for (std::size_t i = 0; i < AV_ID_MAX; ++i) {
         NTLM_AV_ID id = static_cast<NTLM_AV_ID>(stream.in_uint16_le());
         uint16_t length = stream.in_uint16_le();
         if (id == MsvAvEOL) {
             // ASSUME last element is MsvAvEOL
             stream.in_skip_bytes(length);
             break;
         }
         this->add(id, stream.get_current(), length);
         stream.in_skip_bytes(length);
     }
 }
Beispiel #8
0
    void recv(InStream & stream, uint16_t len)override {
        this->len = len;

        unsigned int expected = 2 + 2 + ((this->len < 10) ? 0 : 2); /* colorPointerFlag(2) + colorPointerCacheSize(2) + pointerCacheSize*/
        if (!stream.in_check_rem(expected)){
            LOG(LOG_ERR, "Truncated CAPSTYPE_POINTER, need=%u remains=%zu",
                expected, stream.in_remain());
            throw Error(ERR_MCS_PDU_TRUNCATED);
        }

        this->colorPointerFlag = stream.in_uint16_le();
        this->colorPointerCacheSize = stream.in_uint16_le();
        if (this->len < 10) return;
        this->pointerCacheSize = stream.in_uint16_le();
    }
Beispiel #9
0
    static inline void prepare_compressed_data(InStream & compressed_data_stream, bool compressed,
        uint16_t & MatchCount, uint8_t const * & MatchDetails, uint8_t const * & Literals,
        size_t & literals_length)
    {
        if (compressed) {
            unsigned expected = 2; // MatchCount(2)
            if (!compressed_data_stream.in_check_rem(expected)) {
                LOG(LOG_ERR, "RDP61_COMPRESSED_DATA: data truncated, expected=%u remains=%zu",
                    expected, compressed_data_stream.in_remain());
                throw Error(ERR_RDP61_DECOMPRESS_DATA_TRUNCATED);
            }
            MatchCount = compressed_data_stream.in_uint16_le();

            expected = MatchCount * 8; // MatchCount(2) * (MatchLength(2) + MatchOutputOffset(2) + MatchHistoryOffset(4))
            if (!compressed_data_stream.in_check_rem(expected)) {
                LOG(LOG_ERR, "RDP61_COMPRESSED_DATA: data truncated, expected=%u remains=%zu",
                    expected, compressed_data_stream.in_remain());
                throw Error(ERR_RDP61_DECOMPRESS_DATA_TRUNCATED);
            }
            MatchDetails = compressed_data_stream.get_current();
            compressed_data_stream.in_skip_bytes(expected);
        }
        else {
            MatchCount   = 0;
            MatchDetails = nullptr;
        }

        literals_length = compressed_data_stream.in_remain();
        Literals        = (literals_length ? compressed_data_stream.get_current() : nullptr);
    }
 void recv(InStream & stream, uint16_t len)
 {
     this->len = len;
     this->cacheVersion = stream.in_uint8();
     this->pad1 = stream.in_uint8();
     this->pad2 = stream.in_uint16_le();
 }
Beispiel #11
0
        explicit ClientInputEventPDU_Recv(InStream & stream)

        : numEvents(
            [&stream](){
                if (!stream.in_check_rem(2)) {
                    LOG(LOG_ERR, "SlowPath::ClientInputEventPDU: data truncated (numEvents)");
                    throw Error(ERR_RDP_SLOWPATH);
                }

                auto numEvents = stream.in_uint16_le();
                const unsigned expected =
                      2                    // pad(2)
                    + numEvents * 12 // (time(4) + mes_type(2) + device_flags(2) + param1(2) + param2(2)) * 12
                    ;
                if (!stream.in_check_rem(expected)) {
                    LOG(LOG_ERR, "SlowPath::ClientInputEventPDU: data truncated, expected=%u remains=%zu",
                        expected, stream.in_remain());
                    throw Error(ERR_RDP_SLOWPATH);
                }

                stream.in_skip_bytes(2); // pad
                return numEvents;
            }()
        )
        // (time(4) + mes_type(2) + device_flags(2) + param1(2) + param2(2)) * 12
        , payload(stream.get_current(), this->numEvents * 12)
        {
            // This is the constructor body, we skip payload now that it is packaged

            stream.in_skip_bytes(this->payload.get_capacity());
        }
Beispiel #12
0
        explicit ExtendedMouseEvent_Recv(InStream & stream)
        : pointerFlags(0)
        , xPos(0)
        , yPos(0) {
            const unsigned expected =
                6; // pointerFlags(2) + xPos(2) + yPos(2)
            if (!stream.in_check_rem(expected)) {
                LOG(LOG_ERR, "SlowPath::ExtendedMouseEvent: data truncated, expected=%u remains=%zu",
                    expected, stream.in_remain());
                throw Error(ERR_RDP_SLOWPATH);
            }

            this->pointerFlags = stream.in_uint16_le();
            this->xPos         = stream.in_uint16_le();
            this->yPos         = stream.in_uint16_le();
        }
Beispiel #13
0
 void recv(InStream & stream, uint16_t len)
 {
     this->len = len;
     this->WndSupportLevel = stream.in_uint32_le();
     this->NumIconCaches = stream.in_uint8();
     this->NumIconCacheEntries = stream.in_uint16_le();
 }
Beispiel #14
0
inline void process_glyphcache(GlyphCache & gly_cache, InStream & stream) {
    const uint8_t cacheId = stream.in_uint8();
    const uint8_t nglyphs = stream.in_uint8();
    for (uint8_t i = 0; i < nglyphs; i++) {
        const uint16_t cacheIndex = stream.in_uint16_le();
        const int16_t  offset     = stream.in_sint16_le();
        const int16_t  baseline   = stream.in_sint16_le();
        const uint16_t width      = stream.in_uint16_le();
        const uint16_t height     = stream.in_uint16_le();

        const unsigned int   datasize = (height * nbbytes(width) + 3) & ~3;
        const uint8_t      * data     = stream.in_uint8p(datasize);

        server_add_char(gly_cache, cacheId, cacheIndex, offset, baseline, width, height, data);
    }
}
Beispiel #15
0
    explicit ShareControl_Recv(InStream & stream)
    : totalLength([&stream]() {
        if (!stream.in_check_rem(2+2)){
            LOG(LOG_ERR,
                "Truncated [4: ShareControl packet] , remains=%zu", stream.in_remain());
            throw Error(ERR_SEC);
        }
        return stream.in_uint16_le();
    }())
    , pduType(stream.in_uint16_le() & 0xF)
    , PDUSource([&stream, this]() {
        if (this->pduType == PDUTYPE_DEACTIVATEALLPDU && this->totalLength == 4) {
            // should not happen
            // but DEACTIVATEALLPDU seems to be broken on windows 2000
            return static_cast<uint16_t>(0);
        }
        return stream.in_uint16_le();
    }())
    , payload([&stream, this]() {
        if (this->pduType == PDUTYPE_DEACTIVATEALLPDU && this->totalLength == 4) {
            // should not happen
            // but DEACTIVATEALLPDU seems to be broken on windows 2000
            return InStream(stream.get_current(), 0);
        }

        if (this->totalLength < 6) {
            LOG(LOG_ERR, "ShareControl packet too short totalLength=%u pduType=%u mcs_channel=%u",
                this->totalLength, this->pduType, this->PDUSource);
            throw Error(ERR_SEC);
        }

        if (!stream.in_check_rem(this->totalLength - 6)) {
            LOG(LOG_ERR, "Truncated ShareControl packet, need=%u remains=%zu",
                this->totalLength - 6,
                stream.in_remain());
            throw Error(ERR_SEC);
        }
        return InStream(stream.get_current(), this->totalLength - 6);
    }())
    // body of constructor
    {
        if (this->totalLength == 0x8000) {
            LOG(LOG_ERR, "Expected ShareControl header, got flowMarker");
            throw Error(ERR_SEC);
        }
        stream.in_skip_bytes(this->payload.get_capacity());
    }
Beispiel #16
0
    void receive(InStream & stream, const RDPPrimaryOrderHeader & header) {
        //LOG(LOG_INFO, "RDPMultiDstBlt::receive: header fields=0x%02X", header.fields);

        header.receive_coord(stream, 0x0001, this->nLeftRect);
        header.receive_coord(stream, 0x0002, this->nTopRect);
        header.receive_coord(stream, 0x0004, this->nWidth);
        header.receive_coord(stream, 0x0008, this->nHeight);

        if (header.fields & 0x0010) {
            this->bRop = stream.in_uint8();
        }

        if (header.fields & 0x0020) {
            this->nDeltaEntries = stream.in_uint8();
        }

        if (header.fields & 0x0040) {
            uint16_t cbData = stream.in_uint16_le();
            //LOG(LOG_INFO, "cbData=%d", cbData);

            InStream rgbData(stream.get_current(), cbData);
            stream.in_skip_bytes(cbData);
            //hexdump_d(rgbData.get_current(), rgbData.get_capacity());

            uint8_t zeroBitsSize = ((this->nDeltaEntries + 1) / 2);
            //LOG(LOG_INFO, "zeroBitsSize=%d", zeroBitsSize);

            InStream zeroBits(rgbData.get_current(), zeroBitsSize);
            rgbData.in_skip_bytes(zeroBitsSize);

            uint8_t zeroBit = 0;

            for (uint8_t i = 0, m2 = 0; i < this->nDeltaEntries; i++, m2++) {
                if (m2 == 2) {
                    m2 = 0;
                }

                if (!m2) {
                    zeroBit = zeroBits.in_uint8();
                    //LOG(LOG_INFO, "0x%02X", zeroBit);
                }

                this->deltaEncodedRectangles[i].leftDelta = (!(zeroBit & 0x80) ? rgbData.in_DEP() : 0);
                this->deltaEncodedRectangles[i].topDelta  = (!(zeroBit & 0x40) ? rgbData.in_DEP() : 0);
                this->deltaEncodedRectangles[i].width     = (!(zeroBit & 0x20) ? rgbData.in_DEP() : 0);
                this->deltaEncodedRectangles[i].height    = (!(zeroBit & 0x10) ? rgbData.in_DEP() : 0);

                //LOG(LOG_INFO, "RDPMultiDstBlt::receive: delta rectangle=(%d, %d, %d, %d)",
                //    this->deltaEncodedRectangles[i].leftDelta, this->deltaEncodedRectangles[i].topDelta,
                //    this->deltaEncodedRectangles[i].width, this->deltaEncodedRectangles[i].height);

                zeroBit <<= 4;
            }
        }
    }   // void receive(InStream & stream, const RDPPrimaryOrderHeader & header)
Beispiel #17
0
    void recv(InStream & stream, uint16_t len)override {
        this->len = len;

        if (!stream.in_check_rem(2)) {
            LOG(LOG_ERR, "Truncated CompDeskCaps, need=2 remains=%zu",
                stream.in_remain());
            throw Error(ERR_MCS_PDU_TRUNCATED);
        }

        this->CompDeskSupportLevel = stream.in_uint16_le();
    }
Beispiel #18
0
    void recv(InStream & stream, uint16_t len) override {
        this->len = len;

        /* pad1(4) + pad2(4) + pad3(4) + pad4(4) + pad5(4) + pad6(4) + cache0Entries(2) + cache0MaximumCellSize(2) +
         * cache1Entries(2) + cache1MaximumCellSize(2) + cache2Entries(2) + cache2MaximumCellSize(2)
         */
        const unsigned expected = 36;
        if (!stream.in_check_rem(expected)){
            LOG(LOG_ERR, "Truncated BmpCacheCaps, need=%u remains=%zu",
                expected, stream.in_remain());
            throw Error(ERR_MCS_PDU_TRUNCATED);
        }

        this->pad1 = stream.in_uint32_le();
        this->pad2 = stream.in_uint32_le();
        this->pad3 = stream.in_uint32_le();
        this->pad4 = stream.in_uint32_le();
        this->pad5 = stream.in_uint32_le();
        this->pad6 = stream.in_uint32_le();
        this->cache0Entries = stream.in_uint16_le();
        this->cache0MaximumCellSize = stream.in_uint16_le();
        this->cache1Entries = stream.in_uint16_le();
        this->cache1MaximumCellSize = stream.in_uint16_le();
        this->cache2Entries = stream.in_uint16_le();
        this->cache2MaximumCellSize = stream.in_uint16_le();
      }
    explicit LogonInfoVersion2_Recv(InStream & stream) :
    Version(0),
    Size(0),
    SessionId(0),
    cbDomain(0),
    cbUserName(0) {
        memset(Pad,      0, sizeof(Pad));
        memset(Domain,   0, sizeof(Domain));
        memset(UserName, 0, sizeof(UserName));

        unsigned expected = 2 +     // Version(2)
                            4 +     // Size(4)
                            4 +     // SessionId(4)
                            4 +     // cbDomain(4)
                            4 +     // cbUserName(4)
                            558;    // Pad(558)
        if (!stream.in_check_rem(expected)) {
            LOG(LOG_ERR,
                "Truncated Logon Info Version 2 (data): expected=%u remains=%zu",
                expected, stream.in_remain());
            throw Error(ERR_RDP_DATA_TRUNCATED);
        }

        this->Version    = stream.in_uint16_le();
        this->Size       = stream.in_uint32_le();
        this->SessionId  = stream.in_uint32_le();
        this->cbDomain   = stream.in_uint32_le();
        this->cbUserName = stream.in_uint32_le();

        stream.in_copy_bytes(this->Pad, sizeof(this->Pad));

        expected = this->cbDomain +
                   this->cbUserName;    // SessionId(4)
        if (!stream.in_check_rem(expected)) {
            LOG(LOG_ERR,
                "Truncated Logon Info Version 2 (data): expected=%u remains=%zu",
                expected, stream.in_remain());
            throw Error(ERR_RDP_DATA_TRUNCATED);
        }

        stream.in_uni_to_ascii_str(this->Domain, this->cbDomain,
            sizeof(this->Domain));
        stream.in_uni_to_ascii_str(this->UserName, this->cbUserName,
            sizeof(this->UserName));

        LOG(LOG_INFO,
            "Logon Info Version 2 (data): Domain=\"%s\" UserName=\"%s\" SessionId=%d",
            this->Domain, this->UserName, this->SessionId);
    }   // LogonInfoVersion2_Recv(InStream & stream)
Beispiel #20
0
 explicit InputEvent_Recv(InStream & stream)
 : eventTime([&stream](){
     // time(4) + mes_type(2) + device_flags(2) + param1(2) + param2(2)
     if (!stream.in_check_rem(12)) {
         LOG(LOG_ERR, "SlowPath::InputEvent: data truncated, expected=12 remains=%zu", stream.in_remain());
         throw Error(ERR_RDP_SLOWPATH);
     }
     return stream.in_uint32_le();
 }())
 , messageType(stream.in_uint16_le())
  // device_flags(2) + param1(2) + param2(2)
 , payload(stream.get_current(), 6)
 // Body of constructor
 {
     stream.in_skip_bytes(this->payload.get_capacity());
 }
Beispiel #21
0
        explicit UnicodeKeyboardEvent_Recv(InStream & stream)
        : keyboardFlags(0)
        , unicodeCode(0) {
            const unsigned expected =
                6; // keyboardFlags(2) + unicodeCode(2) + pad2Octets(2)
            if (!stream.in_check_rem(expected)) {
                LOG(LOG_ERR, "SlowPath::UnicodeKeyboardEvent: data truncated, expected=%u remains=%zu",
                    expected, stream.in_remain());
                throw Error(ERR_RDP_SLOWPATH);
            }

            this->keyboardFlags = stream.in_uint16_le();
            this->unicodeCode   = stream.in_uint16_le();

            stream.in_skip_bytes(2); // pad2Octets
        }
 void recv(InStream & stream, uint16_t len)override {
     this->len = len;
     if (len != CAPLEN_BITMAPCACHE_REV2 || !stream.in_check_rem(len)) {
         LOG(LOG_ERR, "Broken CAPSTYPE_BITMAPCACHE_REV2, need=%u (%" PRIu16 ") remains=%zu",
                 CAPLEN_BITMAPCACHE_REV2, len, stream.in_remain());
                 throw Error(ERR_MCS_PDU_TRUNCATED);
     }
     this->cacheFlags    = stream.in_uint16_le();
     this->pad1          = stream.in_uint8();
     this->numCellCaches = stream.in_uint8();
     this->bitmapCache0CellInfo = stream.in_uint32_le();
     this->bitmapCache1CellInfo = stream.in_uint32_le();
     this->bitmapCache2CellInfo = stream.in_uint32_le();
     this->bitmapCache3CellInfo = stream.in_uint32_le();
     this->bitmapCache4CellInfo = stream.in_uint32_le();
     stream.in_skip_bytes(12);
 }
 explicit LogonInfoExtended_Recv(InStream & stream)
 : Length([&stream](){
     const unsigned expected = 2 +   // Length(2)
                               4;    // FieldsPresent(4)
     if (!stream.in_check_rem(expected)) {
         LOG(LOG_ERR,
             "Truncated Logon Info Extended (data): expected=%u remains=%zu",
             expected, stream.in_remain());
         throw Error(ERR_RDP_DATA_TRUNCATED);
     }
     return stream.in_uint16_le();
 }())
 , FieldsPresent(stream.in_uint32_le())
 , payload(stream.get_current(), stream.in_remain())
 {
     stream.in_skip_bytes(this->payload.get_capacity());
 }
Beispiel #24
0
    void recv(InStream & stream)
    {
        if (!stream.in_check_rem(12)){
            LOG(LOG_ERR, "CS_SECURITY short header");
            throw Error(ERR_GCC);
        }
        this->userDataType         = stream.in_uint16_le();
        this->length               = stream.in_uint16_le();

        if (this->length != 12){
            LOG(LOG_ERR, "CS_SECURITY bad header length=%d", this->length);
            throw Error(ERR_GCC);
        }

        this->encryptionMethods    = stream.in_uint32_le();
        this->extEncryptionMethods = stream.in_uint32_le();
    }
Beispiel #25
0
    void recv(InStream & stream)
    {
        //LOG(LOG_INFO, "CSMultiTransport");
        //hexdump_c(stream.get_current(), 8);
        if (!stream.in_check_rem(8)){
            LOG(LOG_ERR, "CS_MULTITRANSPORT short header");
            throw Error(ERR_GCC);
        }
        this->userDataType         = stream.in_uint16_le();
        this->length               = stream.in_uint16_le();

        if (this->length != 8){
            LOG(LOG_ERR, "CS_MULTITRANSPORT bad header length=%d", this->length);
            throw Error(ERR_GCC);
        }

        this->flags = stream.in_uint32_le();
    }
Beispiel #26
0
    void receive(InStream & stream, const RDPSecondaryOrderHeader &/* header*/)
    {
        using namespace RDP;

        this->cacheIndex = stream.in_uint8();
        LOG(LOG_INFO, "receiving colormap %u", this->cacheIndex);
        assert(this->cacheIndex < 6);

        uint16_t numberColors = stream.in_uint16_le();

        for (size_t i = 0; i < numberColors; i++) {
            uint8_t b = stream.in_uint8();
            uint8_t g = stream.in_uint8();
            uint8_t r = stream.in_uint8();
            stream.in_skip_bytes(1);
            this->palette.set_color(i, b|(g << 8)| (r << 16));
        }
    }
Beispiel #27
0
    void receive(InStream & stream) {
        unsigned expected = 18; /* destLeft(2) + destTop(2) + destRight(2) +
                                   destBottom(2) + width(2) + height(2) +
                                   bitsPerPixel(2) + flags(2) + bitmapLength(2) */
        if (!stream.in_check_rem(expected)) {
            LOG( LOG_ERR
               , "BitmapData::receive TS_BITMAP_DATA - Truncated data, need=%u, remains=%zu"
               , expected, stream.in_remain());
            throw Error(ERR_RDP_DATA_TRUNCATED);
        }

        this->dest_left      = stream.in_uint16_le();
        this->dest_top       = stream.in_uint16_le();
        this->dest_right     = stream.in_uint16_le();
        this->dest_bottom    = stream.in_uint16_le();
        this->width          = stream.in_uint16_le();
        this->height         = stream.in_uint16_le();
        this->bits_per_pixel = stream.in_uint16_le();
        this->flags          = stream.in_uint16_le();
        this->bitmap_length  = stream.in_uint16_le();

        assert(   (this->bits_per_pixel == 32)
                  || (this->bits_per_pixel == 24)
                  || (this->bits_per_pixel == 16)
                  || (this->bits_per_pixel == 15)
                  || (this->bits_per_pixel == 8 ));

        if (    (this->flags & BITMAP_COMPRESSION)
            && !(this->flags & NO_BITMAP_COMPRESSION_HDR)) {
            expected = 8; /* cbCompFirstRowSize(2) + cbCompMainBodySize(2) +
                             cbScanWidth(2) + cbUncompressedSize(2) */
            if (!stream.in_check_rem(expected)) {
                LOG( LOG_ERR
                   , "BitmapData::receive TS_CD_HEADER - Truncated data, need=18, remains=%zu"
                   , stream.in_remain());
                throw Error(ERR_RDP_DATA_TRUNCATED);
            }

            stream.in_skip_bytes(2);    /* cbCompFirstRowSize (2 bytes) */

            this->cb_comp_main_body_size = stream.in_uint16_le();
            this->cb_scan_width          = stream.in_uint16_le();
            this->cb_uncompressed_size   = stream.in_uint16_le();
        }
    }
    void receive(InStream & stream, const RDPPrimaryOrderHeader & header)
    {
        using namespace RDP;

        if (header.fields & 0x001) {
            this->back_mode = stream.in_uint16_le();
        }

        header.receive_coord(stream, 0x002, this->startx);
        header.receive_coord(stream, 0x004, this->starty);
        header.receive_coord(stream, 0x008, this->endx);
        header.receive_coord(stream, 0x010, this->endy);

        if (header.fields & 0x020) {
            receive_rdp_color(stream, this->back_color);
        }

        if (header.fields & 0x040) {
            this->rop2 = stream.in_uint8();
        }

        header.receive_pen(stream, 0x080, this->pen);
    }
Beispiel #29
0
 void recv(InStream & stream, uint16_t len)
 {
     this->len = len;
     this->flags = stream.in_uint16_le();
     this->VCChunkSize = stream.in_uint16_le();
 }
Beispiel #30
0
 void recv(InStream & stream, uint16_t len)override {
     this->len = len;
     this->offscreenSupportLevel = stream.in_uint32_le();
     this->offscreenCacheSize = stream.in_uint16_le();
     this->offscreenCacheEntries = stream.in_uint16_le();
 }