From b880c027a9a3ca88f4f18319e99b9ef27d1fffd8 Mon Sep 17 00:00:00 2001 From: sylvain Date: Tue, 22 Oct 2013 22:58:34 +0200 Subject: [PATCH] correct mcs bugs --- rdpy/main.py | 4 ++-- rdpy/protocol/network/type.py | 10 +++++++++- rdpy/protocol/rdp/ber.py | 9 ++++++--- rdpy/protocol/rdp/mcs.py | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/rdpy/main.py b/rdpy/main.py index b3809d8..1c22f64 100644 --- a/rdpy/main.py +++ b/rdpy/main.py @@ -31,7 +31,7 @@ if __name__ == '__main__': #w.show() from twisted.internet import reactor #reactor.connectTCP("127.0.0.1", 5901, factory.RfbFactory(protocol)) - #reactor.connectTCP("192.168.135.160", 3389, factory.RfbFactory(tpkt.TPKT(tpdu.TPDU()))) - reactor.connectTCP("192.168.56.1", 3389, factory.RfbFactory(tpkt.TPKT(tpdu.TPDU(mcs.MCS())))) + reactor.connectTCP("192.168.1.90", 3389, factory.RfbFactory(tpkt.TPKT(tpdu.TPDU(mcs.MCS())))) + #reactor.connectTCP("192.168.56.1", 3389, factory.RfbFactory(tpkt.TPKT(tpdu.TPDU(mcs.MCS())))) reactor.run() sys.exit(app.exec_()) \ No newline at end of file diff --git a/rdpy/protocol/network/type.py b/rdpy/protocol/network/type.py index 2ee4fbe..42f25dc 100644 --- a/rdpy/protocol/network/type.py +++ b/rdpy/protocol/network/type.py @@ -444,4 +444,12 @@ class Stream(StringIO): self.write_uint8(ord(c)) self.write_uint8(0) self.write_uint8(0) - self.write_uint8(0) \ No newline at end of file + self.write_uint8(0) + +def hexDump(src, length=16): + FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.' for x in range(256)]) + for c in xrange(0, len(src), length): + chars = src[c:c+length] + hexa = ' '.join(["%02x" % ord(x) for x in chars]) + printable = ''.join(["%s" % ((ord(x) <= 127 and FILTER[ord(x)]) or '.') for x in chars]) + print "%04x %-*s %s" % (c, length*3, hexa, printable) \ No newline at end of file diff --git a/rdpy/protocol/rdp/ber.py b/rdpy/protocol/rdp/ber.py index ef91baf..2756c9a 100644 --- a/rdpy/protocol/rdp/ber.py +++ b/rdpy/protocol/rdp/ber.py @@ -150,7 +150,10 @@ def writeBoolean(b): @param b: boolean @return: ber boolean structure ''' - return (writeUniversalTag(Tag.BER_TAG_BOOLEAN, False), writeLength(1), UInt8(int(b))) + boolean = UInt8(0) + if b: + boolean = UInt8(0xff) + return (writeUniversalTag(Tag.BER_TAG_BOOLEAN, False), writeLength(1), boolean) def readInteger(s): ''' @@ -190,9 +193,9 @@ def writeInteger(value): @param param: int or python long @return ber interger structure ''' - if value < 0xff: + if value <= 0xff: return (writeUniversalTag(Tag.BER_TAG_INTEGER, False), writeLength(1), UInt8(value)) - elif value < 0xff80: + elif value <= 0xffff: return (writeUniversalTag(Tag.BER_TAG_INTEGER, False), writeLength(2), UInt16Be(value)) else: return (writeUniversalTag(Tag.BER_TAG_INTEGER, False), writeLength(4), UInt32Be(value)) diff --git a/rdpy/protocol/rdp/mcs.py b/rdpy/protocol/rdp/mcs.py index 9d74859..0e93b62 100644 --- a/rdpy/protocol/rdp/mcs.py +++ b/rdpy/protocol/rdp/mcs.py @@ -61,7 +61,7 @@ class MCS(LayerAutomata): ccReqStream.writeType(ccReq) tmp = (ber.writeOctetstring("\x01"), ber.writeOctetstring("\x01"), ber.writeBoolean(True), - self.writeDomainParams(34, 2, 0, 0xffff), + self.writeDomainParams(34, 2, 0, 0xffff),self.writeDomainParams(1, 1, 1, 0x420), self.writeDomainParams(0xffff, 0xfc17, 0xffff, 0xffff), ber.writeOctetstring(ccReqStream.getvalue())) self._transport.send((ber.writeApplicationTag(Message.MCS_TYPE_CONNECT_INITIAL, sizeof(tmp)), tmp))