Code Monkey home page Code Monkey logo

rdpy's Introduction

RDPY Build Status PyPI version

Remote Desktop Protocol in twisted python.

RDPY is a pure Python implementation of the Microsoft RDP (Remote Desktop Protocol) protocol (client and server side). RDPY is built over the event driven network engine Twisted. RDPY support standard RDP security layer, RDP over SSL and NLA authentication (through ntlmv2 authentication protocol).

RDPY provides the following RDP and VNC binaries :

  • RDP Man In The Middle proxy which record session
  • RDP Honeypot
  • RDP screenshoter
  • RDP client
  • VNC client
  • VNC screenshoter
  • RSS Player

Build

RDPY is fully implemented in python, except the bitmap decompression algorithm which is implemented in C for performance purposes.

Dependencies

Dependencies are only needed for pyqt4 binaries :

  • rdpy-rdpclient
  • rdpy-rdpscreenshot
  • rdpy-vncclient
  • rdpy-vncscreenshot
  • rdpy-rssplayer

Linux

Example for Debian based systems :

sudo apt-get install python-qt4

OS X

Example for OS X to install PyQt with homebrew

$ brew install qt sip pyqt

Windows

x86 x86_64
PyQt4 PyQt4
PyWin32 PyWin32

Build

$ git clone https://github.com/citronneur/rdpy.git rdpy
$ pip install twisted pyopenssl qt4reactor service_identity rsa pyasn1
$ python rdpy/setup.py install

Or use PIP:

$ pip install rdpy

For virtualenv, you will need to link the qt4 library to it:

$ ln -s /usr/lib/python2.7/dist-packages/PyQt4/ $VIRTUAL_ENV/lib/python2.7/site-packages/
$ ln -s /usr/lib/python2.7/dist-packages/sip.so $VIRTUAL_ENV/lib/python2.7/site-packages/

RDPY Binaries

RDPY comes with some very useful binaries. These binaries are linux and windows compatible.

rdpy-rdpclient

rdpy-rdpclient is a simple RDP Qt4 client.

$ rdpy-rdpclient.py [-u username] [-p password] [-d domain] [-r rss_ouput_file] [...] XXX.XXX.XXX.XXX[:3389]

You can use rdpy-rdpclient in a Recorder Session Scenario, used in rdpy-rdphoneypot.

rdpy-vncclient

rdpy-vncclient is a simple VNC Qt4 client .

$ rdpy-vncclient.py [-p password] XXX.XXX.XXX.XXX[:5900]

rdpy-rdpscreenshot

rdpy-rdpscreenshot saves login screen in file.

$ rdpy-rdpscreenshot.py [-w width] [-l height] [-o output_file_path] XXX.XXX.XXX.XXX[:3389]

rdpy-vncscreenshot

rdpy-vncscreenshot saves the first screen update in file.

$ rdpy-vncscreenshot.py [-p password] [-o output_file_path] XXX.XXX.XXX.XXX[:5900]

rdpy-rdpmitm

rdpy-rdpmitm is a RDP proxy allows you to do a Man In The Middle attack on RDP protocol. Record Session Scenario into rss file which can be replayed by rdpy-rssplayer.

$ rdpy-rdpmitm.py -o output_dir [-l listen_port] [-k private_key_file_path] [-c certificate_file_path] [-r (for XP or server 2003 client)] target_host[:target_port]

Output directory is used to save the rss file with following format (YYYYMMDDHHMMSS_ip_index.rss) The private key file and the certificate file are classic cryptographic files for SSL connections. The RDP protocol can negotiate its own security layer If one of both parameters are omitted, the server use standard RDP as security layer.

rdpy-rdphoneypot

rdpy-rdphoneypot is an RDP honey Pot. Use Recorded Session Scenario to replay scenario through RDP Protocol.

$ rdpy-rdphoneypot.py [-l listen_port] [-k private_key_file_path] [-c certificate_file_path] rss_file_path_1 ... rss_file_path_N

The private key file and the certificate file are classic cryptographic files for SSL connections. The RDP protocol can negotiate its own security layer. If one of both parameters are omitted, the server use standard RDP as security layer. You can specify more than one files to match more common screen size.

rdpy-rssplayer

rdpy-rssplayer is use to replay Record Session Scenario (rss) files generates by either rdpy-rdpmitm or rdpy-rdpclient binaries.

$ rdpy-rssplayer.py rss_file_path

RDPY Qt Widget

RDPY can also be used as Qt widget through rdpy.ui.qt4.QRemoteDesktop class. It can be embedded in your own Qt application. qt4reactor must be used in your app for Twisted and Qt to work together. For more details, see sources of rdpy-rdpclient.

RDPY library

In a nutshell RDPY can be used as a protocol library with a twisted engine.

Simple RDP Client

from rdpy.protocol.rdp import rdp

