The Art of Efficiency: Automating Recurring Tasks

Recently, in an interview for a cybersecurity company, I was talking about my old scripts, mostly written in Bash. And I rediscovered a very short script that has a story behind and shows how a small lazyness can lead to writing code. When you want to code something but don’t know what to do, because “this or that already exists so it’s pointless”, it could be a good starting point.

Since 2013, a free VPN is available for all, vpnbook.com (But be careful when using a free VPN). They provide a few ovpn files for TCP and UDP connection. A username and password for connecting their VPN are displayed on the same page, you need to use them on your VPN client for getting access.

In 2016 when I discovered this website, it was still possible at that time to copy/paste the code, it was written in text as you can see if you try to select it on this archive taken at the same period : Free VPN Accounts • 100% Free PPTP and OpenVPN Service (archive.org)

At that period, because I was bored of opening the web browser or a new tab for going to this page everyday, for copying the password written bottom page, opening a terminal, executing OpenVPN and then pasting the password (which was valid just for a few days, the username was always the same), I decided to make it simple.

It was possible to select the text with the pointer as we can see below, which means it was possible to grab it directly in the source code.

Then when the webapge was open, you had to copy it with Ctrl+C or right click and the “Copy” option, and to paste it in you VPN client, whether it’s a command line interface or GUI mode.

So I wrote a short script for getting the password and execute OpenVPN CLI in a row: passvpn
(This Github profile is my former one, which I can’t access anymore. The new one is here).

The goal of this script was to capture the password using 2 simple regular expressions. First, it gets the source code with wget, and second, it looks for the word “Password” in the HTML source code. For finding it, it looks for the third “less-than” symbol (<) by using the cut command(cut -d '<' -f 3), looks for the second “greater-than” symbol (>) still with the cut command (cut -d '>' -f 2), and gets the string written in between.

So, by executing this script, the password was displayed directly in the terminal before executing OpenVPN. I just had to type the passcode written on top.

Just as an example I’ve just adapted the script for getting the source code from the archived version of VPNBook, mentioned above, on the Wayback Machine (The warning for the deprecated method in the ovpn file was not displayed in 2016).

Since a few years, this script is not usable anymore, because VPNBook made an invisible change on their website. The font used for the string looks similar but it’s now displayed as an image, as we can see if we try to select the password on the current website.

Is it a coincidence or did they modify it because of my script? Never got a clear answer about this, but it could be funny if I made them change their page because of my lazyness for recurring things. The reason for this modification could be to force us to visit their website and display their ads, even if I’ve never seen any of them, and/or to lead us to the donation form on the right side of the webpage, maybe.

Be lazy, be creative, and try to automate every repetitive action in your daily life.

Leave a Reply

Your email address will not be published. Required fields are marked *

Creative Commons License CC BY-SA 4.0