Skip to content

ABANDONED: A customized OpenWRT VMWare VM for providing virtual networks, useful for Malware Analysis.

License

Notifications You must be signed in to change notification settings

nfarrar/malgate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

MalGate

About

This guide describes the process for setting up a lightweight (~6MB compressed) VMware Appliance that applies different types of routing and levels of anonymity when performing malware analysis.

Virtual machines can be routed directly to host's network, over a VPN connection, or through TOR. Logging is not currently configured, but will implemented in the future. Bridging other physical machines into virtual networks is not yet supported but will be added (through USB nic).

Disclaimer

This work is not yet complete. There are many features I intend to add:

  • An EC2 VPN endpoint build script
  • The VPN configuration
  • A python script for managing the TOR circuits
  • Logging configuration
  • Integration with alienvault
  • Integration with bro

Download

My current VM is not sanitized. I intend to upload a prebuilt, sanitized VM once I have built it.

Naming

I have done my best to keep the naming conventions clean and standardized. I have left the default vmware virtual networks untouched, and added 3 custom networks: vmnet11, vmnet12, and vmnet13. The subnets of each of these networks correspond to their vmnet ID.

Access & Authentication

SSH & HTTP access to the gateway has been enabled on the WAN interface. The default credentials are: root/malware.

Disclaimer

This is super raw and probably completely full of errors at the moment. Needs to be cleaned up. ICMP from the tor network is currently being forwarded out through the WAN interface, and not being encapsulated by TOR. This will allow malware to test for connectivity with ICMP, but also exposes your public address in that case.

Network Configuration

Name Type Adapter DHCP Subnet Note
vmnet0 Bridged Bridged Disabled N/A Default
vmnet1 Bridged None Enabled 192.168.58.0 Default
vmnet8 NAT NAT Enabled 192.168.168.0 Default
vmnet11 Host-Only None Disabled 172.21.11.0/24 Direct
vmnet12 Host-Only None Disabled 172.21.12.0/24 VPN
vmnet13 Host-Only None Disabled 172.21.13.0/24 TOR

Base Configuration

# Set password for root user:
passwd

# Set the vm hostname:
uci set system.@system[0].hostname=gateway

# update package manifest
opkg update

# install vim & tor
opkg install vim-full tor 

WAN Configuration

# create the WAN interface:
uci set network.wan=interface
uci set network.wan.ifname=eth0
uci set network.wan.proto=dhcp
uci set network.wan.defaultroute=0
uci set network.wan.peerdns=0

# permit SSH connections from WAN:
uci add firewall rule
uci set firewall.@rule[-1].src=wan
uci set firewall.@rule[-1].target=ACCEPT
uci set firewall.@rule[-1].proto=tcp
uci set firewall.@rule[-1].dest_port=22

# permit HTTP connections from WAN:
uci add firewall rule
uci set firewall.@rule[-1].src=wan
uci set firewall.@rule[-1].target=ACCEPT
uci set firewall.@rule[-1].proto=tcp
uci set firewall.@rule[-1].dest_port=80

# commit the firewall changes and restart the firewall
uci commit firewall
/etc/init.d/firewall restart

We can now connect to the router from the WAN interface via SSH or HTTP.

LAN Configuration

This network routes traffic to internet via host's physical network.

# create the network & bind to interface
uci set network.lan=interface
uci set network.lan.ifname=eth1
uci set network.tor.proto=static
uci set network.lan.ipaddr=172.21.11.1
uci set network.lan.netmask=255.255.255.0

# configure dhcp
uci set dhcp.lan.start=200
uci set dhcp.lan.stop=225
uci set dhcp.lan.limit=25
uci set dhcp.lan.leasetime=1h

# commit changes and restart network services
uci commit network
/etc/init.d/network restart

VPN Configuration

This network routes traffic to internet through a VPN connection.

# create the network & bind to interface
uci set network.vpn.ifname=eth2
uci set network.tor.proto=static
uci set network.vpn.ipaddr=172.21.12.1
uci set network.vpn.netmask=255.255.255.0

# configure dhcp
uci set dhcp.vpn.start=200
uci set dhcp.vpn.stop=225
uci set dhcp.vpn.limit=25
uci set dhcp.vpn.leasetime=1h

# commit changes and restart network services
uci commit network
/etc/init.d/network restart

Note: The VPN configuration section needs to be made to work in a 'sharable' way.

TOR Configuration

This network routes traffic to internet through a TOR gateway and proxy. ICMP currently leaks.

# create tor network and bind to interface
uci set network.tor=interface
uci set network.tor.ifname=eth3
uci set network.tor.proto=static
uci set network.tor.ipaddr=172.21.13.1
uci set network.tor.netmask=255.255.255.0

# configure dhcp
uci set dhcp.tor=dhcp
uci set dhcp.tor.interface=tor
uci set dhcp.tor.start=200
uci set dhcp.tor.stop=225
uci set dhcp.tor.limit=25
uci set dhcp.tor.leasetime=1h

Manually edited /etc/tor/torc Added to end of file:

User tor
PidFile /var/run/tor.pid

TransPort 9040
TransListenAddress 172.21.13.1
DNSPort 9053
DNSListenAddress 172.21.13.1

TOR firewall zone configuration:

uci set firewall.@zone[2]=zone
uci set firewall.@zone[2].name=tor
uci set firewall.@zone[2].network=tor
uci set firewall.@zone[2].input=ACCEPT
uci set firewall.@zone[2].output=ACCEPT
uci set firewall.@zone[2].forward=REJECT
uci set firewall.@zone[2].conntrack=1

TOR firewall redirection rules:

uci set firewall.@redirect[0]=redirect
uci set firewall.@redirect[0].src=tor
uci set firewall.@redirect[0].target=DNAT
uci set firewall.@redirect[0].proto=tcp
uci set firewall.@redirect[0].dest_ip=172.21.13.1
uci set firewall.@redirect[0].dest_port=9040
uci set firewall.@redirect[0]._name=tor-fw-tcp
uci set firewall.@redirect[0].dest=wan
uci set firewall.@redirect[1]=redirect
uci set firewall.@redirect[1]._name=tor-fw-dns
uci set firewall.@redirect[1].src=tor
uci set firewall.@redirect[1].proto=udp
uci set firewall.@redirect[1].dest_ip=172.21.13.1
uci set firewall.@redirect[1].dest_port=9053
uci set firewall.@redirect[1].target=DNAT
uci set firewall.@redirect[1].dest=wan
uci set firewall.@redirect[1].src_dport=53
uci set firewall.@redirect[2]=redirect
uci set firewall.@redirect[2]._name=tor-fw-icmp
uci set firewall.@redirect[2].src=tor
uci set firewall.@redirect[2].proto=ICMP
uci set firewall.@redirect[2].dest_ip=172.21.13.1
uci set firewall.@redirect[2].target=DNAT
uci set firewall.@redirect[2].dest=wan

Set TOR to start automatically:

# tor won't start until after other applications are up
# in /etc/init.d/tor make the following modification:
# s/START=50/START=94/g

vi /etc/init.d/tor

/etc/init.d/tor enable

Note: Finish & add python script for managing TOR connections.

Resources

OpenWRT Basics

VirtualBox Integration

OpenVPN

Tor:

Tor & Python

Verifying Connectivity

curl icanhazip.com
curl ident.me
    curl v4.ident.me
    curl v6.ident.me
dig @trustworthysource.com +short `hostname`

About

ABANDONED: A customized OpenWRT VMWare VM for providing virtual networks, useful for Malware Analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published