citronneur / rdpy

Remote Desktop Protocol in Twisted Python
GNU General Public License v3.0
1.69k stars 546 forks source link

If an exception is thrown, all screenshots are black #9

Closed ChrisTruncer closed 9 years ago

ChrisTruncer commented 9 years ago

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.

citronneur commented 9 years ago

It is a timeout issue. I test with yours twitter IPs. I push a commit on hotfix branch please try it. Set your timeout to 5.0 secs too.

To handle connection lost or connection failed event is I suggest you to dot that: class EyeWitnessScreenShotFactory(rdp_screenshot.RDPScreenShotFactory): def clientConnectionLost(self, connector, reason): rdp_screenshot.RDPScreenShotFactory.clientConnectionLost(self, connector, reason)

here reason contain the exception that you want to handle

reactor.connectTCP( ip_rdp, int(port_rdp), rdp_screenshot.EyeWitnessScreenShotFactory( width, height, rdp_object.rdp_screenshot_path, timeout, reactor, app))

def clientConnectionFailed(self, connector, reason):
     rdp_screenshot.RDPScreenShotFactory.clientConnectionFailed(self, connector, reason)
     #here reason contain the exception that you want to handle

You can pass context to factory to know which connection is lost.

Sylvain

ChrisTruncer commented 9 years ago

That, is awesome! I just tested your update and it fixed the black screen issues!

I'll try to figure out that exception, although the formatting in here is messing it up and I'm still not certain how to handle that best..

Thanks again for fixing that black screen issue and working on this!

ChrisTruncer commented 9 years ago

I think this is probably good for merging, unless there were more changes you needed to make. Looks like everything is working for me

citronneur commented 9 years ago

i done in tag 1.1.3. Download available from pip.

Sylvain