forked from Hainish/RaspberryPi-Packet-Sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justwifi.sh
65 lines (51 loc) · 2.81 KB
/
justwifi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# In case you wanted to just create a WAP
# Sets up from these directions: https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-routed-wireless-access-point
# Routed Wireless Access Point
echo "
+- RPi -------+
+---+ 10.x.x.2 | +- Laptop ----+
| | WLAN AP +-))) (((-+ WLAN Client |
| | 192.168.x.1 | | 192.168.x.2 |
| +-------------+ +-------------+
+- Router ----+ |
| Firewall | | +- PC#2 ------+
(Internet)---WAN-+ DHCP server +-LAN-+---+ 10.x.x.3 |
| 10.x.x.1 | | +-------------+
+-------------+ |
| +- PC#1 ------+
+---+ 10.x.x.4 |
+-------------+
"
# Ensure we exit on error
set -e
# Install AP and Management Software
sudo apt-get update && sudo apt-get upgrade
sudo apt install hostapd dnsmasq python3
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent
# Set up the Network Router
sudo bash -c "echo 'interface wlan0' >> /etc/dhcpcd.conf"
sudo bash -c "echo 'static ip_address=192.168.4.1/24' >> /etc/dhcpcd.conf"
sudo bash -c "echo 'nohook wpa_supplicant' >> /etc/dhcpcd.conf"
sudo bash -c "echo 'net.ipv4.ip_forward=1 #Enable IPv4 routing' >> /etc/sysctl.d/routed-ap.conf"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo netfilter-persistent save
# Configure the DHCP and DNS services for the wireless network
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo touch /etc/dnsmasq.conf
sudo bash -c "echo 'interface=wlan0 # Listening interface' >>/etc/dnsmasq.conf"
sudo bash -c "echo 'dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h' >>/etc/dnsmasq.conf"
sudo bash -c "echo ' # Pool of IP addresses served via DHCP' >>/etc/dnsmasq.conf"
sudo bash -c "echo 'domain=wlan # Local wireless DNS domain' >>/etc/dnsmasq.conf"
sudo bash -c "echo 'address=/gw.wlan/192.168.4.1' >>/etc/dnsmasq.conf"
sudo bash -c "echo ' # Alias for this router' >>/etc/dnsmasq.conf"
# Ensure Wireless Operation
sudo rfkill unblock wlan
# Download the hostapd config, enable the service
sudo wget -O /etc/hostapd/hostapd.conf https://raw.githubusercontent.com/zoracon/RaspberryPi-Packet-Sniffer/master/hostapd.conf
sudo bash -c "echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' > /etc/default/hostapd"
# Reboot to start dnsmasq, hostapd and apply ip forwarding.
# mitm.sh has to be run manually to start MITMing traffic
sudo systemctl reboot