correct mcs bugs

This commit is contained in:
sylvain
2013-10-22 22:58:34 +02:00
parent b0949e6f3c
commit b880c027a9
4 changed files with 18 additions and 7 deletions

View File

@@ -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_())

View File

@@ -444,4 +444,12 @@ class Stream(StringIO):
self.write_uint8(ord(c))
self.write_uint8(0)
self.write_uint8(0)
self.write_uint8(0)
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)

View File

@@ -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))

View File

@@ -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))