add gcc and mcs layer
This commit is contained in:
@@ -2,6 +2,16 @@
|
||||
@author: sylvain
|
||||
'''
|
||||
|
||||
class InvalidValue(Exception):
|
||||
'''
|
||||
raise when invalid value type occured
|
||||
'''
|
||||
def __init__(self, message):
|
||||
'''
|
||||
constructor with message
|
||||
'''
|
||||
Exception.__init__(self, message)
|
||||
|
||||
class InvalidExpectedDataException(Exception):
|
||||
'''
|
||||
raise when expected data on network is invalid
|
||||
|
||||
@@ -1,14 +1,100 @@
|
||||
'''
|
||||
Created on 12 aout 2013
|
||||
|
||||
@author: sylvain
|
||||
'''
|
||||
|
||||
import struct
|
||||
from StringIO import StringIO
|
||||
from error import InvalidValue
|
||||
|
||||
class Type(object):
|
||||
'''
|
||||
root type
|
||||
'''
|
||||
def write(self, s):
|
||||
'''
|
||||
interface definition of write function
|
||||
'''
|
||||
pass
|
||||
|
||||
def read(self, s):
|
||||
'''
|
||||
interface definition of read value
|
||||
'''
|
||||
pass
|
||||
|
||||
class SimpleType(Type):
|
||||
'''
|
||||
simple type
|
||||
'''
|
||||
def __init__(self, value):
|
||||
self._value = value
|
||||
|
||||
class ComplexType(Type):
|
||||
'''
|
||||
keep ordering declaration of simple type
|
||||
in list and transparent for other type
|
||||
'''
|
||||
def __init__(self):
|
||||
'''
|
||||
init list of simple value
|
||||
'''
|
||||
self._type = []
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
'''
|
||||
magic function to update type list
|
||||
'''
|
||||
if isinstance(value, Type):
|
||||
self._type.append(value)
|
||||
self.__dict__[name] = value
|
||||
|
||||
def __iter__(self):
|
||||
'''
|
||||
iteration over object
|
||||
'''
|
||||
for i in self._type:
|
||||
yield i
|
||||
|
||||
def write(self, s):
|
||||
'''
|
||||
call format on each ordered subtype
|
||||
'''
|
||||
for i in self._type:
|
||||
i.write(s)
|
||||
|
||||
class Uint8(SimpleType):
|
||||
'''
|
||||
unsigned byte
|
||||
'''
|
||||
def __init__(self, value):
|
||||
'''
|
||||
constructor check value range
|
||||
'''
|
||||
if value < 0 or value > 0xff:
|
||||
raise InvalidValue("invalid uint8 value")
|
||||
SimpleType.__init__(self, value)
|
||||
|
||||
def write(self, s):
|
||||
'''
|
||||
write value in stream s
|
||||
'''
|
||||
s.write(struct.pack("B", self._value))
|
||||
|
||||
def read(self, s):
|
||||
'''
|
||||
read value from stream
|
||||
'''
|
||||
self._value = struct.unpack("B",self.read(1))[0]
|
||||
|
||||
|
||||
class Stream(StringIO):
|
||||
|
||||
'''
|
||||
use string io inheritance
|
||||
'''
|
||||
def dataLen(self):
|
||||
'''
|
||||
no read length
|
||||
'''
|
||||
return self.len - self.pos
|
||||
|
||||
def read_uint8(self):
|
||||
@@ -38,6 +124,9 @@ class Stream(StringIO):
|
||||
def read_lesint32(self):
|
||||
return struct.unpack("<i",self.read(4))[0]
|
||||
|
||||
def writeType(self, t):
|
||||
t.write(self)
|
||||
|
||||
def write_uint8(self, value):
|
||||
self.write(struct.pack("B", value))
|
||||
|
||||
|
||||
56
rdpy/protocol/rdp/gcc.py
Normal file
56
rdpy/protocol/rdp/gcc.py
Normal file
@@ -0,0 +1,56 @@
|
||||
'''
|
||||
@author sylvain
|
||||
@summary gcc language
|
||||
'''
|
||||
#constants declaration
|
||||
#server data
|
||||
SC_CORE = 0x0C01
|
||||
SC_SECURITY = 0x0C02
|
||||
SC_NET = 0x0C03
|
||||
|
||||
#client data
|
||||
CS_CORE = 0xC001
|
||||
CS_SECURITY = 0xC002
|
||||
CS_NET = 0xC003
|
||||
CS_CLUSTER = 0xC004
|
||||
CS_MONITOR = 0xC005
|
||||
|
||||
#depth color
|
||||
RNS_UD_COLOR_8BPP = 0xCA01
|
||||
RNS_UD_COLOR_16BPP_555 = 0xCA02
|
||||
RNS_UD_COLOR_16BPP_565 = 0xCA03
|
||||
RNS_UD_COLOR_24BPP = 0xCA04
|
||||
|
||||
RNS_UD_24BPP_SUPPORT = 0x0001
|
||||
RNS_UD_16BPP_SUPPORT = 0x0002
|
||||
RNS_UD_15BPP_SUPPORT = 0x0004
|
||||
RNS_UD_32BPP_SUPPORT = 0x0008
|
||||
|
||||
RNS_UD_SAS_DEL = 0xAA03
|
||||
|
||||
#rdp version
|
||||
RDP_VERSION_4 = 0x00080001
|
||||
RDP_VERSION_5_PLUS = 0x00080004
|
||||
|
||||
RNS_UD_CS_SUPPORT_ERRINFO_PDU = 0x0001
|
||||
|
||||
class ClientCoreSettings:
|
||||
'''
|
||||
class that represent core setting of client
|
||||
'''
|
||||
rdpVersion = RDP_VERSION_5_PLUS
|
||||
desktopWidth = 800
|
||||
desktopHeight = 600
|
||||
kbdLayout = 0x409
|
||||
clientBuild = 2100
|
||||
clientName = "rdpy"
|
||||
keyboardType = 4
|
||||
keyboardSubType = 0
|
||||
keyboardFnKeys = 12
|
||||
postBeta2ColorDepth = RNS_UD_COLOR_24BPP
|
||||
|
||||
class ServerCoreSettings:
|
||||
'''
|
||||
server side core settings structure
|
||||
'''
|
||||
rdpVersion = RDP_VERSION_5_PLUS
|
||||
0
rdpy/protocol/rdp/mcs.py
Normal file
0
rdpy/protocol/rdp/mcs.py
Normal file
Reference in New Issue
Block a user