Tuesday, January 24, 2017

Routing Kali Linux Through Whonix Gateway




Adding Kali Linux to your Torified Whonix Gateway is a simple task. If you haven't read the walk-through on setting up your Whonix Gateway check it out HERE.


Once you have imported the .ova file into VirtualBox click on the settings gear and set the Network Adapter as shown. Note: We are using the Internal Network named Whonix and checking the Cable Connected box.




Next start up the Gateway, then Kali. Now you will need to edit some of Kali's configuration files so she can see the network. At the terminal:

gedit /etc/network/interfaces

Add the following to the interfaces file and save:

iface eth0 inet static
      address 10.152.152.11
      netmask 255.255.192.0
      gateway 10.152.152.10

Now it gets a little squirrely.

All of the online help we've seen says to edit /etc/resolv.conf by adding:

nameserver 10.152.152.10

But when we gedit the file in the newest version of Kali.ove we find it is set to read only. You can, of course, change the permissions of /etc/resolv.conf and edit it directly, but after some investigation we found that /etc/resolv.conf is auto generated from /var/run/NetworkManager/resolv.conf and editing this file will therefore change the /etc/resolv.conf file without changing permissions.

Unfortunately, in either case, we found that the edit does not persist after reboot.

This leaves us in the place of needing to gedit /var/run/NetworkManager/resolv.conf every time we start Kali. Cumbersome, but we have yet to find a way to make Kali remember the Whonix nameserver in /etc/resolv.conf

We are sure there is a way to achieve this, but we simply haven't taken the time to explore.

Our work around involves a few commands at the terminal when we want to connect Kali to Whonix. We have settled on this approach after deciding we prefer Kali not automatically connect to the network at boot and we can also bypass the need to gedit /etc/resolv.conf every time with the following command string: simplifying the process

echo server name 10.152.152.10 >> /var/run/NetworkManager/resolv.conf

This command appends the edit we want to make to the resolv.conf file without bringing up the editor, editing, and saving the file.

Now we just need to reset the interface with:

ifdown eth0
ifup eth0

Note: the ifdown ifup commands appear to throw an exception, but they non-the-less work as expected.

We are now connected to TOR through the Whonix Gateway!

To make the connection easier we can create a shell script with the following commands and name it something like TorConnect.

echo server name 10.152.152.10 >> /var/run/NetworkManager/resolv.conf
ifdown eth0
ifup eth0

Now when we run the script from the terminal prompt we connect to TOR through Whonix without all the typing. We have found this to be a good implementation as it allows us to connect to TOR when we need to, but Kali doesn't automatically connect to any network on boot.

No comments:

Post a Comment