FORUMS
Remove All Ads from XDA

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

9 posts
Thanks Meter: 5
 
By Govorun, Junior Member on 19th February 2014, 02:01 PM
Post Reply Email Thread
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
Click image for larger version

Name:	VNC_1.1_1.png
Views:	1861
Size:	54.5 KB
ID:	2616165
Click image for larger version

Name:	VNC_1.1_2.png
Views:	1790
Size:	37.6 KB
ID:	2616166
Click image for larger version

Name:	VNCscreen1.png
Views:	1831
Size:	55.7 KB
ID:	2592311


DOWNLOAD
ReverseVNCServer.apk
The Following 2 Users Say Thank You to Govorun For This Useful Post: [ View ] Gift Govorun Ad-Free
21st February 2014, 03:21 PM |#2  
Govorun's Avatar
OP Junior Member
Thanks Meter: 5
 
More
Added GUI and apk file now available for download.
The Following User Says Thank You to Govorun For This Useful Post: [ View ] Gift Govorun Ad-Free
5th March 2014, 09:24 PM |#3  
Junior Member
Thanks Meter: 1
 
More
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
The Following User Says Thank You to dustbln For This Useful Post: [ View ] Gift dustbln Ad-Free
6th March 2014, 10:05 AM |#4  
Govorun's Avatar
OP Junior Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by dustbln

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
6th March 2014, 08:17 PM |#5  
Junior Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by Govorun

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
7th March 2014, 09:24 AM |#6  
Govorun's Avatar
OP Junior Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by dustbln

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.
The Following User Says Thank You to Govorun For This Useful Post: [ View ] Gift Govorun Ad-Free
7th March 2014, 03:10 PM |#7  
Junior Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by Govorun

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

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
7th March 2014, 04:45 PM |#8  
Govorun's Avatar
OP Junior Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by dustbln

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.
The Following User Says Thank You to Govorun For This Useful Post: [ View ] Gift Govorun Ad-Free
7th March 2014, 06:37 PM |#9  
Junior Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by Govorun

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!

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
23rd November 2014, 12:30 PM |#10  
Junior Member
Thanks Meter: 0
 
More
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.
2nd March 2015, 10:23 AM |#11  
Junior Member
Thanks Meter: 0
 
More
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
Post Reply Subscribe to Thread

Tags
android, reverse vnc server, vnc server

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes