forked from p15670423/monkey
78 lines
2.1 KiB
Python
78 lines
2.1 KiB
Python
|
|
||
|
|
||
|
|
||
|
|
||
|
import socket
|
||
|
from rdpy.protocol.rdp import rdp
|
||
|
from twisted.internet import reactor
|
||
|
|
||
|
__author__ = 'itamar'
|
||
|
|
||
|
class RDPClient(rdp.RDPClientObserver):
|
||
|
def __init__(self, controller, width, height):
|
||
|
super(RDPClient, self).__init__(controller)
|
||
|
|
||
|
self._width = width
|
||
|
self._height = height
|
||
|
|
||
|
def onUpdate(self, destLeft, destTop, destRight, destBottom, width, height, bitsPerPixel, isCompress, data):
|
||
|
print "onUpdate", destLeft, destTop, destRight, destBottom, width, height, bitsPerPixel, isCompress, len(data)
|
||
|
|
||
|
def onReady(self):
|
||
|
"""
|
||
|
@summary: Call when stack is ready
|
||
|
"""
|
||
|
print "onReady"
|
||
|
|
||
|
def onClose(self):
|
||
|
"""
|
||
|
@summary: Call when stack is close
|
||
|
"""
|
||
|
print "onClose"
|
||
|
|
||
|
def closeEvent(self, e):
|
||
|
print "closeEvent", e
|
||
|
|
||
|
|
||
|
class RDPClientFactory(rdp.ClientFactory):
|
||
|
def __init__(self):
|
||
|
self._username = "Administrator"
|
||
|
self._password = "Password1!"
|
||
|
self._domain = ""
|
||
|
self._keyboard_layout = "en"
|
||
|
self._optimized = False
|
||
|
self._security = "rdp" # "ssl"
|
||
|
|
||
|
self._width = 200
|
||
|
self._height = 200
|
||
|
|
||
|
def __repr__(self):
|
||
|
return "<RDPClientFactory %dx%d>" % (self._width, self._height)
|
||
|
|
||
|
def buildObserver(self, controller, addr):
|
||
|
"""
|
||
|
@summary: Build RFB observer
|
||
|
We use a RDPClient as RDP observer
|
||
|
@param controller: build factory and needed by observer
|
||
|
@param addr: destination address
|
||
|
@return: RDPClientQt
|
||
|
"""
|
||
|
|
||
|
#create client observer
|
||
|
self._client = RDPClient(controller, self._width, self._height)
|
||
|
|
||
|
controller.setUsername(self._username)
|
||
|
controller.setPassword(self._password)
|
||
|
controller.setDomain(self._domain)
|
||
|
controller.setKeyboardLayout(self._keyboard_layout)
|
||
|
controller.setHostname(socket.gethostname())
|
||
|
if self._optimized:
|
||
|
controller.setPerformanceSession()
|
||
|
controller.setSecurityLevel(self._security)
|
||
|
|
||
|
return self._client
|
||
|
|
||
|
|
||
|
reactor.connectTCP("10.0.0.1", 3389, RDPClientFactory())
|
||
|
reactor.run()
|