Sonntag, 7. Dezember 2014

Access websites restricted to a certain domain or network

Imagine you want to browse a website, that is only available within a certain domain or network, e.g. http://fritz.box from outside your local network. If you manage to have a VPN server running inside the network, you are fine with simply establishing the VPN tunnel (see e.g. RaspberryPi as VPN server). But in the other case, there is a very simple way I just got aware of.

The only prerequisite is a host within the network you have access to via SSH. In my case this is a raspberry pi connected to the router (FritzBox) via ethernet. Let us now assume you want to open the configuration page of your router (http://fritz.box) from your desktop PC at university:

Open a terminal and establish an SSH connection using the -D port option:
ssh -D 12345 user@hostInsideNetwork.de

This will make ssh act as SOCKS server tunneling every connection established to the specified port to the hostInsideNetwork. Remember that rebinding privileged ports needs root level access.

After that configure your browser to use this local bound port as SOCKS proxy:

Now you are able to access websites (e.g. http://fritz.box) within the local network, just as if you were there.

Sonntag, 2. Februar 2014

GMail contacts in alpine

I was wondering, if there is a possibility to import all my GoogleMail contacts in alpine. It was easy to figure out that alpine stores contacts per default in a hidden file called .addressbook in the home directory:
~/.addressbook
Each line in this file represents an addressbook entry in three tab-separated columns, like shown in the example below.
nickname (tab) full_name (tab) email-address
Albert_Einstein      Einstein, Prof. Dr. Albert     albert.einstein@patentamt.ch
Werner_Heisenberg    Heisenberg, Prof.Dr. Werner    werner.heisenberg@uni-leipzig.de
Max_Planck           Planck, Prof. Dr. Max          max.planck@uni-berlin.de

...
After some research I found a widely spread example script that makes use of the python module gdata interfacing Google's Data API to query the contacts stored in a GMail account. I modified and extended it to fit my needs in terms of exporting the contacts in alpine conform syntax. You can find the script here (you need the python gdata module as a prerequisite). The scripts takes your GMail address as a command line parameter and asks for your password via python's getpass module. After authentication it queries for all entries in your contacts database and prints the parsed information as lines of text in the right format. To get the contacts into your alpine .addressbook simply run
python gmail2alpine.py  >> .addressbook
I choose the nickname field to be the full name joined with underscores (like in the example above) and ignoring prefixes like "Prof. Dr.", but feel free to edit the corresponding method in the script to your needs.