[APP][2.3+]Reverse VNC Server [open source]

Govorun

Member
Dec 5, 2007
9
5
0
github.com
Reverse VNC Server
VNC server which is aimed to reverse connection (however it supports direct connections too).
Reverse connection means that server connects to client. I.e. VNC viewer should be run in listen mode. This is usefull when device, which screen you are going to send someone, has no public IP address.

For correct work device should be ROOTed

Main reuqirements were:
- reverse connection stability (ability to reconnect at connection lost, none of free VNC servers can do this)
- support most devices (it uses frame buffer as screen get method; input events implemented via input tool execution, so it should work everywhere)

Installation:
- install apk file from attachment. E.g.
adb install ReverseVNCServer.apk

Execution:
You can start VNC server via GUI or via command line.

Starting from command line:
Command line parameters (optional):
-c Reverse connection host and port
-t tries : Number of tries for reverse connection
-r : reconnect on reverse connections lost
-p localport : Local port for incoming connections. Default if 5901
-h : print this help
-v : view only
-s scale : scale percent (default is 100)
-d framebuffer device (default is /dev/graphics/fb0)
-z zoom : specify zoom of cursor coordinates in precents

E.g.
adb shell /data/data/org.arcsinx.reversevncserver/lib/libreversevncserver.so -c 192.168.1.34:5500 -r -p 5901

Hotkeys from VNC viewer:
- left => left
- right => right
- down => down
- up => up
- backspace => back
- ESC => back
- Home => Home
- PgUp => Menu
- F3 => Search
- F10 => Power
- F11 => Disconnect
- F12 => Shutdown application

Sources:
- Location
github.com/ArcsinX/ReverseVNCServer

- How to build
1) run ndk-build in top directory of checked out sources.
2) run update_libs.sh script
3) Import top of sources directory as android application project in Eclipse
4) Run from Eclipse to create apk file in bin directory

TODO:
- VNC password protection
- GUI improve (needed to make it not so ugly)

Screenshots
VNC_1.1_1.png
VNC_1.1_2.png
VNCscreen1.png


DOWNLOAD
View attachment ReverseVNCServer.apk
 
Last edited:

dustbln

Member
Jul 15, 2007
7
1
0
Great idea! Unfortunately it does not work on my Note 3:

Code:
Initializing framebuffer device /dev/graphics/fb0...
Screen info: xres=1080, yres=1920, xresv=1080, yresv=3840, xoffs=0, yoffs=0, bpp=32
mmap failed
 
  • Like
Reactions: Govorun

Govorun

Member
Dec 5, 2007
9
5
0
github.com
Great idea! Unfortunately it does not work on my Note 3:
Thanks for reply.

I have changed a bit frame buffer device initialization and added more info ouput before mmap() call.
Could you try to run it one more time and one more time provide output before mmap failure?



Application updated:
- Added scaling
- Added view only mode
- Built-in NoVNC (for connections via browser)
- Some GUI improvements: landscape view, connection strings
 

dustbln

