add fastpath to be compatible with rdp 8.0
This commit is contained in:
@@ -1,13 +1,34 @@
|
||||
'''
|
||||
@author: sylvain
|
||||
'''
|
||||
#
|
||||
# Copyright (c) 2014 Sylvain Peyrefitte
|
||||
#
|
||||
# This file is part of rdpy.
|
||||
#
|
||||
# rdpy is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Use to manage RDP stack in twisted
|
||||
"""
|
||||
|
||||
from twisted.internet import protocol
|
||||
from rdpy.network.error import CallPureVirtualFuntion, InvalidValue
|
||||
from rdpy.network.layer import LayerMode
|
||||
import tpkt, tpdu, mcs, pdu
|
||||
|
||||
class RDPClientController(pdu.PDUClientListener):
|
||||
"""
|
||||
use to decode and dispatch to observer PDU messages and orders
|
||||
Manage RDP stack as client
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
@@ -17,19 +38,58 @@ class RDPClientController(pdu.PDUClientListener):
|
||||
self._clientObserver = []
|
||||
#transport layer
|
||||
self._pduLayer = pdu.PDU(self)
|
||||
#multi channel service
|
||||
self._mcsLayer = mcs.MCS(LayerMode.CLIENT, self._pduLayer)
|
||||
#transport pdu layer
|
||||
self._tpduLayer = tpdu.TPDU(LayerMode.CLIENT, self._mcsLayer)
|
||||
#transport packet (protocol layer)
|
||||
self._tpktLayer = tpkt.TPKT(self._tpduLayer, self._pduLayer)
|
||||
|
||||
def getPDULayer(self):
|
||||
def getProtocol(self):
|
||||
"""
|
||||
@return: PDU layer use by controller
|
||||
@return: return Protocol layer for twisted
|
||||
In case of RDP TPKT is the Raw layer
|
||||
"""
|
||||
return self._pduLayer
|
||||
return self._tpktLayer
|
||||
|
||||
def enablePerformanceSession(self):
|
||||
def setPerformanceSession(self):
|
||||
"""
|
||||
Set particular flag in RDP stack to avoid wallpaper, theming, menu animation etc...
|
||||
Set particular flag in RDP stack to avoid wall-paper, theme, menu animation etc...
|
||||
"""
|
||||
self._pduLayer._info.extendedInfo.performanceFlags.value = pdu.PerfFlag.PERF_DISABLE_WALLPAPER | pdu.PerfFlag.PERF_DISABLE_MENUANIMATIONS | pdu.PerfFlag.PERF_DISABLE_CURSOR_SHADOW | pdu.PerfFlag.PERF_DISABLE_THEMING
|
||||
|
||||
def setScreen(self, width, height):
|
||||
"""
|
||||
Set screen dim of session
|
||||
@param width: width in pixel of screen
|
||||
@param height: height in pixel of screen
|
||||
"""
|
||||
#set screen definition in MCS layer
|
||||
self._mcsLayer._clientSettings.core.desktopHeight.value = height
|
||||
self._mcsLayer._clientSettings.core.desktopWidth.value = width
|
||||
|
||||
def setUsername(self, username):
|
||||
"""
|
||||
Set the username for session
|
||||
@param username: username of session
|
||||
"""
|
||||
#username in PDU info packet
|
||||
self._pduLayer._info.userName.value = username
|
||||
|
||||
def setPassword(self, password):
|
||||
"""
|
||||
Set password for session
|
||||
@param password: password of session
|
||||
"""
|
||||
self._pduLayer._info.password.value = password
|
||||
|
||||
def setDomain(self, domain):
|
||||
"""
|
||||
Set the windows domain of session
|
||||
@param domain: domain of session
|
||||
"""
|
||||
self._pduLayer._info.domain.value = domain
|
||||
|
||||
def addClientObserver(self, observer):
|
||||
"""
|
||||
add observer to RDP protocol
|
||||
@@ -132,28 +192,15 @@ class ClientFactory(protocol.Factory):
|
||||
"""
|
||||
Factory of Client RDP protocol
|
||||
"""
|
||||
def __init__(self, width = 1024, height = 800):
|
||||
"""
|
||||
@param width: width of screen
|
||||
@param height: height of screen
|
||||
"""
|
||||
self._width = width
|
||||
self._height = height
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
'''
|
||||
"""
|
||||
Function call from twisted and build rdp protocol stack
|
||||
@param addr: destination address
|
||||
'''
|
||||
"""
|
||||
controller = RDPClientController()
|
||||
self.buildObserver(controller)
|
||||
mcsLayer = mcs.createClient(controller)
|
||||
|
||||
#set screen definition in MCS layer
|
||||
mcsLayer._clientSettings.core.desktopHeight.value = self._height
|
||||
mcsLayer._clientSettings.core.desktopWidth.value = self._width
|
||||
|
||||
return tpkt.TPKT(tpdu.createClient(mcsLayer));
|
||||
return controller.getProtocol();
|
||||
|
||||
def buildObserver(self, controller):
|
||||
'''
|
||||
@@ -162,9 +209,9 @@ class ClientFactory(protocol.Factory):
|
||||
raise CallPureVirtualFuntion("%s:%s defined by interface %s"%(self.__class__, "buildObserver", "ClientFactory"))
|
||||
|
||||
class ServerFactory(protocol.Factory):
|
||||
'''
|
||||
Factory of Serrve RDP protocol
|
||||
'''
|
||||
"""
|
||||
Factory of Server RDP protocol
|
||||
"""
|
||||
def __init__(self, privateKeyFileName, certificateFileName):
|
||||
"""
|
||||
@param privateKeyFileName: file contain server private key
|
||||
@@ -178,30 +225,30 @@ class ServerFactory(protocol.Factory):
|
||||
Function call from twisted and build rdp protocol stack
|
||||
@param addr: destination address
|
||||
"""
|
||||
pduLayer = pdu.PDU(pdu.PDUServerListener())
|
||||
return tpkt.TPKT(tpdu.createServer(mcs.createServer(pduLayer), self._privateKeyFileName, self._certificateFileName));
|
||||
#pduLayer = pdu.PDU(pdu.PDUServerListener())
|
||||
#return tpkt.TPKT(tpdu.createServer(mcs.createServer(pduLayer), self._privateKeyFileName, self._certificateFileName));
|
||||
|
||||
def buildObserver(self):
|
||||
'''
|
||||
build observer use for connection
|
||||
'''
|
||||
"""
|
||||
Build observer use for connection
|
||||
"""
|
||||
raise CallPureVirtualFuntion("%s:%s defined by interface %s"%(self.__class__, "buildObserver", "ServerFactory"))
|
||||
|
||||
class RDPClientObserver(object):
|
||||
'''
|
||||
class use to inform all RDP event handle by RDPY
|
||||
'''
|
||||
"""
|
||||
Class use to inform all RDP event handle by RDPY
|
||||
"""
|
||||
def __init__(self, controller):
|
||||
"""
|
||||
@param listener: RDP listener use to interact with protocol
|
||||
@param controller: RDP controller use to interact with protocol
|
||||
"""
|
||||
self._controller = controller
|
||||
self._controller.addClientObserver(self)
|
||||
|
||||
|
||||
def onBitmapUpdate(self, destLeft, destTop, destRight, destBottom, width, height, bitsPerPixel, isCompress, data):
|
||||
'''
|
||||
notify bitmap update
|
||||
"""
|
||||
Notify bitmap update
|
||||
@param destLeft: xmin position
|
||||
@param destTop: ymin position
|
||||
@param destRight: xmax position because RDP can send bitmap with padding
|
||||
@@ -211,5 +258,5 @@ class RDPClientObserver(object):
|
||||
@param bitsPerPixel: number of bit per pixel
|
||||
@param isCompress: use RLE compression
|
||||
@param data: bitmap data
|
||||
'''
|
||||
"""
|
||||
raise CallPureVirtualFuntion("%s:%s defined by interface %s"%(self.__class__, "onBitmapUpdate", "RDPClientObserver"))
|
||||
Reference in New Issue
Block a user