CAUTION!
> Running normal applications has the problem that any remote code
> execution vulnerability in the application totally compromises the
> user. This isn't just a theoretical attack, a vulnerability in Firefox
> was used to compromise visitors of hidden services hosted by freedom
> hosting in August 2013.
Never rely on the virtual machine against malicious code. For that task you should take a bare hardware, separate station connected to the Tor's host.
You can google a thousands of examples with breaking any chroot / any jail. The same picture with virtual machines.
If you do not believe me, start googling from this -> Blue Pill.
If you are looking for a solution against leaks - probably, there is a SOCKS5 settings for you:
/etc/tor/torrc:
....
SocksListenAddress 192.168.0.1:9050
....
You should create a virtual interface called "bridge" and bind IP address 192.168.0.1 from host to this interface. Thereafter, make a SOCKS5 proxy on the 9050 port for IP address 192.168.0.1:
root@host:~# brctl addbr br0
root@host:~# ifconfig br0 192.168.0.1 netmask 255.255.255.0 up
root@host:~# kill -HUP `pidof tor`
Make sure that your VM use only a virtual interface, br0
, that not connected to any external (real) interface.
In your VM, configure everything what's needed for a network to use 192.168.0.1:9050
socks5 proxy. For example, look at /usr/bin/torsocks
.
1) For example, LXC-Container, /var/lib/lxc/VM/config
:
....
lxc.network.type = veth
lxc.network.hwaddr = 00:12:34:56:78:9a
lxc.network.link = br0
lxc.network.flags = up
lxc.network.ipv4 = 192.168.0.2
....
Inside the container, change default server IP address from loopback 127.0.0.1
to virtual bridge 192.168.0.1
, for torsocks proxifier /etc/torsocks.conf
:
...
#server = 127.0.0.1
server = 192.168.0.1
...
Now you can proxify anything by torsocks:
root@vm:~# torsocks wget -q -O - https://check.torproject.org 2>&1 | egrep -i 'congratulations|ip address'
<img alt="Congratulations. Your browser is configured to use Tor." src="/images/tor-on.png">
Congratulations. Your browser is configured to use Tor.<br>
Your IP address appears to be: <b>192.3.116.166</b><br>
Bingo!
Hint: Do not break default Tor settings, keep the SOCKS5 proxy by default on 127.0.0.1:9050
and use one of the inet daemons, for example, rinetd:
root@host:~# vi /etc/rinetd.conf
# bindadress bindport connectaddress connectport
192.168.0.1 9050 127.0.0.1 9050
Now reload settings and you get 2 socks5
of Tor, one on the loopback
and another on the br0
:
root@host:~# service rinetd reload
Reloading configuration of internet redirection server: rinetd.
2) In VirtualBox you need only one settings to achieve this:

Inside the VM, configure everything to use socks5 proxy
, for example, chromium
:

3) QEMU; here you are need a tap
interface:
root@host:~# modprobe tun
root@host:~# tunctl -t tap0
root@host:~# brctl addbr br0
root@host:~# brctl addif br0 tap0
root@host:~# ifconfig br0 192.168.0.1 netmask 255.255.255.0 up
root@host:~# ifconfig tap0 up
root@host:~# iptables -I INPUT -m state --state NEW -i tap0 -j ACCEPT
root@host:~# iptables -I INPUT -m state --state NEW -i br0 -j ACCEPT
root@host:~# cat >> /etc/rinetd.conf << EOF
192.168.0.1 9050 127.0.0.1 9050
EOF
root@host:~# service rinetd restart
root@host:~# /usr/bin/qemu-system-x86_64 -boot d -m 2048 --enable-kvm \
-cdrom 'kali-linux-1.0.5-amd64.iso' \
-net nic,vlan=1,macaddr=00:aa:00:60:00:01,model=e1000 \
-net tap,vlan=1,ifname=tap0,script=no -vga std
Don't forget inside the QEMU set ip address to the eth0
interface:
root@kali:~# ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up
root@kali:~# ping 192.168.0.1
64 bytes from 192.168.0.1: icmp_req=1 ttl=64 time=0.395ms
64 bytes from 192.168.0.1: icmp_req=2 ttl=64 time=0.241ms
64 bytes from 192.168.0.1: icmp_req=3 ttl=64 time=0.42ms
....
Don't forget to change default firefox settings about:config
-> network.proxy.socks_remote_dns = True

Set socks5 proxy: Edit
-> Preferences
-> Advanced
-> Network
-> Settings
-> Manual proxy configuration
-> SOCKS Host: 192.168.0.1
& Port: 9050

Check your connection: http://check.torproject.org

Configure /etc/proxychains.conf
by adding only one string to the end of file: socks5 192.168.0.1 9050
:

Now, you can start any program with prefix proxychain program.bin
:

The VM doesn't see an external network, only tap0 and virtual bridge behind this tap0 - br0, and SOCKS5 proxy on that bridge 192.168.0.1:9050.
4) VMware:

That way, the VM will connect to the host machine, to VMware's internal virtual interface, vmnet1, only, no external network. Bind the SOCKS5 proxy to this interface by rinetd.

Q: What VMs support this?
A: pretty much everyone. QEMU, KVM, LXC, Bochs, VirtualBox, VMware, Parallels Workstation, FreeBSD jail, Xen, etc...
Q: What is the main goal?
A: With only one-two commands and SOCKS5, you can get everything what you are looking for. With any environment around you... You may replace Tor with any other proxy server or even with ssh.
It looks much better than native Tor's transport port, because SOCKS5 is everywhere. You will never see any leaks with this technique.
See: tor-talk Tor transparent proxy leaks?, trac.torproject.org: TransparentProxyLeaks.
CAUTION!
Let me tell you once again,
NEVER rely on the virtual machine against **malicious code**! This may be used only for comfort. [1][30], [2][31], [3][32], [4][33], [5][34], [6][35], [7][36], [8][37], [9][38], [10][39], [11][40], [12][41], [13][42], [14][43], [15][44], [16][45] ... infinity.
