O'Reilly logo

Penetration Testing with Perl by Swizec Teller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Designing our own live host scanner

Let's now write our own host scanner program in Perl. We will be using a few new Perl modules, which will be described as we go over the code in the description:

#!/usr/local/bin/perl5.18.2 -w use strict; use Net::Pcap qw( :functions ); use Net::Frame::Device; use Net::Netmask; use Net::Frame::Dump::Online; use Net::ARP; use Net::Frame::Simple; my $err = ""; my $dev = pcap_lookupdev(\$err); # from Net::Pcap my $devProp = Net::Frame::Device->new(dev => $dev); my $ip = $devProp->ip; my $gateway = $devProp->gatewayIp; my $netmask = new Net::Netmask($devProp->subnet); my $mac = $devProp->mac; my $netblock = $ip . ":" . $netmask->mask(); my $filterStr = "arp and dst host ".$ip; my $pcap = Net::Frame::Dump::Online->new( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required