P2P RDP with Python

做~自己de王妃 提交于 2019-12-06 10:51:34

Some time ago I wrote something called easyrfb which, too, is based on python-vnc-viewer, but I never published it. It does not cover exactly what you asked, but it is very similar. In the hope it might be helpful, parts of it now can be found at http://hydra.geht.net/easyrfb/

Note that the files there are not always in a working state, because the files are directly linked to my working copy. But I am not editing often.

It's now available on GitHub, too: https://github.com/hilbix/pyrfb/tree/easyrfb

This it what it does at my side:

  • Connect to a locally running Xvnc (technically any VNC server will do)
  • Continuously write the current screen contents to a highly compressed test.jpg
  • Some web page grabs that using AJAX and updates an image
  • Mouse clicks on that image are forwarded to the VNC server as mouse clicks
  • Keyboard input can be simulated using forms
  • And one can take lossless PNG screenshots
  • There is an edit.html to do fuzzy matching based on the PNG screenshots (called templates)
  • Shell scripts can check if such templates are matched or wait for them to match.

The internal communication is done using TCP, Unix-Sockets and some files, so it's not difficult to change it such, that every component runs at a different location:

  • The VNC server (the screen to show)
  • rfbimg.py (which does VNC -> image and offers the control .sock)
  • The shell scripts (if needed, using sendsock.py to talk to .sock)
  • The web service (AJAX, and GET image) with stubs (forwarding commands to .sock)
  • The controlling web client (any browser, even lynx or telnet can do)

Please do not ask me for documentation! Use the source, Luke!

Mental health warning! The complete picture is a big and ugly grown unclean pile of headache-inducing-facepalm creating bits of mostly unrelated randomly placed complex scripts with wrong and misleading names, unclean copies, uncommented and unfinished half-edits, everything hardcoded to exactly one single machine, probably needing some undocumented local 10 year old tweaks to nonupgraded packages, or even older stuff. So I will not hand out everything. (And even if this sounds familiar, nope, I am not working for Microsoft.)

Well apart from the "in Python", sounds like you're just reinventing another VNC. Most modern derivatives are based on TightVNC which is open source. If you can understand the VNC code (C++) and the RFB protocol it uses, you'll find all of your questions answered.

This python implementation of a VNC client might also be interesting to you. However, note the comment on that page:

What is it good for? Nothing ;-) Use the original VNC viewer for better performance.

Maybe you can achieve your goals by reusing VNC technology in some way ? (e.g creating Python bindings for the VNC C++ code and/or using the RFB protocol so you can interoperate with existing VNC servers/clients ?)

As per this GitHub comment, you can use libfreerdp via ctypes in Python.

See: FreeRDP library at GitHub.

FreeRDP is a free remote desktop protocol library and clients http://www.freerdp.com/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!