source: fierce2/trunk/lib/Fierce/Iprange/NmapPingScan.pm @ 6

Revision 6, 1.1 KB checked in by jabra, 5 years ago (diff)

update

Line 
1package NmapPingScan;
2{
3    use Object::InsideOut;
4    use Nmap::Parser;
5
6    # execute: Iprange -> Output(Array)
7    # find all the IPs that respond to ping
8    sub execute {
9        my ($self, $iprange_obj) = @_;
10
11        my $iprange = $iprange_obj->iprange;
12        my $np  = Nmap::Parser->new;
13        my $nmap_path = "nmap";
14        my $args = "-sP";
15        my @data;
16       
17        $np->parsescan( $nmap_path, $args, @$iprange );
18        for my $host ( $np->get_ips('up') ) {
19            push(@data,$host);
20        }
21
22        return \@data;
23    }
24   
25    # run_normal_output: Iprange -> Output(Array)
26    # find all the IPs that respond to ping and returns normal Output
27    sub run_normal_output {
28        my ($self, $iprange_obj) = @_;
29        my $data = $self->execute($iprange_obj);
30        my @output;
31       
32        push(@output, "\nTrying to find IPs that respond to ping...\n");
33        if ( @$data )  {
34            foreach my $item (@$data) {
35                my ($host) = $item;
36                push(@output,"\t$host\n");
37            }
38        }
39
40        return @output;
41    }
42 
43}
44
451;
Note: See TracBrowser for help on using the repository browser.