forked from privacyint/appdata-environment-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnic_change.sh
74 lines (69 loc) · 1.91 KB
/
nic_change.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
66
67
68
69
70
71
72
73
74
#!/bin/bash
## Determine the NIC
wlannic=`iw dev | awk '$1=="Interface"{print $2}'`
## Ask the user to apply to config
if [ "$wlannic" == "" ]; then
zenity --warning --text="Your Wireless NIC was not detected"
exit 1
fi
zenity --question --text="Your Wireless NIC appears to be $wlannic, do you want to automatically update configuration files?"
rc=$?
if [ "${rc}" == "1" ]; then
exit 1
fi
sudo cat << EOF1 > /etc/hostapd/hostapd.conf
interface=$wlannic
driver=nl80211
ssid=pi_maninthemiddle
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=privacyint
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF1
sudo cat << EOF2 > /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface (adapter 1 in VBOX)
allow-hotplug enp0s3
auto enp0s3
iface enp0s3 inet dhcp
##Wifi controller was automatically added below
##
auto $wlannic
iface $wlannic inet static
address 100.64.32.1
netmask 255.255.255.0
EOF2
sudo cat << EOF3 > /etc/iptables/rules.v4
# Generated by xtables-save v1.8.2 on Tue Feb 19 13:55:01 2019
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i $wlannic -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
-A PREROUTING -i $wlannic -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8080
-A POSTROUTING -o enp0s3 -j MASQUERADE
COMMIT
# Completed on Tue Feb 19 13:55:01 2019
# Generated by xtables-save v1.8.2 on Tue Feb 19 13:55:01 2019
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -i enp0s3 -o $wlannic -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Tue Feb 19 13:55:01 2019
EOF3
echo "File Changes Complete"
exit 0