In this post we will learn how to secure our VPN so that it doesn’t leak any traffic.
If you have ever used a VPN for geolocation specific sites or applications, you might have run into the issue where your VPN turns off and suddenly you are connecting to that application using your main connection which can lead to minor interruptions from that site or application or even becoming blocked.
A solid setup can be the differential preventing this from happening and that is what we will learn how to configure in this post using some basic Windows firewall rules.
[ Part 1 – Part 2 – Part 3 – Part 4 – Part 5 – Part 6 – Part 7 – Part 8 ]
What’s going on guys?
Welcome to part three of the Python control server series.
In part one we created our simple server and client with about 20 lines of code each (Python 3). Then in part two, we’ve added basic AES encryption to our traffic using pyAesCrypt.
Given the nature of encryption using pyAesCrypt, we we’re unable to receive any data on the server over 1024 bytes with encryption. The main reason for this is that length needs to be passed for the decryption method.
In this part we will be fixing this issue, so let’s get with it.
Traffic Encryption
What exactly is the issue we have here? Why is less than 1024 bytes ok?
Both in our server and client we are sending 1024 bytes at a time. This means that whenever we send a message containing less than 1024 bytes, we won’t run into any issues.
Now considering we have to pass a length argument for decryption, if we send a message that is 1500 bytes, the server will receive the first 1024 bytes and attempt to decrypt it – resulting in an error.
This is where we have a few different options: receive all the encrypted data and then decrypt it all at once; or, receive smaller chunks of data and decrypt on-demand. Both options have their merits, I decided this latter one would be easier to program for a encryption noob like me. 🙂
Welcome to part two of the Python control server series.
In the first part of the series we made a simple plaintext control server. It allows you to run commands and control your systems from a distance.
This time we’re stepping it up and adding AES encryption to it.
Traffic Encryption
Since the plan is to eventually add more functionality to our server such as file transfer and reading documents over public networks, traffic encryption is definitely essential to the project.
Imagine you are downloading a file from your computer at home to your laptop using a hotel’s public wireless connection. It’s hard to feel safe about it without using some form of encryption.
For this and other reasons, we’ll be using pyAesCrypt to encrypt the connection to our server using AES both ways (server and client).
I have a short encryption tutorial for you today, which is kind of a continuation from my recursive file encryption post a while back.
In that post we did encryption of multiple files recursively, while this time we’ll be doing in-memory AES encryption over the network.
This tutorial will be limited in scope in the sense that we’ll only send the data one way for now (from client to server); however, the plan is to incorporate it into my python control server series soon.
We’ll be using Python 3 for this tutorial (as one should by now). For the encryption side of things we’re using pyAesCrypt, which can be easily installed with pip by running the following command in a terminal:
python -m pip install pyaescrypt
In the video above, after going through the code and explanations, I also fire up wireshark and show the difference from both a plaintext server/client traffic to the encrypted data we’re implementing here.
We’re off to another series: Python Control Server.
Yes, there’s three series going on at once in the blog, so what! 😀
I like having multiple things going so that I don’t have to think much whenever I have some free time to code. I can just sit down and choose whichever series/project to work on at the moment.
Anyway, many people emailed me to post my old videos (from like 10 years ago) from this same series – written in Python 2.X.
It’s also worth mentioning that some of the libraries I used back then have not been properly ported over to Python 3. Overall it just makes a lot of sense to redo the project using more current libraries.
Control Server
Why make a Python Control Server?
For many (ahem, very educational) reasons of course! Like for example, we are two days away from Christmas and many people enjoy taking vacations around this time. Well, why not setup a nice control server to have access to your systems while your away?
Sounds like a good idea time to me!
About Christmas though, I had my first batch of family visiting and let me tell you… its rather easy to get a cold when there’s a lot of people in the same household for hours at a time. So pardon my voice in the video.
Recent Comments