Okay, for what it's worth, here's my version. It does seem to work well enough:

#!C:\perl\bin\perl.exe my $netstat = "C:\\WINNT\\System32\\netstat.exe"; sub clear_screen { my $cmd; if ($^O =~ /win32/i) {$cmd = 'cls'} else {$cmd = 'clear'} system($cmd); } sub ferret { my ($line, @ports) = @_; my ($protocol, $local, $other, $status) = split(/\s+/, $line, 4); my ($local_addr, $local_port) = split(/:/, $local); my ($other_addr, $other_port) = split(/:/, $other); my @scan; foreach (@ports) { if ($local_port =~ /$_/){ push @scan, "$local_port -> $other_addr" if $status =~ /ESTABLISHED/; push @scan, "$local_port listening..." if $status =~ /LISTENING/; push @scan, "$local_port waiting..." if $status =~ /TIME_WAIT/; } } return @scan; } # Scan a range of ports, sub scan_range { my $range = shift; my @ports; foreach (@_) {push @ports, ($_-$range .. $_+$range)}; open(NETSTAT, "$netstat -a -p tcp|") or die "Oops! Cannot run netstat: $! \n"; my $report; while(<NETSTAT>) { next unless $_ =~ /TCP/; $_ =~ s/^\s+//; $report .= join "\n", ferret($_, @ports); } close(NETSTAT); $report = "Ports idle..." unless $report; clear_screen(); return "$report\n"; } # Repeatedlt scan certain ports and their immediate neighbors. my @ports = (4899, 8080); # Win32 RAdmin, XML-RPC. my $range = 5; # How many neigbhbors to either side. my $seconds = 60; # How long to wait between scans. my $minutes = 30; # How long to keep re-scaning. for (1 .. int($minutes / $seconds * 60)) { print "Scan $_ ", scan_range($range, @ports); sleep $seconds; }

In reply to Re: RAdmin detector for Win32 by aplonis
in thread RAdmin detector for Win32 by aplonis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.