class MyRDPFactory(rdp.ClientFactory):

    def clientConnectionLost(self, connector, reason):
        reactor.stop()

    def clientConnectionFailed(self, connector, reason):
        reactor.stop()

    def buildObserver(self, controller, addr):

        class MyObserver(rdp.RDPClientObserver):

            def onReady(self):
                """
                @summary: Call when stack is ready
                """
                #send 'r' key
                self._controller.sendKeyEventUnicode(ord(unicode("r".toUtf8(), encoding="UTF-8")), True)
                #mouse move and click at pixel 200x200
                self._controller.sendPointerEvent(200, 200, 1, true)

            def onUpdate(self, destLeft, destTop, destRight, destBottom, width, height, bitsPerPixel, isCompress, data):
                """
                @summary: Notify bitmap update
                @param destLeft: xmin position
                @param destTop: ymin position
                @param destRight: xmax position because RDP can send bitmap with padding
                @param destBottom: ymax position because RDP can send bitmap with padding
                @param width: width of bitmap
                @param height: height of bitmap
                @param bitsPerPixel: number of bit per pixel
                @param isCompress: use RLE compression
                @param data: bitmap data
                """
                
            def onSessionReady(self):
		        """
		        @summary: Windows session is ready
		        """

            def onClose(self):
                """
                @summary: Call when stack is close
                """

        return MyObserver(controller)

from twisted.internet import reactor
reactor.connectTCP("XXX.XXX.XXX.XXX", 3389, MyRDPFactory())
reactor.run()

Simple RDP Server

from rdpy.protocol.rdp import rdp

class MyRDPFactory(rdp.ServerFactory):

    def buildObserver(self, controller, addr):

        class MyObserver(rdp.RDPServerObserver):

            def onReady(self):
                """
                @summary: Call when server is ready
                to send and receive messages
                """

            def onKeyEventScancode(self, code, isPressed):
                """
                @summary: Event call when a keyboard event is catch in scan code format
                @param code: scan code of key
                @param isPressed: True if key is down
                @see: rdp.RDPServerObserver.onKeyEventScancode
                """

            def onKeyEventUnicode(self, code, isPressed):
                """
                @summary: Event call when a keyboard event is catch in unicode format
                @param code: unicode of key
                @param isPressed: True if key is down
                @see: rdp.RDPServerObserver.onKeyEventUnicode
                """

            def onPointerEvent(self, x, y, button, isPressed):
                """
                @summary: Event call on mouse event
                @param x: x position
                @param y: y position
                @param button: 1, 2, 3, 4 or 5 button
                @param isPressed: True if mouse button is pressed
                @see: rdp.RDPServerObserver.onPointerEvent
                """

            def onClose(self):
                """
                @summary: Call when human client close connection
                @see: rdp.RDPServerObserver.onClose
                """

        return MyObserver(controller)

from twisted.internet import reactor
reactor.listenTCP(3389, MyRDPFactory())
reactor.run()

Simple VNC Client

from rdpy.protocol.rfb import rfb

class MyRFBFactory(rfb.ClientFactory):

    def clientConnectionLost(self, connector, reason):
        reactor.stop()

    def clientConnectionFailed(self, connector, reason):
        reactor.stop()

    def buildObserver(self, controller, addr):
        class MyObserver(rfb.RFBClientObserver):

            def onReady(self):
                """
                @summary: Event when network stack is ready to receive or send event
                """

            def onUpdate(self, width, height, x, y, pixelFormat, encoding, data):
                """
                @summary: Implement RFBClientObserver interface
                @param width: width of new image
                @param height: height of new image
                @param x: x position of new image
                @param y: y position of new image
                @param pixelFormat: pixefFormat structure in rfb.message.PixelFormat
                @param encoding: encoding type rfb.message.Encoding
                @param data: image data in accordance with pixel format and encoding
                """

            def onCutText(self, text):
                """
                @summary: event when server send cut text event
                @param text: text received
                """

            def onBell(self):
                """
                @summary: event when server send biiip
                """

            def onClose(self):
                """
                @summary: Call when stack is close
                """

        return MyObserver(controller)

from twisted.internet import reactor
reactor.connectTCP("XXX.XXX.XXX.XXX", 3389, MyRFBFactory())
reactor.run()

rdpy's People

Contributors

christruncer avatar citronneur avatar cudeso avatar dnozay avatar manuteleco avatar mutchako avatar r04r avatar speidy avatar viktor-evdokimov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rdpy's Issues

please add a license.

Please add a copy of the GPLv3 license to the top-level directory. This makes it easy for people to find the terms.

how to use rdpy_rdpmitm.py with NLA ๏ผŸ(ubuntu14.04)

  1. ./rdpy-rdpmitm.py -o ./rss/ -n 192.168.0.12:3389
    [] INFO: ******************************************
    [] INFO: * NLA Security selected *
    [
    ] INFO: *******************************************
    no error ,but connect failed.
  2. ./rdpy-rdpmitm.py -o ./rss/ -k ./key/ser.key -c ./key/srv.crt -n 192.168.0.12:3389
    Unhandled Error
    rdpy.core.error.RDPSecurityNegoFail: negotiation failure code 5

Build Issue

Hey there,

First off, I know this is a work in project (so it seems). Having this built, would be AWESOME. I've been searching for a pure python RDP client, I would love to see this.

I tried building rdpy after cloning it, but it seems I am getting an error. I'm using Kali linux to test this on. Figured I'd post the error here for you:

