citronneur / rdpy

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

exceptions.AttributeError: 'str' object has no attribute 'toUtf8' #34

Closed quentinhardy closed 9 years ago

quentinhardy commented 9 years ago

Hello,

Thank you for your project. Good job :)

I have tried to use your Simple RDP Client code and your Simple RDP Server code. To use your RDP server code, I need to modify this following line:

reactor.listenTCP(3389, MyRDPFactory())

by

reactor.listenTCP(3389, MyRDPFactory(15))

Otherwise, I have this following error:

TypeError: __init__() takes at least 2 arguments (1 given)

Moreover, when I use the sample RDP client code, I have the following error when it is connecting to the sample RDP server:

[*] WARNING:    *******************************************
[*] WARNING:    *          RDP Security selected          *
[*] WARNING:    *******************************************
[*] DEBUG:  read RSA public key from proprietary certificate
[*] DEBUG:  Still have correct data in packet <class 'rdpy.protocol.rdp.pdu.caps.PointerCapability'>, read 2 bytes as padding
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 611, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 209, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/nla/cssp.py", line 208, in dataReceived
    self._layer.dataReceived(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/x224.py", line 148, in recvData
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/t125/mcs.py", line 243, in recvData
    self._channels[channelId].recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/core/layer.py", line 102, in <lambda>
    callback = lambda x:self.__class__.recv(self, x)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/sec.py", line 470, in recv
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/pdu/layer.py", line 263, in recvServerFontMapPDU
    self._listener.onReady()
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/rdp.py", line 200, in onReady
    observer.onReady()
  File "rdpc.py", line 20, in onReady
    self._controller.sendKeyEventUnicode(ord(unicode("r".toUtf8(), encoding="UTF-8")), True)
exceptions.AttributeError: 'str' object has no attribute 'toUtf8'

Thank you for your help,

ex0dus-cpp commented 9 years ago

just use self._controller.sendKeyEventUnicode(ord(unicode('r', encoding="UTF-8")), True)

quentinhardy commented 9 years ago

Thank you.

New error:

[*] WARNING:    *******************************************
[*] WARNING:    *          RDP Security selected          *
[*] WARNING:    *******************************************
[*] DEBUG:  read RSA public key from proprietary certificate
[*] DEBUG:  Still have correct data in packet <class 'rdpy.protocol.rdp.pdu.caps.PointerCapability'>, read 2 bytes as padding
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 611, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 209, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 215, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/nla/cssp.py", line 208, in dataReceived
    self._layer.dataReceived(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/core/layer.py", line 209, in dataReceived
    self.recv(expectedData)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/tpkt.py", line 195, in readData
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/x224.py", line 148, in recvData
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/t125/mcs.py", line 243, in recvData
    self._channels[channelId].recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/core/layer.py", line 102, in <lambda>
    callback = lambda x:self.__class__.recv(self, x)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/sec.py", line 470, in recv
    self._presentation.recv(data)
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/pdu/layer.py", line 263, in recvServerFontMapPDU
    self._listener.onReady()
  File "/home/bobsecurity/Bureau/rdpy-master/rdpy/protocol/rdp/rdp.py", line 200, in onReady
    observer.onReady()
  File "rdpc.py", line 23, in onReady
    self._controller.sendPointerEvent(200, 200, 1, true)
exceptions.NameError: global name 'true' is not defined

To fix this, replace true by True in the RDP Client source code:

self._controller.sendPointerEvent(200, 200, 1, true)