Quality code and lots of coffee

Tag: pi

VNC Brute Force & Tunnelling

On my Linux blog I posted a few bits and pieces about my Raspberry Pi, (one post of which I think found its way to this site, but I digress) One of those posts was about setting up a VNC server on a Raspberry Pi to allow remote control over your network.

Now I used VNC a lot in my home, primarily for my laptop and home entertainment server as I like to control them from across either the living room or my bedroom, as they’re mostly used for media. So since my RPi was going to be my one-stop-shop for media, file storage and if I ever get round to it, some server hosting. I thought I may as well configure the VNC server to be accessible from the internet.

Similar to when you’re learning to drive, you never really know why you have to check your blind spot until you’re in a situation where you really should have checked your blind spot.
I.E you just nearly side-swiped somebody.

I used to have the same mentality about security, I always chose strong passwords that’s obvious but never bothered with firewalls or encryption or anything of that nature. Not with anything as harmless as the remote control I use for my server anyway.

Well for my VNC application I had some issues with password authentication, so I foolishly thought “Nah nobody will ever try VNC on this particular IP” how wrong I was. Not more than a week later I sat down to watch some TV and found that there had been some files downloaded to my desktop, some windows opened on my web browser and somebody had tried to install something. It’s a very odd feeling to have been ‘hacked’ (I use the term loosely because it was my own fault) but thankfully my external HDD hadn’t arrived yet and so the pi held little more than the OS and a wallpaper jpg. Needless to say I formatted the hard drive and put a strong password on my VNC access as well as removing password-less command execution from the default Pi account, so now I need to put in my password before executing anything (which incidentally has broken the shutdown button)

Then over the past few weeks there have been instances where I couldn’t connect to my VNC server, I chalked it up to Linux being a bit dodgy on some software packages, particularly with the arm architecture, however today I thought I was going to get to the bottom of it. When checking the screen that VINO was running in I found a series of deferred authentication attempts, and a new one was being written every second. After a brief look on the Ubuntu forums I found that it was in fact evidence that a brute force was taking place, trying to break in through my VNC password.

Thankfully Vino has a feature where after a few consistent attempts at a password it will assume there is a brute force taking place and immediately start to deny everything coming in, which I was thankful for since there are actually now files on that server.

So since it appeared that I was still not safe from pesky hackers (and I was being hacked this time) I had to beef up the security. Putting even stronger passwords on my VNC and user account on the pi. After some research I decided the best course of action would be to actually tunnel the VNC connection through my SSH.


It was the diagrams that really sold me on it

The benefits of this being that any data sent between the remote host and the client are actually encrypted through the SSH Server (which is a fair bit more secure than a standard VNC Connection), and SSH tunnelling means I don’t have to have a port forward for the VNC server itself, just the SSH server. So with the 5900 port switched off on my router, I was able to tunnel my VNC connection through the SSH server and back out to the other side – where it connected to the actual VNC server. Theres a very handy wiki on how to VNC over an SSH Tunnel here link so I won’t bother recounting my steps. It’s also very straightforward and the android app I use for VNC had an option to use SSH tunnelling (which you can find here) so I didn’t even need to find a new VNC app.

As an added precaution I changed the default port of my SSH server from 22. Since I now knew brute forcing random IPs was a thing I decided maybe being on the default option for everything was asking to be a target which you can do via the config found in

sudo nano /etc/ssh/sshd_config

probably best to take a backup though.

So there we have it, I was hacked and now I know more about SSH tunnelling and poor security.

Now we just wait for the next attack…

Raspberry Pi – Media Player

I recently took the plunge and bought a Raspberry Pi to replace my tired and decrepit old Dell Server. The main purpose of which was to hook it up to an external hard drive, leave it plugged into my TV and watch some movies on it. Basically a torrent/video box with maybe some web hosting thrown into the mix.

So the pi works out the box with NOOBS and I went straight for Raspbian as I preferred the Debian based system. However when I started with the machine it became apparent that there is actually a problem with playing videos…

The Pi isn’t a powerful computer, and as such has problems playing videos outside of specific environments such as XBMC, and since I wanted to stay away from dual boots I thought I better make it work. I tried a few solutions like VLC and Gnome-MPlayer but the hardware platform made videos a bit difficult, there was only one application that worked, OMXPlayer.

OMX is a command line video player (which sounded redundant from the start) and when I ran the command to open a video it seemed to work audio and video perfectly, however using the command line for everything is not my style, I was quite happy to keep using OXM but I was more in the mood for a double click and play situation.

Luckily I found a forum post (X) that showed me just what I was after, you can create a symbolic shortcut to OXMplayer that you can launch from the menu, and you can add an argument into the command so that you can pass a file path with a double click of the file.

First of all you need to open up a terminal and enter the following command to create the shortcut.

sudo nano /usr/share/applications/oxmplayer.desktop

then paste in the following lines

[Desktop Entry]
Type=Application
Name=OMXPlayer
Categories=AudioVideo;Player;
Exec=lxterminal –command “omxplayer -o hdmi %f”
Terminal=false
Icon=/usr/share/icons/nuoveXT2/96x96/categories/applications-multimedia.png

Use CTRL+X to save the shortcut and when closed there should be a new item in your menu showing OMXplayer

OMX Player Shortcut

Double clicking this item will not do much as there is no file to actually play, however you can change the default player of video files to use this application using by right clicking a video and pointing to this shortcut.

OMX Default Player

You can now double click on a video and it will launch in OMXPlayer command line.

There is however further problems, specifically to do with resolutions, because unfortunately for some reason if the video doesn’t match your monitor resolution you will end up with bars on the sides of the screen

Philadelphia

as you can see in the picture the sides are still visible because unfortunately earlier episodes of Sunny in Philadelphia wasn’t shot in widescreen. The video is already running as large as we can, but we need to find some way to blacken the screen.

Checking the man options for OMXplayer I found that by adding the -b argument to OMXPlayer it will black the edges of the screen for you to make video time a bit better.

Some people have indicated that there are issues with the screen refreshing or not coming back on after a video which was discussed in this bug.

So to make the screen blackout during your video change the following

[Desktop Entry]
Type=Application
Name=OMXPlayer
Categories=AudioVideo;Player;
Exec=lxterminal –command “omxplayer -b -o hdmi %f
Terminal=false
Icon=/usr/share/icons/nuoveXT2/96x96/categories/applications-multimedia.png

and that should do it easy videos.

Since the OMXPlayer is in command line there is no GUI so here is a helpful list of how to actually control the player here

© 2025 Joe van de Bilt

Theme by Anders NorenUp ↑