scons -C rdpy/rdpy/core install
scons: Entering directory `/mnt/hgfs/gitrepos/rdpy/rdpy/core'
scons: Reading SConscript files ...
TypeError: File /mnt/hgfs/gitrepos/rdpy/rdpy/core/Sconstruct found where directory expected.:
File "/mnt/hgfs/gitrepos/rdpy/rdpy/core/SConstruct", line 4:
script_dir = os.path.dirname(os.path.realpath(Dir("#/Sconstruct").abspath))
File "/usr/lib/scons/SCons/Script/SConscript.py", line 614:
return method(_args, *_kw)
File "/usr/lib/scons/SCons/Environment.py", line 1978:
return self.fs.Dir(s, _args, *_kw)
File "/usr/lib/scons/SCons/Node/FS.py", line 1351:
return self._lookup(name, directory, Dir, create)
File "/usr/lib/scons/SCons/Node/FS.py", line 1318:
return root._lookup_abs(p, fsclass, create)
File "/usr/lib/scons/SCons/Node/FS.py", line 2215:
result.diskcheck_match()
File "/usr/lib/scons/SCons/Node/FS.py", line 1504:
"File %s found where directory expected.")
File "/usr/lib/scons/SCons/Node/FS.py", line 384:
return self.func(_args, *_kw)
File "/usr/lib/scons/SCons/Node/FS.py", line 405:
raise TypeError(errorfmt % node.abspath)

Screenshot Capability?

So, I have a use case that I would love to use rdpy for (assuming you were cool with it). I write a tool which is designed to take screenshots of web apps (along with other information), and aggregate all of that into a report. This really helps make the information gathering phase of pen tests go easier as we can automate this process.

I'd LOVE to be able to add in the ability to screenshot workstations/servers over RDP. This would also be great information to have for pen tests. I've never really developed with pyqt, so I figured I'd ask you first. Is there any easy way that you could add in the ability to take screenshots of the open window of rdpy? The most likely scenario how I would use this is to either take a screenshot of the login page itself (when not providing a username or password), or to take a screenshot after successfully having logged into the remote system. Is there any way you would be interested in adding a switch, or something that I could invoke which would screenshot the current rdpy screen? I'd really love that ability :)

Thanks again!

virtual channels support in rdpy

hello guys,

I'm going over your code and it seems like you don't support virtual channels redirection in rdpy yet.
moreover, I couldn't find the right place to add a support for other channels (I mostly see global channel messages).

  1. do you plan to add support for virtual channels in rdpy?
  2. what is the right place to implement and catch VCs messages ?

thanks.

FreeRDP and server side library whern use standard RDP security layer

[18:02:20:794] [10716:-1236563136] [ERROR][com.freerdp.core] - invalid signature length (got 56, expected 64)
[18:02:20:794] [10716:-1236563136] [ERROR][com.freerdp.core.gcc] - gcc_read_server_data_blocks: gcc_read_server_security_data failed
[18:02:20:794] [10716:-1236563136] [ERROR][com.freerdp.core.gcc] - gcc_read_conference_create_response: gcc_read_server_data_blocks failed
[18:02:20:794] [10716:-1236563136] [ERROR][com.freerdp.core] - gcc_read_conference_create_response failed
[18:02:20:794] [10716:-1236563136] [ERROR][com.freerdp.core.connection] - rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed

Exception when starting RDP client on os x 10.9

Followed installation instructions.

on

 rdpy-rdpclient.py server-name

Rdp window opens and I have a popup with this text:

 Lost connection : [Failure instance: Traceback (failure with no frames): 
 <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly. ]

And here is what I have in terminal:

INFO : failed to auto detect keyboard layout [Errno 2] No such file or directory
INFO : keyboard layout set to en
INFO : *******************************************
INFO : *          NLA Security selected          *
INFO : *******************************************
^[[A2015-03-13 11:48:59.010 Python[52516:d07] modalSession has been exited 
prematurely - check for a reentrant call to endModalSession:

pyqt installed via homebrew (brew install qt sip pyqt)

I did not expected it to work on os x 10.9 as you don't mentioned os x at all, but it was worth checking out. If it would've work for me, that going to be my replacement for CoRD as I cannot make changes to that, and contributing to python source code is actually an option.

Thank you for this project!

rdpy.core.error.InvalidSize in rdp-rdpclient.py

I'm connecting to a test VM, when I use rdesktop is all fine but with rdpy-rdpclient here's what I got. I tried removing some options, changing width&height, but no luck. :-(

% rdpy-rdpclient.py -u username -p password -w 800 -l 600 -r test.rss 192.168.1.102
INFO : keyboard layout set to en
ERROR : Error during read <class 'rdpy.protocol.rdp.gcc.ServerCoreData'>::clientRequestedProtocol
ERROR : Error during read <class 'rdpy.protocol.rdp.gcc.DataBlock'>::dataBlock
ERROR : Error during read <class 'rdpy.protocol.rdp.gcc.Settings'>::settings
Unhandled Error
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib64/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib64/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib64/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/lib64/python2.7/site-packages/qtreactor/qt4base.py", line 100, in _read
    data = w.doRead()
  File "/usr/lib64/python2.7/site-packages/twisted/internet/tcp.py", line 214, in doRead
    return self._dataReceived(data)
  File "/usr/lib64/python2.7/site-packages/twisted/internet/tcp.py", line 220, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/usr/lib64/python2.7/site-packages/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/usr/lib64/python2.7/site-packages/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/usr/lib64/python2.7/site-packages/rdpy/protocol/rdp/x224.py", line 147, in recvData
    self._presentation.recv(data)
  File "/usr/lib64/python2.7/site-packages/rdpy/protocol/rdp/mcs.py", line 372, in recvConnectResponse
    self._serverSettings = gcc.readConferenceCreateResponse(data)
  File "/usr/lib64/python2.7/site-packages/rdpy/protocol/rdp/gcc.py", line 581, in readConferenceCreateResponse
    s.readType(serverSettings)
  File "/usr/lib64/python2.7/site-packages/rdpy/core/type.py", line 894, in readType
    value.read(self)
  File "/usr/lib64/python2.7/site-packages/rdpy/core/type.py", line 97, in read
    self.__read__(s)
  File "/usr/lib64/python2.7/site-packages/rdpy/core/type.py", line 477, in __read__
    raise e
rdpy.core.error.InvalidSize: Impossible to read type <class 'rdpy.protocol.rdp.gcc.ServerCoreData'> : read length is too small

RDP Connection Issue/Error

Hi there,

I'm attempting to loop over connecting to multiple machines via RDP, and I'm getting an error in rdpy. If I'm writing this code wrong, I'd love to know, otherwise I wanted to report this bug to you. The pastebin here (http://pastebin.com/3Rx4vd5B) shows the error that I'm getting. The top is the error, the bottom part is the specific function I am using to connect via RDP and make a screenshot.

If you need to see my full code, it's here - https://github.com/ChrisTruncer/EyeWitness/tree/Eyewitness_deaux_Shmoo

timeout needed for vncscreenshot

thank you for making these tools, can you please port the timeout fix you did for the rdp one to the vnc bin? it is badly broke on my system and im sure timeout would help greatly. thank you

rdpy-rdpclient.py Connection failed ?

C:\Python27\Scripts>rdpy-rdpclient.py -w 900 -l 500 81.196.188.63:3389
[] INFO: -268368887
[
] INFO: keyboard layout set to en
[*] INFO: Connection failed : [Failure instance: Traceback (failure with no frames): <
0060: A connection attempt failed because the connected party did not properly respond after
s failed to respond..

why ?
How can i solve this?
if i use x64 version is better?

exceptions.AttributeError in rdpy-rdpmitm.py

Tested freerdp version 1.2.0_beta1_pre20141115 against rdpmitm, here's the output:

% ./rdpy-rdpmitm.py -o /tmp 192.168.56.3
Unhandled Error
Traceback (most recent call last):
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 215, in doRead
    return self._dataReceived(data)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 221, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "build/bdist.linux-x86_64/egg/rdpy/core/layer.py", line 209, in dataReceived

  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/tpkt.py", line 195, in readData

  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/x224.py", line 147, in recvData

  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/mcs.py", line 520, in recvConnectInitial

exceptions.AttributeError: 'NoneType' object has no attribute 'channelDefArray'

rdpy.core.error.InvalidExpectedDataException in rdpy-rdpmitm.py

I have tried rdpy-rdpmitm.py connecting to a target Win7 machine. If I use rdpy-rdpclient.py it works like a charm, but if I try with rdesktop here's what happens. Still haven't tried with Microsoft's Terminal Services client mstsc.

% ./rdpy-rdpmitm.py -o /tmp 192.168.56.3
ERROR : Error during read <class 'rdpy.protocol.rdp.x224.X224DataHeader'>::messageType
Unhandled Error
Traceback (most recent call last):
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 215, in doRead
    return self._dataReceived(data)
  File "venv/lib/python2.7/site-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 221, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "build/bdist.linux-x86_64/egg/rdpy/core/layer.py", line 209, in dataReceived

  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/tpkt.py", line 195, in readData

  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/x224.py", line 146, in recvData

  File "build/bdist.linux-x86_64/egg/rdpy/core/type.py", line 897, in readType

  File "build/bdist.linux-x86_64/egg/rdpy/core/type.py", line 97, in read

  File "build/bdist.linux-x86_64/egg/rdpy/core/type.py", line 477, in __read__

rdpy.core.error.InvalidExpectedDataException: <class 'rdpy.core.type.UInt8'> const value expected 240 != 128

How do I use rdpy-rdpmitm.py

Tried -o ~/rdp -n IP_ADDRESS didn't seem to work (stuck).
How am I suppose to use it? How do I give the credentials?
Can I use this to record and replay the entire session or does it record just the login?

Thanks,
Hanan.

LWin key press is not working

I want to open Explorer on the remote machine, to which I joined by the rdpy.
To do this, i need to press the hotkeys win + e.
I do this with the following code:
self._controller.sendKeyEventScancode (347, True)
self._controller.sendKeyEventScancode (18, True)
self._controller.sendKeyEventScancode (18, False)
self._controller.sendKeyEventScancode (347, False)
Since the keys scancode lwin = 347.
But the key is not pressed.
Can you please tell me what code i should write to do this.

Credentials data

Hi, is it possible to get credentials data from the .rss files, or by mitmproxy programmatically?

Can I dump the rss file into a video format?

Hi,
Is there a way to convert the rss file into any video formats so that I can fast forward the RDP capture. I have a big capture file that I want to go through at a fast rate. Also, if there is a way that this can be done directly in rssplayer that would also be useful.

Thanks.

RDPScreenshot Bug

Hi there again!

I'm trying to go through and test your latest commits before I push out my stuff (finally), and I am running into a bug when trying to screenshot a rdp server.

I removed the IP address, but if you need one, let me know and I can send you one privately to test against. Here is the crash dump - http://pastebin.com/PtcytEsw

Thanks!

rdpy-rdphoneypot

When i'm using Recorded Session Scenario to replay - artifacts are appear. Example screen attached.
test

If an exception is thrown, all screenshots are black

Hi there,

So I know that currently older versions of RDP are not supported. When RDPY connects to one of those older systems, an exception is thrown (obviously). However, if the same reactor is used after the previous exception has been hit, all of the following screenshots are only black screens.

This function (https://github.com/ChrisTruncer/EyeWitness/blob/Eyewitness_deaux_Shmoo/EyeWitness.py#L741-772) iterates over a list containing multiple IPs to connect to. If one of the IPs is running an old version of RDP, all screenshots will be black.

To re-create this ideally in a simpler manner, I'm going to try to edit your script to encounter the same issue. Try using this here - http://pastebin.com/8PsyVSA3

Just change the values of all_machines to IPs of systems on your network. Make one of them a Windows XP machine (or any unsupported RDP system). The script will likely finish, but all screenshots are black, even though two out of the three machines should have a screenshot.

Hope this helps to clarify the issue I am having. Just let me know otherwise.

rdpy-rdpmitm unhandled error

Hello,

The server is 192.168.18.65(windows server 2003), and I was trying to simulate a MITM attack. But when I use a client(windows XP) to connect 192.168.18.30(the ubuntu's IP)......
screenshot

rdpy-rdphoneypot.py: service_identity and exception problem

Hi,
Thank you for providing rpdy!

I am encountering two problems:

  • I cannot seem to get rid of the UserWarning about service_identity not being installed. I am using virtualenv and installed the service_identity module, both using pip and easy_install. The service_identity files are installed, but the warning remains?
  • The second problem occurs when I try to connect via rdp to the virtual machine running rdpy-rdphoneypot, see exception error below.

Any help would be appreciated.

rpdy_error_message

rdpy-rdpmitm.py 2 Problems

The client (windows) no longer prompts you for credentials before you establish a remote desktop connection, so no logon data is stored in cleartext.
login_prompt This window doesn't appear..
2.
The keyboard layout of the client isn't detected automatically, always the US keyboard will be used even if the client has a different layout. I think always the default value found in gcc.py self.kbdLayout = UInt32Le(KeyboardLayout.US) will be used cause if i change that value i get a different keyboard layout.

Got a workaround for keyboard layout for me (chaniung the gcc.py self.kbdLayout = UInt32Le(KeyboardLayout.US value) so that is solved for me only the credentials Problem is still valid

rdpy.core.error.InvalidExpectedDataException: Invalid MCS PDU : ERECT_DOMAIN_REQUEST expected

When running rdpy-rdphoneypot.py on Ubuntu 14.04 x64, some connections cause the following error:

[*] INFO:       Connection from xx.xxx.x.xx:33804
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 208, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 214, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/usr/local/lib/python2.7/dist-packages/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy/protocol/rdp/x224.py", line 148, in recvData
    self._presentation.recv(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy/protocol/rdp/t125/mcs.py", line 542, in recvErectDomainRequest
    raise InvalidExpectedDataException("Invalid MCS PDU : ERECT_DOMAIN_REQUEST expected")
rdpy.core.error.InvalidExpectedDataException: Invalid MCS PDU : ERECT_DOMAIN_REQUEST expected

X Server Screenshots?

Hi there,

I know you don't have this in here currently, but I was curious if you thought about adding support for linux X servers? In the event that the server is set to allow unauthenticated access, users could screenshot the active desktop. Would that be something you would consider adding in?

waiting license packet

[*] INFO:   *******************************************
[*] INFO:   *          NLA Security selected          *
[*] INFO:   *******************************************
Unhandled Error
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\twisted\python\log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Python27\lib\site-packages\twisted\python\log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Python27\lib\site-packages\twisted\python\context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Python27\lib\site-packages\twisted\python\context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "C:\Python27\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 209, in doRead
    return self._dataReceived(data)
  File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 215, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "C:\Python27\lib\site-packages\twisted\protocols\tls.py", line 422, in dataReceived
    self._flushReceiveBIO()
  File "C:\Python27\lib\site-packages\twisted\protocols\tls.py", line 392, in _flushReceiveBIO
    ProtocolWrapper.dataReceived(self, bytes)
  File "C:\Python27\lib\site-packages\twisted\protocols\policies.py", line 120, in dataReceived
    self.wrappedProtocol.dataReceived(data)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\protocol\rdp\nla\cssp.py", line 289, in <lambda>
    self.dataReceived = lambda x: self.__class__.dataReceived(self, x)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\protocol\rdp\nla\cssp.py", line 208, in dataReceived
    self._layer.dataReceived(data)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\core\layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\protocol\rdp\tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\protocol\rdp\x224.py", line 148, in recvData
    self._presentation.recv(data)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\protocol\rdp\t125\mcs.py", line 243, in recvData
    self._channels[channelId].recv(data)
  File "C:\Users\sjuul\workspace\rdpy\rdpy\protocol\rdp\sec.py", line 636, in recvLicenceInfo
    raise InvalidExpectedDataException("waiting license packet")
rdpy.core.error.InvalidExpectedDataException: waiting license packet

I'm trying to set up an rdp proxy by modifying the mitm code not to log the data. However I get the error above if I try to connect to the proxy

Unhandled Error Nego fail

Unhandled Error
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\twisted\python\log.py", line 88, in callWi
thLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Python27\lib\site-packages\twisted\python\log.py", line 73, in callWi
thContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Python27\lib\site-packages\twisted\python\context.py", line 118, in c
allWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Python27\lib\site-packages\twisted\python\context.py", line 81, in ca
llWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "C:\Python27\lib\site-packages\qtreactor\qt4base.py", line 100, in _read
    data = w.doRead()
  File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 209, in doR
ead
    return self._dataReceived(data)
  File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 215, in _da
taReceived
    rval = self.protocol.dataReceived(data)
  File "build\bdist.win32\egg\rdpy\protocol\rdp\nla\cssp.py", line 208, in dataR
eceived

  File "build\bdist.win32\egg\rdpy\core\layer.py", line 209, in dataReceived

  File "build\bdist.win32\egg\rdpy\protocol\rdp\tpkt.py", line 195, in readData

  File "build\bdist.win32\egg\rdpy\protocol\rdp\x224.py", line 199, in recvConne
ctionConfirm

rdpy.core.error.RDPSecurityNegoFail: negotiation failure code 2

Hello, why this error is unhandled? Can I catch it (so it is not displayed in the console) so as not to disrupt the logic of the program?

Qt5 support

Qt4 has been deprecated and Qt5 (5.6 long term support, 5.7 latest). Unfortunately PyQt4 is no longer supported through homebrew on macOS and everything is migrating to Qt5 and so rdpy no longer functions.

Focus on window after alt+tab

I opened notepad and minimize it. Next, I run script rdpy and logon to the system, introduced alt + tab, then several keys through sendKeyEventUnicode. Then I come in again through the normal login. It turns out that window becomes active, but keys is not pressed (so with rdpy script letters are still introduced into the old window). So problem is that we need to wait until window will be in focus.
Another thing (that's my actually problem): I run a console with "win + r", then I want to enter a command. But the window "Run" out of focus. So all my further keys go wrong.

Simplest way to test a connection

So, Im using this code:

`#!/usr/bin/env python

