Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

Data hiding

Any features you would like to see in UltraVNC? Propose it here
Post Reply
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Data hiding

Post by Dhanush »

I want data hiding to be apart of UltraVNC i.e. when the remote client is connected to the server some of the priviliged information on the server(for example details about a person should be blurred) should not be visible to the client.
Is there an API to acheive this? If not, What are the other alternatives?
Bonji
100
100
Posts: 339
Joined: 2008-05-13 14:54

Re: Data hiding

Post by Bonji »

How would the viewer have any idea what should or should not be visible? No VNC solution can do this as far as I'm aware.
-Ben
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

when the server copies the screen interms of small rectangles into the buffers to send to the client/viewer, it should be able to get the co-ordiantes of the textfields and blurr its content. Now the blurred content should be visible at the client side.
Bonji
100
100
Posts: 339
Joined: 2008-05-13 14:54

Re: Data hiding

Post by Bonji »

VNC has no idea what the contents of the screen updates actually are. It's just "painting" the remote screen for the local client.

Someone correct me if I'm wrong, but I'm pretty sure I'm not.
-Ben
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

From vnc point, you send bitmaps, no application data.

This would require a lot of code...yes you could write some code that based on some user input detect the edit fields.
But then this would break the copyrects ( move a window, as this isn't handled with bitmaps)
This is nothing we gonna do, not general enough to spend time on it.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

thanks for the replies! Now I am in the last step of what I want to acheive. All I need is to get the bitmap of the screen at the winvnc.sln file.
Since the uVNC server creates a bitmap of the server screen, I need to know where in winvnc.sln will I get hold of the bitmap object?
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

Look for m_backbuffer

Screen -> this is copied to Thebuffer ( memorybuffer desktop)
Thebuffer -> is copied to m_backbuffer ( memorybuffer send to the viewer)

As starting point you can use the function that write a red rectangle on the viewer to warn for UAC.
void
vncDesktop::WriteMessageOnScreen(char * tt,BYTE *scrBuff, UINT scrBuffSize)

Instead of overwriting the rectangle you can use some blur function to manipulate the old pixels.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

This is the scene now, I have created a bitmap of the screen with the data blurred using an external applicaiton,which I have created. Now all I want to do is "AND" (bit multiplication) this bitmap with the original bitmap created by the uVNC server. After the bits are multiplied, the bitmap is sent to the viewer by the server which is then displayed at the viewer.
For doing the bit multiplication I have to find the bitmap created at the uVNC server.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

You makes it harder this it should be.

You have a buffer of the full screen m_backbuffer ( Width/Height/stride (sizeof a line)/pixels size(8-32bit) is known)
[pixel1,pixel2,...] row1
[pixel1,pixel2,...] row2
You need to extract a rect ( x,y,w,h) in a temp buffer, does your math and put the temp buffer back.
That's all.... the hardest is to know the correct rect that need to be blured.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

Is there an API from which I can convert the m_backbuff to a bitmap file? so that I can view what exactly m_backbuff holds at a particular point of time.
Also what are m_ScaledBuff and m_mainbuff used for?
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

m_mainbuff= copy of server screen
m_ScaledBuff= copy of server screen, but scaled when server site scaling is used

m_backbuffer= You do exact the same as the viewer do on his screen in this local buffer. The buffer is a copy of the
viewer screen. VNC compare m_mainbuff with this buffer to check for changes


The format of the buffer is a DIB
see
http://msdn.microsoft.com/en-us/library ... s.85).aspx

There are functions to convert DIB to bitmaps.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

In which part of the source code is the the bitmap buffer(having the server screen) sent back to the viewer?
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

The bitmap himself is never send, we only send difference

Sample
change rects ( 0,0,50,50),(100,150,60,800),(x,y,w,h)
vncclient.cpp:vncClient::SendRectangles(const rfb::RectVector &rects)
Each rect is send seperate
vncClient::SendRectangle(const rfb::Rect &rect)
Data is also encoded and some encoders send data insite the encoder ( like zrle)
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

Since the m_mainbuff has the copy of the server screen, I want to mask(merge) the copy of the the server screen with a bitmap stored on the disk.
In which part of the source code can I perform this action? i.e since there are several references to m_mainbuff where do I get hold of the copy of the server screen?
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

The m_mainbuff is a representaion of the screen, or the framebuffer in case you use the driver.
In both cases the buffer is updated several times a second.
If you would write your data to it, it would be overwritten a few ms later.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

In which part of the code is the difference taken(between m_mainbuf and m_backbuff) ? so that I can mask the contents of m_mainbuf and the bitmap stored on the disk.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

Now we back on start

first of my answers was
Look for m_backbuffer

Screen -> this is copied to Thebuffer ( memorybuffer desktop)
Thebuffer -> is copied to m_backbuffer ( memorybuffer send to the viewer)

As starting point you can use the function that write a red rectangle on the viewer to warn for UAC.
void
vncDesktop::WriteMessageOnScreen(char * tt,BYTE *scrBuff, UINT scrBuffSize)
This function write a bitmap to the buffer and send it to the client....this is exact what you want to do.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

Yeah, thats exactly what I want to do.
So I have to replace the m_membitmap with the bitmap I want to load right?

******************************************************************************
vncDesktop::WriteMessageOnScreen(char * tt,BYTE *scrBuff, UINT scrBuffSize)
{
// Select the memory bitmap into the memory DC
RECT rect;
SetRect(&rect, 0,0, 300, 120);
COLORREF bgcol =RGB(0xff, 0x00, 0x00); //bazingaa
COLORREF oldtxtcol =SetTextColor(m_hmemdc, RGB(0,0,254)); //bazingaa
COLORREF oldbgcol =SetBkColor( m_hmemdc, bgcol);
HBRUSH backgroundBrush = CreateSolidBrush(bgcol);

HANDLE handleImage;

handleImage = LoadImage(0,"C:\\Users\\310154757\\Documents\\Visual Studio 2010\\Projects\\bitmap\\bitmap\\screen.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

HBITMAP oldbitmap;
if ((oldbitmap = (HBITMAP) SelectObject(m_hmemdc, handleImage)) == NULL)
return;


FillRect(m_hmemdc, &rect, backgroundBrush);
DrawText(m_hmemdc,tt,strlen(tt),&rect,DT_CENTER | DT_VCENTER);
// Select the old bitmap back into the memory DC
//DWORD err= GetLastError();


//ExtTextOut(m_hmemdc, 0, 0, ETO_OPAQUE,&rect,tt,strlen(tt), NULL);


SetBkColor( m_hmemdc, oldbgcol);

SetTextColor(m_hmemdc, oldtxtcol);
SelectObject(m_hmemdc, oldbitmap);
DeleteObject(backgroundBrush);

CopyToBuffer(rect, scrBuff, scrBuffSize);
}
*************************************************************************

doesnt seem to work. I guess its not being written to the buffer which is sent to the viewer.
How do I write it to the buffer?
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

the control while debugging never enters the function - void vncDesktop::WriteMessageOnScreen(char * tt,BYTE *scrBuff, UINT scrBuffSize)
so making changes there is not helping.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

I am able to mask my bitmap with the contents of the "databuf" buffer and view the output in an image file saved on a disk. but the problem is databuf contents are not being sent to the viewer.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

WriteMessageOnScreen function is used
winvnc.exe running as application
You open a window that require UAC, while the UAC popup is shown, the viewer show a message "the the remote need to press the UAC"
This is done with this function

Search for WriteMessageOnScreen in the src and find the spot(s) where it is called.
For testing just remove the the if so WriteMessageOnScreen is called even without the UAC case.
Dhanush
8
8
Posts: 12
Joined: 2014-04-16 05:22

Re: Data hiding

Post by Dhanush »

below is the WriteMessageOnScreen(char * tt,BYTE *scrBuff, UINT scrBuffSize) function.
I dont see it writing to the UAC anywhere. Please help!

*********************************************************************************************
void vncDesktop::WriteMessageOnScreen(char * tt,BYTE *scrBuff, UINT scrBuffSize)
{
// Select the memory bitmap into the memory DC
RECT rect;
SetRect(&rect, 0,0, 300, 120);
COLORREF bgcol =RGB(0xff, 0x00, 0x00); //bazingaa
COLORREF oldtxtcol =SetTextColor(m_hmemdc, RGB(0,0,254)); //bazingaa
COLORREF oldbgcol =SetBkColor( m_hmemdc, bgcol);
HBRUSH backgroundBrush = CreateSolidBrush(bgcol);

HBITMAP oldbitmap;
if ((oldbitmap = (HBITMAP) SelectObject(m_hmemdc, m_membitmap)) == NULL)
return;

FillRect(m_hmemdc, &rect, backgroundBrush);
DrawText(m_hmemdc,tt,strlen(tt),&rect,DT_CENTER | DT_VCENTER);
// Select the old bitmap back into the memory DC
//DWORD err= GetLastError();
//ExtTextOut(m_hmemdc, 0, 0, ETO_OPAQUE,&rect,tt,strlen(tt), NULL);


SetBkColor( m_hmemdc, oldbgcol);

SetTextColor(m_hmemdc, oldtxtcol);
SelectObject(m_hmemdc, oldbitmap);
DeleteObject(backgroundBrush);

CopyToBuffer(rect, scrBuff, scrBuffSize);
}
************************************************************
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6862
Joined: 2004-04-23 10:21
Contact:

Re: Data hiding

Post by Rudi De Vos »

Search for WriteMessageOnScreen and find the spot(s) where it is called.
vncdesktopthread.cpp

Code: Select all

if (vncService::InputDesktopSelected()==2)
	{
		m_desktop->m_buffer.WriteMessageOnScreen("UltraVVNC running as application doesn't \nhave permission to acces \nUAC protected windows.\n\nScreen is locked until the remote user \nunlock this window");
		rfb::Rect rect;
		rect.tl = rfb::Point(0,0);
		rect.br = rfb::Point(300,120);
		rgncache.assign_union(rect);
We change screendata by writing text on it and tell vnc that the spot is changed
For testing just remove the the if
Make sure

Code: Select all

m_desktop->m_buffer.WriteMessageOnScreen("UltraVVNC running as application doesn't \nhave permission to acces \nUAC protected windows.\n\nScreen is locked until the remote user \nunlock this window");
		rfb::Rect rect;
		rect.tl = rfb::Point(0,0);
		rect.br = rfb::Point(300,120);
		rgncache.assign_union(rect);
is called each run, place it before

Code: Select all

if (vncService::InputDesktopSelected()==2)
so it look like this

Code: Select all

		//screensize_changed=true;
	}
m_desktop->m_buffer.WriteMessageOnScreen("UltraVVNC running as application doesn't \nhave permission to acces \nUAC protected windows.\n\nScreen is locked until the remote user \nunlock this window");
		rfb::Rect rect;
		rect.tl = rfb::Point(0,0);
		rect.br = rfb::Point(300,120);
		rgncache.assign_union(rect);		
	if (vncService::InputDesktopSelected()==2)
	{
           if (m_desktop->startw8)
				{
Now you should see what you do on screen
Post Reply