8 Commits

Author SHA1 Message Date
speyrefitte
e4c04a7dd1 rrrr tag to quickly 2014-12-03 09:56:41 +01:00
speyrefitte
cdcfdec379 bad setup.py 2014-12-03 09:51:43 +01:00
speyrefitte
894dc44a52 add service_identity in depends 2014-12-03 09:43:16 +01:00
citronneur
47dba5bb6e bug fix on auto detect keybord for windows system 2014-12-03 09:38:14 +01:00
citronneur
c4d071a2e0 Bug fix in screenshot script 2014-12-02 21:32:52 +01:00
speyrefitte
44d99eaca4 Eyewitness integration 2014-12-02 17:00:42 +01:00
speyrefitte
9419bea9b0 fix issue 7 2014-12-02 16:07:33 +01:00
speyrefitte
bd91093617 add 64 bit pre build 2014-12-02 10:12:49 +01:00
6 changed files with 68 additions and 49 deletions

View File

@@ -19,9 +19,10 @@ sudo apt-get install python-qt4
#### Windows
[PyQt4](http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.3/PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-x32.exe)
[PyWin32](http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download)
x86 | x86_64
----|-------
[PyQt4 x86](http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.3/PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-x32.exe) | [PyQt4 x86_64](http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.3/PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-x64.exe/download)
[PyWin32 x86](http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download) | [PyWin32 x86_64](http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win-amd64-py2.7.exe/download)
### Build

View File

@@ -118,14 +118,15 @@ def autoDetectKeyboardLayout():
return "fr"
elif os.name == 'nt':
import win32api, win32con, win32process
import ctypes.windll.user32 as user32
w = user32.GetForegroundWindow()
tid = user32.GetWindowThreadProcessId(w, 0)
result = user32.GetKeyboardLayout(tid)
if result == 0x409409:
from ctypes import windll
w = windll.user32.GetForegroundWindow()
tid = windll.user32.GetWindowThreadProcessId(w, 0)
result = windll.user32.GetKeyboardLayout(tid)
log.info(result)
if result == 0x40c040c:
return "fr"
except:
log.info("failed to auto detect keyboard layout")
except Exception as e:
log.info("failed to auto detect keyboard layout " + str(e))
pass
return "en"

View File

@@ -38,6 +38,7 @@ class RDPScreenShotFactory(rdp.ClientFactory):
"""
@summary: Factory for screenshot exemple
"""
__INSTANCE__ = 0
def __init__(self, width, height, path, timeout):
"""
@param width: width of screen
@@ -45,6 +46,7 @@ class RDPScreenShotFactory(rdp.ClientFactory):
@param path: path of output screenshot
@param timeout: close connection after timeout s without any updating
"""
RDPScreenShotFactory.__INSTANCE__ += 1
self._width = width
self._height = height
self._path = path
@@ -57,8 +59,10 @@ class RDPScreenShotFactory(rdp.ClientFactory):
@param reason: str use to advertise reason of lost connection
"""
log.info("connection lost : %s"%reason)
reactor.stop()
app.exit()
RDPScreenShotFactory.__INSTANCE__ -= 1
if(RDPScreenShotFactory.__INSTANCE__ == 0):
reactor.stop()
app.exit()
def clientConnectionFailed(self, connector, reason):
"""
@@ -66,9 +70,11 @@ class RDPScreenShotFactory(rdp.ClientFactory):
@param connector: twisted connector use for rdp connection (use reconnect to restart connection)
@param reason: str use to advertise reason of lost connection
"""
log.info("connection failes : %s"%reason)
reactor.stop()
app.exit()
log.info("connection failed : %s"%reason)
RDPScreenShotFactory.__INSTANCE__ -= 1
if(RDPScreenShotFactory.__INSTANCE__ == 0):
reactor.stop()
app.exit()
def buildObserver(self, controller, addr):
@@ -93,19 +99,20 @@ class RDPScreenShotFactory(rdp.ClientFactory):
controller.setScreen(width, height);
self._buffer = QtGui.QImage(width, height, QtGui.QImage.Format_RGB32)
self._path = path
self._hasUpdated = True
self._brandWidthTask = task.LoopingCall(self.checkUpdate)
self._brandWidthTask.start(timeout) # call every second
self._timeout = timeout
self._startTimeout = False
def onUpdate(self, destLeft, destTop, destRight, destBottom, width, height, bitsPerPixel, isCompress, data):
"""
@summary: callback use when bitmap is received
"""
self._hasUpdated = True
image = RDPBitmapToQtImage(destLeft, width, height, bitsPerPixel, isCompress, data);
with QtGui.QPainter(self._buffer) as qp:
#draw image
qp.drawImage(destLeft, destTop, image, 0, 0, destRight - destLeft + 1, destBottom - destTop + 1)
if not self._startTimeout:
self._startTimeout = False
reactor.callLater(self._timeout, self.checkUpdate)
def onReady(self):
"""
@@ -121,11 +128,7 @@ class RDPScreenShotFactory(rdp.ClientFactory):
self._buffer.save(self._path)
def checkUpdate(self):
if not self._hasUpdated:
log.info("close connection on timeout without updating orders")
self._controller.close();
return
self._hasUpdated = False
self._controller.close();
return ScreenShotObserver(controller, self._width, self._height, self._path, self._timeout)
@@ -140,8 +143,8 @@ if __name__ == '__main__':
#default script argument
width = 1024
height = 800
path = "/tmp/rdpy-rdpscreenshot.jpg"
timeout = 2.0
path = "/tmp/"
timeout = 5.0
try:
opts, args = getopt.getopt(sys.argv[1:], "hw:l:o:t:")
@@ -159,12 +162,7 @@ if __name__ == '__main__':
path = arg
elif opt == "-t":
timeout = float(arg)
if ':' in args[0]:
ip, port = args[0].split(':')
else:
ip, port = args[0], "3389"
#create application
app = QtGui.QApplication(sys.argv)
@@ -173,6 +171,14 @@ if __name__ == '__main__':
qt4reactor.install()
from twisted.internet import reactor
reactor.connectTCP(ip, int(port), RDPScreenShotFactory(width, height, path, timeout))
for arg in args:
if ':' in arg:
ip, port = arg.split(':')
else:
ip, port = arg, "3389"
reactor.connectTCP(ip, int(port), RDPScreenShotFactory(width, height, path + "%s.jpg"%ip, timeout))
reactor.runReturn()
app.exec_()

