I'm coding a little app to find idle hosts using nmap, but I recieve SIGSEGV errors. I'm not sure if this is my fault or nmaps fault.
#!/usr/bin/perl -w
use strict;
my $ip;
my $goodhosts = 0;
my $marker = 0;
while ($goodhosts != 10 ) {
#used to pick a random ip address
open(GETHOST, "nmap -iR 1 -sL |") || die "fix your code\n";
while (<GETHOST>) {
chomp;
if ($_ =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) {
$ip = $1;
}
}
close(GETHOST);
#test for idleness
open(IDLERESULT, "nmap -P0 -sI $ip whatever.ip |") || die "bad code\n"
+;
while (<IDLERESULT>) {
chomp;
if (m/completed/) {
$marker = 1;
}
}
close(IDLERESULT);
if ($marker == 1) {
$goodhosts = $goodhosts + 1;
system("echo $ip >> idle_hosts");
$marker = 0;
}
}
root@me root# ./idlesearch
Idlescan zombie 52.7.124.210 (52.7.124.210) port 80 cannot be used because it has not returned any of our probes -- perhaps it is down or firewalled.
QUITTING!
caught SIGSEGV signal, cleaning up
Idlescan zombie 164.248.128.208 (164.248.128.208) port 80 cannot be used because it has not returned any of our probes -- perhaps it is down or firewalled.
QUITTING!
caught SIGSEGV signal, cleaning up
Here is my box
uname -a
Linux 2.6.3-27mdk #1 Tue May 31 21:48:42 MDT 2005 i686 unknown unknown GNU/Linux
And here is perl
perl -v
This is perl, v5.8.3 built for i386-linux-thread-multi
And here is nmap
nmap -version
nmap version 3.93 ( http://www.insecure.org/nmap/ )
Thanks for any help.
Mike
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.