sibson/vncdotool

Missing support for RFB 4.000, 4.001, 5.000 and newer AuthTypes

robbyatbln opened this issue · 6 comments

Please include the following information:

vncdotool version
1.0.0

from vncdotool import api
client = api.connect('192.168.178.111', password='raspberry')
client.timeout = 10
client.captureScreen('screenshot.png')
client.disconnect()

and this ERROR:

Traceback (most recent call last):
File "D:\Programme\Python3\Lib\site-packages\vncdotool\api.py", line 103, in proxy_call
result = self.queue.get(timeout=self._timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programme\Python3\Lib\queue.py", line 179, in get
raise Empty
_queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\Users\maste\PycharmProjects\untitled6\venv\Lib\vncbild.py", line 4, in
client.captureScreen('screenshot.png')
File "D:\Programme\Python3\Lib\site-packages\vncdotool\api.py", line 105, in proxy_call
raise TimeoutError("Timeout while waiting for client response")
TimeoutError: Timeout while waiting for client response

Thanks for helping!!!

on windows with python 3.11

This is not enough information to help you, as the problem way well be with your setup.
Please test with vncdo -v -s 192.168.178.111 -p 'raspberry' capture 'screenshot.png' first and also make sure, that you can actually connect to IPv4 address 192.168.178.111 TCP port 5900 and that it is not blocked by any firewall rule and that the VNC server running there actually binds to a public interface — loopback lo is not enugh.
To test this use some low-level tool like netcat and do a nc 192.168.178.111 5900: you should see some RFB 003.008 string printed — if not, investigate your network first.

hi ican use the pi with vnc that works.

PS E:\Users\maste\PycharmProjects> vncdo -v -t 10 -s 192.168.178.111 -p 'raspberry' capture 'screenshot.png'
INFO:root:connecting to 192.168.178.111:5900
INFO:twisted:Starting factory <vncdotool.command.VNCDoCLIFactory object at 0x0000026F2483DED0>
INFO:twisted:Protocol version 5.000 not supported
INFO:twisted:Using protocol version 3.800
INFO:twisted:unknown security types: (13, 5, 6, 130, 192)
CRITICAL:root:TIMEOUT Exceeded (10.0s)
CRITICAL:root:Connection to the other side was lost in a non-clean fashion: Connection lost.
INFO:twisted:Stopping factory <vncdotool.command.VNCDoCLIFactory object at 0x0000026F2483DED0>
INFO:twisted:Main loop terminated.
PS E:\Users\maste\PycharmProjects>

and this is the nc output:

Starting Nmap 7.93 ( https://nmap.org ) at 2023-02-01 15:47 Mitteleuropäische Zeit

Failed to resolve "5900".

Failed to resolve ":".

Failed to resolve ":".

Nmap scan report for raspberrypi.fritz.box (192.168.178.111)

Host is up (0.0048s latency).

Not shown: 996 closed tcp ports (reset)

PORT STATE SERVICE

22/tcp open ssh

53/tcp open domain

5900/tcp open vnc

8888/tcp open sun-answerbook

MAC Address: DC:A6:32:40:52:BC (Raspberry Pi Trading)

Failed to resolve ":".

Nmap done: 1 IP address (1 host up) scanned in 4.67 seconds

INFO:twisted:Protocol version 5.000 not supported

That is not a valid/supported VNC/RFB protocol version.

and this is the nc output:

What follows is the output of nmap not netcat. Please use nc or netcat or telnet or whatever tool to open a TCP connection to your host on TCP port 5900 and return its output, which should start with RFB 003.

RFB 005.000
ist the output over telnet if i tried on a other pi i becam this error:

D:\Programme\Python3\python.exe E:\Users\maste\PycharmProjects\untitled6\venv\Lib\vncbild.py
Unhandled Error
Traceback (most recent call last):
File "D:\Programme\Python3\Lib\site-packages\twisted\python\log.py", line 96, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "D:\Programme\Python3\Lib\site-packages\twisted\python\log.py", line 80, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "D:\Programme\Python3\Lib\site-packages\twisted\python\context.py", line 117, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "D:\Programme\Python3\Lib\site-packages\twisted\python\context.py", line 82, in callWithContext
return func(*args, **kw)
--- ---
File "D:\Programme\Python3\Lib\site-packages\twisted\internet\selectreactor.py", line 148, in _doReadOrWrite
why = getattr(selectable, method)()
File "D:\Programme\Python3\Lib\site-packages\twisted\internet\tcp.py", line 248, in doRead
return self._dataReceived(data)
File "D:\Programme\Python3\Lib\site-packages\twisted\internet\tcp.py", line 253, in _dataReceived
rval = self.protocol.dataReceived(data)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 685, in dataReceived
self._handler()
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 694, in _handleExpected
self._expected_handler(block, *self._expected_args, **self._expected_kwargs)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 255, in _handleVNCAuth
self.vncRequestPassword()
File "D:\Programme\Python3\Lib\site-packages\vncdotool\client.py", line 375, in vncRequestPassword
self.sendPassword(self.factory.password)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 261, in sendPassword
des = RFBDes(pw)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\pyDes.py", line 410, in init
self.setKey(key)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 835, in setKey
if bsrc & (1 << i):
builtins.TypeError: unsupported operand type(s) for &: 'str' and 'int'

Unhandled Error
Traceback (most recent call last):
File "D:\Programme\Python3\Lib\site-packages\twisted\python\log.py", line 96, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "D:\Programme\Python3\Lib\site-packages\twisted\python\log.py", line 80, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "D:\Programme\Python3\Lib\site-packages\twisted\python\context.py", line 117, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "D:\Programme\Python3\Lib\site-packages\twisted\python\context.py", line 82, in callWithContext
return func(*args, **kw)
--- ---
File "D:\Programme\Python3\Lib\site-packages\twisted\internet\selectreactor.py", line 148, in _doReadOrWrite
why = getattr(selectable, method)()
File "D:\Programme\Python3\Lib\site-packages\twisted\internet\tcp.py", line 248, in doRead
return self._dataReceived(data)
File "D:\Programme\Python3\Lib\site-packages\twisted\internet\tcp.py", line 253, in _dataReceived
rval = self.protocol.dataReceived(data)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 685, in dataReceived
self._handler()
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 694, in _handleExpected
self._expected_handler(block, *self._expected_args, **self._expected_kwargs)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 255, in _handleVNCAuth
self.vncRequestPassword()
File "D:\Programme\Python3\Lib\site-packages\vncdotool\client.py", line 375, in vncRequestPassword
self.sendPassword(self.factory.password)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 261, in sendPassword
des = RFBDes(pw)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\pyDes.py", line 410, in init
self.setKey(key)
File "D:\Programme\Python3\Lib\site-packages\vncdotool\rfb.py", line 835, in setKey
if bsrc & (1 << i):
builtins.TypeError: unsupported operand type(s) for &: 'str' and 'int'

Traceback (most recent call last):
File "D:\Programme\Python3\Lib\site-packages\vncdotool\api.py", line 103, in proxy_call
result = self.queue.get(timeout=self._timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programme\Python3\Lib\queue.py", line 179, in get
raise Empty
_queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\Users\maste\PycharmProjects\untitled6\venv\Lib\vncbild.py", line 4, in
client.captureScreen('screenshot.png')
File "D:\Programme\Python3\Lib\site-packages\vncdotool\api.py", line 105, in proxy_call
raise TimeoutError("Timeout while waiting for client response")
TimeoutError: Timeout while waiting for client response

Process finished with exit code 1

and a long time a go i had something that works with this tool.... please help and thanks a lot of for your time

RFB 005.000 is a completely new protocol: each new version might add new messages or may change the semantics of previous messages. Because of that any VNC client must understand all messages associated with that version. If the client receives an unknown message the only reasonable things any client can do is to terminate the connection.

vncdotool only supports the following versions:

  • 003.003, 003.007, 003.008 which are described by RFC 6143, which is available public.
  • 003.889 is an extension from Apple; no public spec available, but luckily close enough to 3.8

Several companies extended RFB as specified in the RFC on their own, but never provided a public specification for their changes, which anyone can access for free:

  • 004.000 is used by Intel AMT KVM
  • 004.001 is RealVNC 4.6 (the company, which invented RFB, but they only ever opened and published their old version in said RFB, but all further versions are proprietary)
  • 005.000 is RealVNC 5.3

The current code already limits the supported version to 003.008 — albeit it is printed as 3.800 above, which is already fixed in the latest version currently in git — but then only unknown authentication types are offered, which vncdotool does not understand and thus does not support:

INFO:twisted:Protocol version 5.000 not supported
INFO:twisted:Using protocol version 3.800
INFO:twisted:unknown security types: (13, 5, 6, 130, 192)
  • 5 is RSA_AES
  • 6 is RSA_AES_UNENCRYPTED
  • 13 is RSA_AES_2STEP
  • 130 is RSA_AES256_UNENCRYPTED
  • 192 is REALVNC_192

non of them are supported by vncdotool — not even the version currently brewing in git branch main — so the client and server cannot agree to a common authentication mechanism and the client has to abort the connection.

vncdotool version 1.0.0

That version is way to old; you should try pip install git+https://github.com/sibson/vncdotool.git@main, which might also fix your 2nd problem

builtins.TypeError: unsupported operand type(s) for &: 'str' and 'int'