View File

@@ -37,11 +37,13 @@ class RFBScreenShotFactory(rfb.ClientFactory):
"""
@summary: Factory for screenshot exemple
"""
__INSTANCE__ = 0
def __init__(self, password, path):
"""
@param password: password for VNC authentication
@param path: path of output screenshot
"""
RFBScreenShotFactory.__INSTANCE__ += 1
self._path = path
self._password = password
@@ -52,8 +54,10 @@ class RFBScreenShotFactory(rfb.ClientFactory):
@param reason: str use to advertise reason of lost connection
"""
log.info("connection lost : %s"%reason)
reactor.stop()
app.exit()
RFBScreenShotFactory.__INSTANCE__ -= 1
if(RFBScreenShotFactory.__INSTANCE__ == 0):
reactor.stop()
app.exit()
def clientConnectionFailed(self, connector, reason):
"""
@@ -62,8 +66,10 @@ class RFBScreenShotFactory(rfb.ClientFactory):
@param reason: str use to advertise reason of lost connection
"""
log.info("connection failed : %s"%reason)
reactor.stop()
app.exit()
RFBScreenShotFactory.__INSTANCE__ -= 1
if(RFBScreenShotFactory.__INSTANCE__ == 0):
reactor.stop()
app.exit()
def buildObserver(self, controller, addr):
@@ -132,7 +138,7 @@ def help():
if __name__ == '__main__':
#default script argument
path = "/tmp/rdpy-vncscreenshot.jpg"
path = "/tmp/"
password = ""
try:
@@ -148,20 +154,23 @@ if __name__ == '__main__':
elif opt == "-p":
password = arg
if ':' in args[0]:
ip, port = args[0].split(':')
else:
ip, port = args[0], "5900"
#create application
app = QtGui.QApplication(sys.argv)
#add qt4 reactor
import qt4reactor
qt4reactor.install()
from twisted.internet import reactor
reactor.connectTCP(ip, int(port), RFBScreenShotFactory(password, path))
for arg in args:
if ':' in arg:
ip, port = arg.split(':')
else:
ip, port = arg, "5900"
reactor.connectTCP(ip, int(port), RFBScreenShotFactory(password, path + "%s.jpg"%ip))
reactor.runReturn()
app.exec_()

View File

@@ -463,8 +463,9 @@ class CompositeType(Type):
if not self._readLen is None and readLen > self._readLen.value:
#roll back
s.pos -= sizeof(self.__dict__[name])
#and notify
raise InvalidSize("Impossible to read type %s : read length is too small"%(self.__class__))
#and notify if not optional
if not self.__dict__[name]._optional:
raise InvalidSize("Impossible to read type %s : read length is too small"%(self.__class__))
except Exception as e:
log.error("Error during read %s::%s"%(self.__class__, name))

View File

@@ -4,7 +4,7 @@ import setuptools
from distutils.core import setup, Extension
setup(name='rdpy',
version='1.1.0',
version='1.1.3',
description='Remote Desktop Protocol in Python',
long_description="""
RDPY is a pure Python implementation of the Microsoft RDP (Remote Desktop Protocol) protocol.
@@ -34,6 +34,7 @@ setup(name='rdpy',
install_requires=[
'twisted',
'pyopenssl',
'service_identity',
'qt4reactor',
],
)