Documentation and the Configuration of the project: Intermidiary Gateway in Public Networks Evaluation, which describes how to reproduce the steps of setting up the same network environment, and conduct the same security tests.
- Raspberry Pi (in our case PI2)
- Supported USB Wifi Adapter (our case Ralink chipset) (realtek is NOT recommended)
- micro SD card
- Router with internet access (and permission to hack it)
- Ethernet Cable
- Attack Computer (with wifi)
- Download openwrt image (for your raspberry pi model)
- Install Raspberry Pi Images
- Flash the SD card with the openwrt image using raspberry pi imager
- Connect the powered up raspberrypi to your computer via ethernet (insert sd card into the raspberry pi beforehand)
ssh root@192.168.1.1
passwd
and type in the new password- Add the initial network configurations to the /etc/config/network file
- Edit /etc/config/firewall to change
option input 'REJECT'
tooption input 'ACCEPT'
, which is located belowoption name 'wan'
- Connect the raspberry pi to the public router through ethernet
- Get the new ip address with
nmap -sn [x.x.x.x/xx] | grep -B2 raspberry
- ssh into the new ip address
opkg update
opkg install kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb kmod-usb-core kmod-usb-uhci kmod-usb-ohci kmod-usb2 usbutils openvpn-openssl luci-app-openvpn
to install drivers and other dependencies` (these drivers are specific to ralink)- Apply the final network configuration
- Apply the wireless configuration located in /etc/config/wireless (if the file doesn't exist, create it)
service network restart
uci commit wireless
wifi
- Insert the USB Wifi Adapter
Steps to reproduce Virtual Router Setup:
- Download openwrt image (for your machine's architecture)
gzip -d openwrt-*.img.gz
VBoxManage convertfromraw --format VDI openwrt-*.img openwrt.vdi
VBoxManage modifymedium openwrt.vdi --resize 128
- Create a new virtual machine with the openwrt.vdi drive attached
- Clone this VM to create the virtual public and private routers
- Attach 3 network adapters to the public router: Host only, NAT and Internal Network pubnet (Host only serves for remote ssh connection from host for headless operation)
- Attach 2 network adapter (Internal Networks) to the private router: pubnet and privnet
- Create a kali or parrot VM connected to the Internal Network pubnet
- Create a windows VM for each pubnet and privnet
- Apply configurations to the routers
https://protonvpn.com/support/how-to-set-up-protonvpn-on-openwrt-routers/
Three files need to be edited (besides the firewall):
/etc/openvpn/myvpn.auth
/etc/openvpn/myvpn.ovpn
/etc/config/openvpn
myvpn` is arbitrary, and can be changed to anything, as long as it matches everywhere.
This file contains username and password for the vpn connection (both look like hashes, and are seperated by a new line)
This is the downloaded config file from your vpn prvider's download page. Must be edited:
.
.
.
remote-cert-tls server
auth-user-pass /etc/openvpn/myvpn.auth
pull
fast-io
.
.
.
This file should be renamed to myvpn.ovpn (change myvpn to anything) and placed in /etc/openvpn
.
There should be only auth-user-pass
present, instead of auth-user-pass /etc/openvpn/myvpn.auth
, so the last part should be added.
Must contain:
config openvpn 'myvpn'
option config 'etc/openvpn/myvpn.ovpn'
option enabled '1'
The firewall modifications for the vpn are shown in the Firewall Setup section.
Make sure the end device uses the gateway's DNS settings and an up-to-date web browser.
Replace the firewall configuration file in /etc/config with the one from this repository
- Drop crafted packets:
option drop_invalid '1'
- SYN flood protection:
option synflood_protect '1'
option synflood_rate '25/s'
option synflood_burst '50'
option tcp_syncookies '1'
- Reject inbound traffic from wan and vpn networks:
option input 'REJECT'
- Enable NAT towards this zone:
option masq '1'
(Translates addresses from other zones and presents them to this one) - Include
tun0
interface to give access to lan devices (there are other implementations aswell)list device 'tun0'
list network 'wan'
list network 'wan6'
Enable lan zone to have access to the wan zone:
config forwarding
option src 'lan'
option dest 'wan'
lsusb
dmesg
cat /sys/kernel/debug/usb/devices
opkg update
opkg install <package>
service network restart
uci show network
uci commit wireless
wifi
iwinfo wlan0 scan