diff --git a/bin/rdpy-rdpclient.py b/bin/rdpy-rdpclient.py index 8b5d707..46a6503 100755 --- a/bin/rdpy-rdpclient.py +++ b/bin/rdpy-rdpclient.py @@ -29,7 +29,7 @@ from rdpy.protocol.rdp import rdp from rdpy.core.error import RDPSecurityNegoFail import rdpy.core.log as log -#log._LOG_LEVEL = log.Level.INFO +log._LOG_LEVEL = log.Level.INFO class RDPClientQtFactory(rdp.ClientFactory): """ diff --git a/bin/rdpy-rdpproxy.py b/bin/rdpy-rdpproxy.py index ab581aa..201c877 100755 --- a/bin/rdpy-rdpproxy.py +++ b/bin/rdpy-rdpproxy.py @@ -75,6 +75,7 @@ class ProxyServer(rdp.RDPServerObserver): if self._client is None: #try a connection domain, username, password = self._controller.getCredentials() + log.info("Credentials dump : connection from %s with %s\\%s [%s]"%(self._controller.getHostname(), domain, username, password)) width, height = self._controller.getScreen() reactor.connectTCP(self._target[0], int(self._target[1]), ProxyClientFactory(self, width, height, @@ -223,6 +224,7 @@ class ProxyClientFactory(rdp.ClientFactory): self._domain = domain self._username = username self._password = password + self._security = "ssl" def buildObserver(self, controller, addr): """ @@ -238,7 +240,22 @@ class ProxyClientFactory(rdp.ClientFactory): controller.setDomain(self._domain) controller.setUsername(self._username) controller.setPassword(self._password) - return ProxyClient(controller, self._server) + controller.setSecurityLevel(self._security) + return ProxyClient(controller, self._server) + + def clientConnectionLost(self, connector, reason): + """ + @summary: Connection lost event + @param connector: twisted connector use for rdp connection (use reconnect to restart connection) + @param reason: str use to advertise reason of lost connection + """ + #try reconnect with basic RDP security + if reason.type == error.RDPSecurityNegoFail: + #stop nego + log.info("due to security nego error back to standard RDP security layer") + self._security = "rdp" + connector.connect() + return class Shadow(rdp.RDPServerObserver): """ diff --git a/bin/rdpy-rdpscreenshot.py b/bin/rdpy-rdpscreenshot.py index 673980c..cd3c701 100755 --- a/bin/rdpy-rdpscreenshot.py +++ b/bin/rdpy-rdpscreenshot.py @@ -101,19 +101,16 @@ class RDPScreenShotFactory(rdp.ClientFactory): """ @summary: observer that connect, cache every image received and save at deconnection """ - def __init__(self, controller, width, height, security, path, timeout, reactor): + def __init__(self, controller, width, height, path, timeout, reactor): """ @param controller: {RDPClientController} @param width: {integer} width of screen @param height: {integer} height of screen - @param security: {str} (ssl | rdp) security level @param path: {str} path of output screenshot @param timeout: {float} close connection after timeout s without any updating @param reactor: twisted reactor """ rdp.RDPClientObserver.__init__(self, controller) - controller.setScreen(width, height); - controller.setSecurityLevel(security) self._buffer = QtGui.QImage(width, height, QtGui.QImage.Format_RGB32) self._path = path self._timeout = timeout @@ -147,8 +144,10 @@ class RDPScreenShotFactory(rdp.ClientFactory): def checkUpdate(self): self._controller.close(); - - return ScreenShotObserver(controller, self._width, self._height, self._security, self._path, self._timeout, self._reactor) + + controller.setScreen(width, height); + controller.setSecurityLevel(self._security) + return ScreenShotObserver(controller, self._width, self._height, self._path, self._timeout, self._reactor) def main(width, height, path, timeout, hosts): """ diff --git a/rdpy/protocol/rdp/lic.py b/rdpy/protocol/rdp/lic.py index 05307f6..90e5c57 100644 --- a/rdpy/protocol/rdp/lic.py +++ b/rdpy/protocol/rdp/lic.py @@ -264,21 +264,12 @@ class LicenseManager(object): self._transport = transport self._username = "" self._hostname = "" - - def generateKeys(self): - """ - @summary: generate keys for license session - """ - - + def recv(self, s): """ @summary: receive license packet from PDU layer @return true when license automata is finish - """ - with open("/tmp/toto", "wb") as f: - f.write(s.getvalue()[s.pos:].encode('base64')) - + """ licPacket = LicPacket() s.readType(licPacket) diff --git a/rdpy/protocol/rdp/sec.py b/rdpy/protocol/rdp/sec.py index 0d663d4..e04c25d 100644 --- a/rdpy/protocol/rdp/sec.py +++ b/rdpy/protocol/rdp/sec.py @@ -18,7 +18,7 @@ # """ -Some use full methods for security in RDP +RDP Standard security layer """ import sha, md5 diff --git a/setup.py b/setup.py index d11a432..946bb70 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import setuptools from distutils.core import setup, Extension setup(name='rdpy', - version='1.1.3', + version='1.2.0', description='Remote Desktop Protocol in Python', long_description=""" RDPY is a pure Python implementation of the Microsoft RDP (Remote Desktop Protocol) protocol. @@ -15,7 +15,8 @@ setup(name='rdpy', url='https://github.com/citronneur/rdpy', packages=[ 'rdpy', - 'rdpy.core', + 'rdpy.core', + 'rdpy.security', 'rdpy.protocol', 'rdpy.protocol.rdp', 'rdpy.protocol.rdp.pdu',