Member
Jul 15, 2007
7
1
0
Thanks for reply.
I have changed a bit frame buffer device initialization and added more info ouput before mmap() call.
Could you try to run it one more time and one more time provide output before mmap failure?
Thanks for you fast response! Unfortunately it still fails :(

Code:
Initializing framebuffer device /dev/graphics/fb0...
Screen info: xres=1080, yres=1920, xresv=1080, yresv=3840, xoffs=0, yoffs=0, bpp=32
        line_length=4352, fb_size=16711680, align_size(fb_size)=16711680
mmap failed
Failed to initialize frame buffer
 

Govorun

Member
Dec 5, 2007
9
5
0
github.com
Unfortunately it still fails :(
I reproduced this problem: set fb_size to yours and try mmap with it. It seems mmap fails for thus big values (in case of high resolution).
So I replaced mmap call with malloc + read. Now it should work. Updated version attached in the first post.
 
Last edited:
  • Like
Reactions: dustbln

dustbln

Member
Jul 15, 2007
7
1
0
I reproduced this problem: set fb_size to yours and try mmap with it. It seems mmap fails for thus big values (in case of high resolution).
So I replaced mmap call with malloc + read. Now it should work. Updated version attached in the first post.
We're getting closer :good:

Code:
User options set:
        Reverse connection string: 192.168.1.X:XXXX
        Reconnect on reverse connection lost
        Local port: 5901
Initializing framebuffer device /dev/graphics/fb0 ... 
Screen info:
        xres=1080, yres=1920, xresv=1080, yresv=3840, xoffs=0, yoffs=0, bpp=32
        line_length=4352, fb_size=16711680
Initializing server...
07/03/2014 15:06:46 Listening for VNC connections on TCP port 5901
07/03/2014 15:06:46 Listening for VNC connections on TCP6 port 5900
07/03/2014 15:06:46 Listening for HTTP connections on TCP port 5801
07/03/2014 15:06:46   URL http://localhost:5801
07/03/2014 15:06:46 Listening for HTTP connections on TCP6 port 5800
07/03/2014 15:06:46   URL http://localhost:5800
Initializing VNC server:
        width:  1080
        height: 1920
        bpp:    32
        port:   5901
        scale:  100
07/03/2014 15:06:46 Making connection to client on host 192.168.1.X port XXXX
07/03/2014 15:06:46   other clients:
07/03/2014 15:06:46 Normal socket connection
Framebuffer read failed: No such device
Failed to update screen
 

Govorun

Member
Dec 5, 2007
9
5
0
github.com
Code:
Initializing framebuffer device /dev/graphics/fb0 ... 
...
Framebuffer read failed: No such device
This is very strange, that "No such device" error appears at try to read framebuffer device (not at opening it).
You can try command
adb pull /dev/graphics/fb0
This command should create local file fb0. If this command fails then something wrong with framebuffer device:
- maybe on Note 3 framebuffer devices do not work
- maybe some other device should be used. You can list all you graphics devices with command adb shell ls /dev/graphics/
On my device I have two framebuffer devices: fb0 (for touchscreen) and fb1 (for HDMI connected displays)
If you able to find framebuffer device for which adb pull will not fail then you can try to start VNC server with this device passing extra -d option.
E.g. adb shell /data/data/org.arcsinx.reversevncserver/lib/libreversevncserver.so -c 192.168.1.34:5500 -r -p 5901 -d /dev/graphics/fb1

Anyway I am going to implement one more screen capture mode (Surface Flinger). Maybe then It will work on your device too.
 
  • Like
Reactions: dustbln

dustbln

Member
Jul 15, 2007
7
1
0
This is very strange, that "No such device" error appears at try to read framebuffer device (not at opening it).
You can try command
adb pull /dev/graphics/fb0
This command should create local file fb0. If this command fails then something wrong with framebuffer device:
- maybe on Note 3 framebuffer devices do not work
- maybe some other device should be used. You can list all you graphics devices with command adb shell ls /dev/graphics/
On my device I have two framebuffer devices: fb0 (for touchscreen) and fb1 (for HDMI connected displays)
If you able to find framebuffer device for which adb pull will not fail then you can try to start VNC server with this device passing extra -d option.
E.g. adb shell /data/data/org.arcsinx.reversevncserver/lib/libreversevncserver.so -c 192.168.1.34:5500 -r -p 5901 -d /dev/graphics/fb1

Anyway I am going to implement one more screen capture mode (Surface Flinger). Maybe then It will work on your device too.
I doubt reading the framebuffer works on stock 4.4 Samsung Galaxy Note 3 ROM. Tried all of the devices and did some google research without any positive result. :(
Anyway. keep up the great work as a reliable RVNC Service was just missing on Android! :good:

Code:
# cat /proc/fb
0 mdssfb_90000
1 mdssfb_70000
2 mdssfb_a0000

# fbset -fb /dev/graphics/fb0                          

mode "1080x1920-0"
        # D: 1.114 MHz, H: 0.865 kHz, V: 0.446 Hz
        geometry 1080 1920 1080 3840 32
        timings 898000 36 162 3 13 10 2
        accel false
        rgba 8/24,8/16,8/8,8/0
endmode

# cat /dev/graphics/fb0
cat: /dev/graphics/fb0: No such device
 

godlatro1

New member
Jul 11, 2014
1
0
0
Hi!
I Cant connect to my LG G2 with rooted Cloudy G3 2.1 - Tight VNC said - Connection lost because server cancel connection
If i try connect via browser - Java block app, and on jre 8 - security wont change lower than "hight".
WebSocket wont work WebSock error: [object Event]
How to connect?

If I use APP Odroid VNC SERVER - connect stable, but i see distortion screen.
 
Last edited:

vanducnkt

New member
Mar 2, 2015
1
0
0
Hi !
it have an error.
unsigned int *ReadFb()
{
if (UpdateFbInfo() == -1)
return NULL;
#ifndef USEMMAP
if (lseek(fbfd, SEEK_SET, 0) == -1)
{
perror("lseek failed for framebuffer device\n");
return NULL;
}
if (read(fbfd, fbmmap, fbsize) == -1)
{
perror("Framebuffer read failed");
return NULL;
}
#endif

return (unsigned int *)fbmmap;
}

with samsung galaxy tab 3 it work good. but with samsung galaxy tab 2 and nexus 10 it out perror("Framebuffer read failed"); and send buffe black to client.
can you help me fix it ?
Thank you
 

Govorun

Member
Dec 5, 2007
9
5
0
github.com
perror("Framebuffer read failed");
Hi. Can you say what exact message appears? I mean that perror() call prints out error description.
Also can you provide output of the following command on your device?
Code:
ls /dev/graphics/
E.g. on your pc to which your device connected
Code:
adb shell ls /dev/graphics/
P.S.
Btw, I have not update apk for sometime (I am going to update APK today.)
Update:
I have updated APK in the first post, try it first.
 
Last edited:

Govorun

Member
Dec 5, 2007
9
5
0
github.com
Hi!
If i try connect via browser - Java block app, and on jre 8 - security wont change lower than "hight".
Hi.
If your browser blocks java applet, you can use java-script only viewer by clicking button "Click here to connect using noVNC" at the bottom of browser page (circled red on attached picture, click to enlarge)
javascript-only.jpg
 
Last edited:

tbsmith

New member
Nov 27, 2009
3
1
0
SurfaceFlinger implementation

Hi,
Is the version of this app with the SurfaceFlinger implementation released yet? I'm not able to use the framebuffer on my device.

Thanks,
Todd
 
  • Like
Reactions: pinkerini

johnha

Member
Aug 12, 2013
7
0
0
Hi there, I know this is an old thread but I am just discovering it now. I tried to look up the github link but it doesn't appear that it's available anymore. Do you know if the source code is published anywhere right now? Thank you!