Advertisement
opexxx

lantapcap.sh

Jul 10th, 2014
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.76 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # lantapcap.sh
  4. # By JP Dunning
  5. # www.foundstone.com
  6. #
  7.  
  8. NET0=eth0
  9. NET1=eth1
  10. CAPNAME=name
  11. CONTINUE=go
  12.  
  13. printf "\nUse LanTapCap for capturing network traffic with a LAN Tap\n"
  14. printf "\nInterfaces:\n\n"
  15. ifconfig -a | grep "Link encap:" | awk '{print $1}'
  16.  
  17. printf "\nSpecify interfaces for sniffing."
  18. printf "\nInterface 1 of 2 [eth0]: "
  19. read NET0
  20.  
  21. printf "Interface 2 of 2 [eth1]: "
  22. read NET1
  23.  
  24. printf "Packet capture name [Capture]: "
  25. read CAPNAME
  26.  
  27. printf "\nDisable interfaces ...\n\n"
  28. ifconfig $NET0 down
  29. ifconfig $NET1 down
  30.  
  31. printf "Enable interfaces ...\n\n"
  32. ifconfig $NET0 up
  33. ifconfig $NET1 up
  34.  
  35. printf "Set interfaces to promiscuous mode ...\n\n"
  36. ifconfig $NET0 promisc
  37. ifconfig $NET1 promisc
  38.  
  39. sleep 1
  40.  
  41. printf "Starting capturing ...\n\n"
  42.  
  43. sleep 1
  44.  
  45. xterm -bg blue -fg white -geometry 90x10-0+0 -T "Capturing on $NET0" -e tcpdump -i $NET0 -w $CAPNAME-$NET0.pcap -v &
  46.  
  47. sleep 2
  48.  
  49. xterm -bg blue -fg white -geometry 90x10-0+120 -T "Capturing on $NET1" -e tcpdump -i $NET1 -w $CAPNAME-$NET1.pcap -v &
  50.  
  51. sleep 2
  52.  
  53. printf "\n\nPress ANY KEY to end capturing.\n\n"
  54. read CONTINUE
  55.  
  56. printf "Produced capture file $CAPNAME-$NET0.pcap from $NET0\n\n"
  57. printf "Produced capture file $CAPNAME-$NET1.pcap from $NET1\n\n"
  58.  
  59. printf "Halting captures ...\n\n"
  60.  
  61. if [[ ! -z $(pidof tcpdump) ]]; then kill $(pidof tcpdump); fi
  62.  
  63. printf "Merging captures ...\n\n"
  64. mergecap $CAPNAME-$NET0.pcap $CAPNAME-$NET1.pcap -w $CAPNAME-Full.pcap
  65.  
  66. printf "Disable interfaces ...\n\n"
  67. ifconfig $NET0 down
  68. ifconfig $NET1 down
  69.  
  70. printf "Produced capture file $CAPNAME-$NET0.pcap from $NET0\n\n"
  71. printf "Produced capture file $CAPNAME-$NET1.pcap from $NET1\n\n"
  72. printf "Produced capture file $CAPNAME-Full.pcap from merging captures\n\n"
  73. printf "... done\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement