我使用rdpy-rdpmitm
演示版rdpy
來實現rdp代理服務器,但我想在連接到目標服務器之前檢查密碼並讓客戶端重新啓動輸入用戶名和密碼。我的代碼是這樣的;我如何實施OnReady
方法?我如何讓rdpy-rdpmitm讓客戶端在密碼不正確時重新輸入用戶名和密碼
class ProxyServer(rdp.RDPServerObserver):
def __init__(self, controller, target, clientSecurityLevel, rssRecorder):
"""
@param controller: {RDPServerController}
@param target: {tuple(ip, port)}
@param rssRecorder: {rss.FileRecorder} use to record session
"""
rdp.RDPServerObserver.__init__(self, controller)
self._target = target
self._client = None
self._rss = rssRecorder
self._clientSecurityLevel = clientSecurityLevel
def onReady(self):
"""
@summary: Event use to inform state of server stack
First time this event is called is when human client is connected
Second time is after color depth nego, because color depth nego
restart a connection sequence
@see: rdp.RDPServerObserver.onReady
"""
if self._client is None:
# try a connection
domain, username, password = self._controller.getCredentials()
self._rss.credentials(username, password, domain, self._controller.getHostname())
width, height = self._controller.getScreen()
self._rss.screen(width, height, self._controller.getColorDepth())
if checkPassword(username, password): #password ok
reactor.connectTCP('127.0.0.1', 3389, ProxyClientFactory(self, width, height, domain, username, password,self._clientSecurityLevel))
else:
pass
#how to make client re-input username and password in this place
請問你的代碼已經是你的類中,還是可以在外面? –