add argument for rdpclient script
This commit is contained in:
@@ -22,8 +22,7 @@
|
|||||||
example of use rdpy as rdp client
|
example of use rdpy as rdp client
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys, os, getopt
|
||||||
import os
|
|
||||||
|
|
||||||
# Change path so we find rdpy
|
# Change path so we find rdpy
|
||||||
sys.path.insert(1, os.path.join(sys.path[0], '..'))
|
sys.path.insert(1, os.path.join(sys.path[0], '..'))
|
||||||
@@ -36,12 +35,15 @@ class RDPClientQtFactory(rdp.ClientFactory):
|
|||||||
"""
|
"""
|
||||||
Factory create a RDP GUI client
|
Factory create a RDP GUI client
|
||||||
"""
|
"""
|
||||||
def __init__(self, width, height):
|
def __init__(self, width, height, username, password, domain):
|
||||||
"""
|
"""
|
||||||
init client with correct definition
|
init client with correct definition
|
||||||
"""
|
"""
|
||||||
self._width = width
|
self._width = width
|
||||||
self._height = height
|
self._height = height
|
||||||
|
self._username = username
|
||||||
|
self._passwod = password
|
||||||
|
self._domain = domain
|
||||||
self._w = None
|
self._w = None
|
||||||
|
|
||||||
def buildObserver(self, controller):
|
def buildObserver(self, controller):
|
||||||
@@ -59,6 +61,9 @@ class RDPClientQtFactory(rdp.ClientFactory):
|
|||||||
|
|
||||||
#resize session
|
#resize session
|
||||||
controller.setScreen(self._width, self._height)
|
controller.setScreen(self._width, self._height)
|
||||||
|
controller.setUsername(self._username)
|
||||||
|
controller.setPassword(self._passwod)
|
||||||
|
controller.setDomain(self._domain)
|
||||||
controller.setPerformanceSession()
|
controller.setPerformanceSession()
|
||||||
|
|
||||||
return client
|
return client
|
||||||
@@ -86,7 +91,46 @@ class RDPClientQtFactory(rdp.ClientFactory):
|
|||||||
reactor.stop()
|
reactor.stop()
|
||||||
app.exit()
|
app.exit()
|
||||||
|
|
||||||
|
def help():
|
||||||
|
print "Usage: rdpy-rdpclient [options] ip[:port]"
|
||||||
|
print "\t-u: user name"
|
||||||
|
print "\t-p: password"
|
||||||
|
print "\t-d: domain"
|
||||||
|
print "\t-w: width of screen default value is 1024"
|
||||||
|
print "\t-l: height of screen default value is 800"
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
#default script argument
|
||||||
|
username = ""
|
||||||
|
password = ""
|
||||||
|
domain = ""
|
||||||
|
width = 1024
|
||||||
|
height = 800
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], "hu:p:d:w:l")
|
||||||
|
except getopt.GetoptError:
|
||||||
|
help()
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == "-h":
|
||||||
|
help()
|
||||||
|
sys.exit()
|
||||||
|
elif opt == "-u":
|
||||||
|
username = arg
|
||||||
|
elif opt == "-p":
|
||||||
|
password = arg
|
||||||
|
elif opt == "-d":
|
||||||
|
domain = arg
|
||||||
|
elif opt == "-w":
|
||||||
|
width = int(arg)
|
||||||
|
elif opt == "-l":
|
||||||
|
height = int(arg)
|
||||||
|
|
||||||
|
if ':' in args[0]:
|
||||||
|
ip, port = args[0].split(':')
|
||||||
|
else:
|
||||||
|
ip, port = args[0], "3389"
|
||||||
|
|
||||||
#create application
|
#create application
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
|
||||||
@@ -95,7 +139,7 @@ if __name__ == '__main__':
|
|||||||
qt4reactor.install()
|
qt4reactor.install()
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
reactor.connectTCP(sys.argv[1], int(sys.argv[2]), RDPClientQtFactory(1024, 800))
|
reactor.connectTCP(ip, int(port), RDPClientQtFactory(width, height, username, password, domain))
|
||||||
reactor.runReturn()
|
reactor.runReturn()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
@@ -423,7 +423,7 @@ class CompositeType(Type):
|
|||||||
for name in self._typeName:
|
for name in self._typeName:
|
||||||
try:
|
try:
|
||||||
s.readType(self.__dict__[name])
|
s.readType(self.__dict__[name])
|
||||||
|
readLen += sizeof(self.__dict__[name])
|
||||||
#read is ok but read out of bound
|
#read is ok but read out of bound
|
||||||
if not self._readLen is None and readLen > self._readLen.value:
|
if not self._readLen is None and readLen > self._readLen.value:
|
||||||
#roll back
|
#roll back
|
||||||
@@ -440,8 +440,6 @@ class CompositeType(Type):
|
|||||||
s.pos -= sizeof(self.__dict__[tmpName])
|
s.pos -= sizeof(self.__dict__[tmpName])
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
readLen += sizeof(self.__dict__[name])
|
|
||||||
|
|
||||||
def __write__(self, s):
|
def __write__(self, s):
|
||||||
"""
|
"""
|
||||||
Call write on each ordered sub type
|
Call write on each ordered sub type
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ class RDPInfo(CompositeType):
|
|||||||
#code page
|
#code page
|
||||||
self.codePage = UInt32Le()
|
self.codePage = UInt32Le()
|
||||||
#support flag
|
#support flag
|
||||||
self.flag = UInt32Le(InfoFlag.INFO_MOUSE | InfoFlag.INFO_UNICODE | InfoFlag.INFO_LOGONERRORS | InfoFlag.INFO_LOGONNOTIFY | InfoFlag.INFO_ENABLEWINDOWSKEY | InfoFlag.INFO_DISABLECTRLALTDEL)
|
self.flag = UInt32Le(InfoFlag.INFO_MOUSE | InfoFlag.INFO_UNICODE | InfoFlag.INFO_LOGONERRORS | InfoFlag.INFO_LOGONNOTIFY | InfoFlag.INFO_ENABLEWINDOWSKEY | InfoFlag.INFO_DISABLECTRLALTDEL | InfoFlag.INFO_AUTOLOGON)
|
||||||
self.cbDomain = UInt16Le(lambda:sizeof(self.domain) - 2)
|
self.cbDomain = UInt16Le(lambda:sizeof(self.domain) - 2)
|
||||||
self.cbUserName = UInt16Le(lambda:sizeof(self.userName) - 2)
|
self.cbUserName = UInt16Le(lambda:sizeof(self.userName) - 2)
|
||||||
self.cbPassword = UInt16Le(lambda:sizeof(self.password) - 2)
|
self.cbPassword = UInt16Le(lambda:sizeof(self.password) - 2)
|
||||||
@@ -497,7 +497,7 @@ class RDPInfo(CompositeType):
|
|||||||
#shell execute at start of session
|
#shell execute at start of session
|
||||||
self.alternateShell = UniString(readLen = UInt16Le(lambda:self.cbAlternateShell.value - 2))
|
self.alternateShell = UniString(readLen = UInt16Le(lambda:self.cbAlternateShell.value - 2))
|
||||||
#working directory for session
|
#working directory for session
|
||||||
self.workingDir = UniString("toto", readLen = UInt16Le(lambda:self.cbWorkingDir.value - 2))
|
self.workingDir = UniString(readLen = UInt16Le(lambda:self.cbWorkingDir.value - 2))
|
||||||
self.extendedInfo = RDPExtendedInfo(conditional = extendedInfoConditional)
|
self.extendedInfo = RDPExtendedInfo(conditional = extendedInfoConditional)
|
||||||
|
|
||||||
class RDPExtendedInfo(CompositeType):
|
class RDPExtendedInfo(CompositeType):
|
||||||
@@ -629,22 +629,22 @@ class DataPDU(CompositeType):
|
|||||||
Create object in accordance self.shareDataHeader.pduType2 value
|
Create object in accordance self.shareDataHeader.pduType2 value
|
||||||
"""
|
"""
|
||||||
if self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_UPDATE:
|
if self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_UPDATE:
|
||||||
return UpdateDataPDU(readLen = self.shareDataHeader.uncompressedLength)
|
return UpdateDataPDU(readLen = self.shareDataHeader.uncompressedLength - 18)
|
||||||
|
|
||||||
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_SYNCHRONIZE:
|
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_SYNCHRONIZE:
|
||||||
return SynchronizeDataPDU(readLen = self.shareDataHeader.uncompressedLength)
|
return SynchronizeDataPDU(readLen = self.shareDataHeader.uncompressedLength - 18)
|
||||||
|
|
||||||
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_CONTROL:
|
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_CONTROL:
|
||||||
return ControlDataPDU(readLen = self.shareDataHeader.uncompressedLength)
|
return ControlDataPDU(readLen = self.shareDataHeader.uncompressedLength - 18)
|
||||||
|
|
||||||
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_SET_ERROR_INFO_PDU:
|
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_SET_ERROR_INFO_PDU:
|
||||||
return ErrorInfoDataPDU(readLen = self.shareDataHeader.uncompressedLength)
|
return ErrorInfoDataPDU(readLen = self.shareDataHeader.uncompressedLength - 18)
|
||||||
|
|
||||||
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_FONTLIST:
|
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_FONTLIST:
|
||||||
return FontListDataPDU(readLen = self.shareDataHeader.uncompressedLength)
|
return FontListDataPDU(readLen = self.shareDataHeader.uncompressedLength - 18)
|
||||||
|
|
||||||
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_FONTMAP:
|
elif self.shareDataHeader.pduType2.value == PDUType2.PDUTYPE2_FONTMAP:
|
||||||
return FontMapDataPDU(readLen = self.shareDataHeader.uncompressedLength)
|
return FontMapDataPDU(readLen = self.shareDataHeader.uncompressedLength - 18)
|
||||||
else:
|
else:
|
||||||
#read all value
|
#read all value
|
||||||
return String()
|
return String()
|
||||||
@@ -764,7 +764,7 @@ class FastPathUpdatePDU(CompositeType):
|
|||||||
def __init__(self, updateType = 0, updateData = None):
|
def __init__(self, updateType = 0, updateData = None):
|
||||||
CompositeType.__init__(self)
|
CompositeType.__init__(self)
|
||||||
self.updateHeader = UInt8(updateType)
|
self.updateHeader = UInt8(updateType)
|
||||||
self.compressionFlags = UInt8(conditional = lambda:(self.updateHeader.value & FastPathOutputCompression.FASTPATH_OUTPUT_COMPRESSION_USED))
|
self.compressionFlags = UInt8(conditional = lambda:((self.updateHeader.value >> 4) & FastPathOutputCompression.FASTPATH_OUTPUT_COMPRESSION_USED))
|
||||||
self.size = UInt16Le()
|
self.size = UInt16Le()
|
||||||
|
|
||||||
def UpdateDataFactory():
|
def UpdateDataFactory():
|
||||||
@@ -773,10 +773,6 @@ class FastPathUpdatePDU(CompositeType):
|
|||||||
"""
|
"""
|
||||||
if (self.updateHeader.value & 0xf) == FastPathUpdateType.FASTPATH_UPDATETYPE_BITMAP:
|
if (self.updateHeader.value & 0xf) == FastPathUpdateType.FASTPATH_UPDATETYPE_BITMAP:
|
||||||
return (UInt16Le(FastPathUpdateType.FASTPATH_UPDATETYPE_BITMAP, constant = True), BitmapUpdateDataPDU(readLen = self.size))
|
return (UInt16Le(FastPathUpdateType.FASTPATH_UPDATETYPE_BITMAP, constant = True), BitmapUpdateDataPDU(readLen = self.size))
|
||||||
|
|
||||||
elif (self.updateHeader.value & 0xf) == FastPathUpdateType.FASTPATH_UPDATETYPE_SYNCHRONIZE:
|
|
||||||
return SynchronizeUpdatePDU(readLen = self.size)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return String()
|
return String()
|
||||||
|
|
||||||
@@ -784,17 +780,6 @@ class FastPathUpdatePDU(CompositeType):
|
|||||||
updateData = FactoryType(UpdateDataFactory)
|
updateData = FactoryType(UpdateDataFactory)
|
||||||
|
|
||||||
self.updateData = updateData
|
self.updateData = updateData
|
||||||
|
|
||||||
class SynchronizeUpdatePDU(CompositeType):
|
|
||||||
"""
|
|
||||||
PDU is ignored, artefact of T.125
|
|
||||||
"""
|
|
||||||
def __init__(self, readLen = None):
|
|
||||||
"""
|
|
||||||
@param readLen: Max size of packet
|
|
||||||
"""
|
|
||||||
CompositeType.__init__(self, readLen = readLen)
|
|
||||||
self.pad2Octets = UInt16Le()
|
|
||||||
|
|
||||||
class BitmapUpdateDataPDU(CompositeType):
|
class BitmapUpdateDataPDU(CompositeType):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class TPDUDataHeader(CompositeType):
|
|||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
CompositeType.__init__(self)
|
CompositeType.__init__(self)
|
||||||
self.header = UInt8(2, constant = True)
|
self.header = UInt8(2)
|
||||||
self.messageType = UInt8(MessageType.X224_TPDU_DATA, constant = True)
|
self.messageType = UInt8(MessageType.X224_TPDU_DATA, constant = True)
|
||||||
self.separator = UInt8(0x80, constant = True)
|
self.separator = UInt8(0x80, constant = True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user