-- coding: utf-8 --

from rdpy.protocol.rdp import rdp
from twisted.internet import reactor
from rdpy.core.error import RDPSecurityNegoFail

class RDPFactory(rdp.ClientFactory):

def __init__(self, username, password):
    self.username = username
    self.password = password

def clientConnectionLost(self, connector, reason):
    print "Connection lost. Reason: %s" % reason.type
    reactor.stop()

def clientConnectionFailed(self, connector, reason):
    print "Connection Failed. Reason: %s" % reason.type
    reactor.stop()

def buildObserver(self, controller, addr):
    controller.setUsername(self.username)
    controller.setPassword(self.password)

    class MyObserver(rdp.RDPClientObserver):

        def onReady(self):
            """
            @summary: Call when stack is ready
            """
            print "Observer ready"

        def onClose(self):
            """
            @summary: Call when stack is close
            """
            print "Obsever closed"

    return MyObserver(controller)

`
Is there a way to have a credentials callback? If the username and password is wrong, how can I show it to the user?

Thanks

RDPY client/server test

Hi, Thanks for your efforts in creating this library and sharing with us!

I am trying to use this code to handle some actions on a remote machine. I am able to connect to the remote machine using the rdpy client code sample, however, I am not able to send any mouse or key events to the remote machine. How do I achieve this?

Do I need to run the rdpy server code on the remote machine? if so, how can I do it since the port 3389 is already in use by the TCP services on windows and the rdpy server code throws exception saying that it cant listen on port 3389 since its already being listened by the windows TCP services.

Let me know...Thanks in advance!

Executing batch/script and recieve the result

Thanks for your project. It's great.

I'm trying to implement a Python script to processing a list of RDP servers and run a batch script with saving results. Can you give me any advice for this task. Thanks a lot.

dpy-rdphoneypot.py is broken

$ rdpy-rdphoneypot.py                                                                                                                                         LA: 0.24 
[*] INFO:	Build size map
[*] INFO:	Connection from 127.0.0.1:48412
Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in doRead
    return self._dataReceived(data)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 221, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "build/bdist.linux-x86_64/egg/rdpy/core/layer.py", line 209, in dataReceived
    
  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    
  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/x224.py", line 148, in recvData
    
  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/t125/mcs.py", line 243, in recvData
    
  File "build/bdist.linux-x86_64/egg/rdpy/core/layer.py", line 102, in <lambda>
    
  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/sec.py", line 470, in recv
    
  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/pdu/layer.py", line 504, in recvClientFontListPDU
    
  File "build/bdist.linux-x86_64/egg/rdpy/protocol/rdp/rdp.py", line 480, in onReady
    
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.2-py2.7-linux-x86_64.egg/EGG-INFO/scripts/rdpy-rdphoneypot.py", line 56, in onReady
    rssFilePath = sorted(self._rssFileSizeList, key = lambda x: abs(x[0][0] * x[0][1] - size))[0][1]
exceptions.IndexError: list index out of range

Stream is too small to read expected SimpleType in rdp-rssplayer.py

[] ERROR: Error during read <class 'rdpy.core.rss.UpdateEvent'>::length
[
] ERROR: Error during read <class 'rdpy.core.rss.Event'>::event
Traceback (most recent call last):
File "/root/Documents/rdpy/rdpy/bin/rdpy-rssplayer.py", line 104, in
QtCore.QTimer.singleShot(e.timestamp.value,lambda:loop(widget, rssFile, e))
File "/root/Documents/rdpy/rdpy/bin/rdpy-rssplayer.py", line 103, in loop
e = rssFile.nextEvent()
File "build/bdist.linux-x86_64/egg/rdpy/core/rss.py", line 282, in nextEvent
File "build/bdist.linux-x86_64/egg/rdpy/core/type.py", line 898, in readType
File "build/bdist.linux-x86_64/egg/rdpy/core/type.py", line 97, in read
File "build/bdist.linux-x86_64/egg/rdpy/core/type.py", line 478, in read
rdpy.core.error.InvalidSize: Stream is too small to read expected SimpleType

Hitting an exception in type.py on line 478

def __read__(self, s):
    """
    @summary:  Read inner value from stream
                Use struct package to unpack
                In accordance of structFormat and typeSize fields
    @param s: Stream that will be read
    @raise InvalidSize: if there is not enough data in stream
    """
    if s.dataLen() < self._typeSize:
        raise InvalidSize("Stream is too small to read expected SimpleType ")			

    self.value = struct.unpack(self._structFormat, s.read(self._typeSize))[0]

dataLen is 1 but typeSize is 4

rdpy-rdpserver ?

Hello,

In your opinion, is it possible to have a python RDP server (rdpy-rdpserver) thanks to this project?

The aim would be to use this project client side and server side in order to don't use RDP inherent in Windows.

Thank you in advance for your response,

Unhandled Error in rdpy-rdphoneypot.py

Hi,

Cool project, love the idea. I was testing out the rdpy-rdphoneypot.py and I've encountered the following errors when testing with hydra and ncrack. I'm running Ubuntu 12.04.5 LTS and Python 2.7.3. Please let me know if you need any more info.

Thanks,
Zach

Here's the stack trace when I test with Hydra:

Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 215, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 221, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/protocol/rdp/x224.py", line 147, in recvData
    data.readType(header)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/core/type.py", line 897, in readType
    value.read(self)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/core/type.py", line 97, in read
    self.__read__(s)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/core/type.py", line 477, in __read__
    raise e
rdpy.core.error.InvalidExpectedDataException: <class 'rdpy.core.type.UInt8'> const value expected 240 != 128

Here's the stack trace from ncrack:

Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 215, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 221, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/protocol/rdp/x224.py", line 148, in recvData
    self._presentation.recv(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/protocol/rdp/t125/mcs.py", line 544, in recvErectDomainRequest
    per.readInteger(data)
  File "/usr/local/lib/python2.7/dist-packages/rdpy-1.3.0-py2.7-linux-x86_64.egg/rdpy/protocol/rdp/t125/per.py", line 144, in readInteger
    raise InvalidValue("invalid integer size %d"%size)
rdpy.core.error.InvalidValue: invalid integer size 0

Unknown scancode in rdpy-rssplayer

Hello,

When replaying an RSS file with the rdpy-rssplayer, the keystrokes are displayed, but not all of them. Some are displayed as "" where xx is an hexadecimal code.

Is it the expected behavior ?
How can I get the real key pressed (specifying the keyboard layout somewhere?) ?

In last resort how can I map those hexadecimal value to an actual character or key that was pressed ?

Thanks and keep up with the good job !
Regards,
Arno

Various syntax errors for all Python scripts

I know there's a high chance that this is my fault, but I can't get anything to work. I'm running Arch Linux and installed all dependencies using PIP as suggested. Here's all the errors I'm getting:

$ rdpy-rdpclient.py
  File "/usr/bin/rdpy-rdpclient.py", line 225
    """
      ^
SyntaxError: invalid syntax
$ rdpy-rdphoneypot.py
  File "/usr/bin/rdpy-rdphoneypot.py", line 153
    """
      ^
SyntaxError: invalid syntax
$ rdpy-rdpmitm.py
  File "/usr/bin/rdpy-rdpmitm.py", line 267
    """
      ^
SyntaxError: invalid syntax
$ rdpy-rdpscreenshot.py
  File "/usr/bin/rdpy-rdpscreenshot.py", line 191
    print "Usage: rdpy-rdpscreenshot [options] ip[:port]"
                                                        ^
SyntaxError: Missing parentheses in call to 'print'
$ rdpy-rssplayer.py
  File "/usr/bin/rdpy-rssplayer.py", line 73
    print "Usage: rdpy-rssplayer [-h] rss_filepath"
                                                  ^
SyntaxError: Missing parentheses in call to 'print'
$ rdpy-vncclient.py
Traceback (most recent call last):
  File "/usr/bin/rdpy-vncclient.py", line 27, in <module>
    from rdpy.ui.qt4 import RFBClientQt
  File "/usr/lib/python3.5/site-packages/rdpy/ui/qt4.py", line 27, in <module>
    from rdpy.protocol.rfb.rfb import RFBClientObserver
  File "/usr/lib/python3.5/site-packages/rdpy/protocol/rfb/rfb.py", line 28, in <module>
    from rdpy.core.layer import RawLayer, RawLayerClientFactory
  File "/usr/lib/python3.5/site-packages/rdpy/core/layer.py", line 110, in <module>
    from type import Stream
ImportError: No module named 'type'
$ rdpy-vncscreenshot.py
  File "/usr/bin/rdpy-vncscreenshot.py", line 135
    print "Usage: rdpy-vncscreenshot [options] ip[:port]"
                                                        ^
SyntaxError: Missing parentheses in call to 'print'

VNC Screenshot Script

Hi!

So you added in the RDP screenshot, and that works perfect. You had mentioned you could also create a VNC screenshot script. Could you please create that?

Thanks!

X224 parsing error

Hi Silvain,

First of all, thanks for your library!

I'm experiencing issues with the server when attempting to connect with microsoft RDP client (like the one bundled in XP), see error below:

Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 88, in callWithLogger
return callWithContext({"system": lp}, func, _args, *_kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 73, in callWithContext
return context.call({ILogContext: newCtx}, func, _args, *_kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, _args, *_kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(args,*kw)
--- ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in doRead
return self._dataReceived(data)
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 221, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/test/rdpy-master/rdpy/../rdpy/protocol/network/layer.py", line 114, in dataReceived
self.recv(expectedData)
File "/home/test/rdpy-master/rdpy/../rdpy/protocol/rdp/tpkt.py", line 90, in readData
self._presentation.recv(data)
File "/home/test/rdpy-master/rdpy/../rdpy/protocol/rdp/tpdu.py", line 108, in recvConnectionConfirm
raise InvalidExpectedDataException("invalid TPDU header code X224_TPDU_CONNECTION_CONFIRM != %d"%header.code)
exceptions.TypeError: %d format: a number is required, not UInt8

Thanks !

How to use rdpy-rdpmitm.py command?

i use the commmand:
rdpy-rdpmitm.py -o c:/123 192.168.83.185
the result is:

Traceback (most recent call last):
File "C:\Python27\Scripts\rdpy-rdpmitm.py", line 309, in
reactor.listenTCP(int(listen), ProxyServerFactory(parseIpPort(args[0]), oupu
tDirectory, privateKeyFilePath, certificateFilePath, clientSecurity))
File "C:\Python27\lib\site-packages\twisted\internet\posixbase.py", line 478,
in listenTCP
p.startListening()
File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 984, in sta
rtListening
raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on any:3389: [Errno 10
048] Only one usage of each socket address (protocol/network address/port) is no
rmally permitted.

NLA security

Why in NLA Security level connection (with -n key), credetentials are not asks (as on attached picture) before connect and then this session are closed?
image

exceptions.AttributeError: 'str' object has no attribute 'toUtf8'

Hello,

Thank you for your project. Good job :)

I have tried to use your Simple RDP Client code and your Simple RDP Server code. To use your RDP server code, I need to modify this following line:

reactor.listenTCP(3389, MyRDPFactory())

by

reactor.listenTCP(3389, MyRDPFactory(15))

Otherwise, I have this following error:

TypeError: __init__() takes at least 2 arguments (1 given)

Moreover, when I use the sample RDP client code, I have the following error when it is connecting to the sample RDP server:

[*] WARNING:    *******************************************
[*] WARNING:    *          RDP Security selected          *
[*] WARNING:    *******************************************
[*] DEBUG:  read RSA public key from proprietary certificate
[*] DEBUG:  Still have correct data in packet <class 'rdpy.protocol.rdp.pdu.caps.PointerCapability'>, read 2 bytes as padding
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 611, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 209, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/nla/cssp.py", line 208, in dataReceived
    self._layer.dataReceived(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/x224.py", line 148, in recvData
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/t125/mcs.py", line 243, in recvData
    self._channels[channelId].recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/core/layer.py", line 102, in <lambda>
    callback = lambda x:self.__class__.recv(self, x)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/sec.py", line 470, in recv
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/pdu/layer.py", line 263, in recvServerFontMapPDU
    self._listener.onReady()
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/rdp.py", line 200, in onReady
    observer.onReady()
  File "rdpc.py", line 20, in onReady
    self._controller.sendKeyEventUnicode(ord(unicode("r".toUtf8(), encoding="UTF-8")), True)
exceptions.AttributeError: 'str' object has no attribute 'toUtf8'

Thank you for your help,

Support for older versions of RDP (Windows XP, Server 2003, etc.)

I'd love to see rdpy have support for older versions of RDP. When I go on assessments, I still see a large number of Windows XP and Server 2003 in the networks. It would be awesome and really helpful if rdpy was able to add support for this older version.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.