7 use Data::Dump qw/dump/;
15 $path =~ s{[^\w\d\.]+}{_}g;
19 system("nmap -O -oX /tmp/$path $what") == 0 || return;
23 KeyAttr => { address => 'addrtype' },
24 ForceArray => [ 'host', 'osmatch', 'port' ],
29 foreach my $host ( @{ $nmap->{host} } ) {
33 my $ip = $host->{address}->{ipv4}->{addr} || die "ipv4";
34 my $mac = $host->{address}->{mac}->{addr} || die "mac";
38 client::save_ip_mac( $ip, $mac );
39 if ( my $os = $host->{os}->{osmatch}->[0]->{name} ) {
40 client::conf( $ip, 'os' => $os );
43 my @ports = map { $_->{portid} } @{ $host->{ports}->{port} };
44 client::conf( $ip, 'ports' => join("\n", @ports) ) if @ports;
49 warn "# finish $count hosts";