Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl hangs

Status
Not open for further replies.

skottieb

Programmer
Jun 26, 2002
118
AU
Hello,
I have written a pretty crude port scanner in perl, the problem I am having is when I run it it hangs on port 135 on my machine, telneting didnt help as it just hung aswell. I know it works because it detects my web server on port 80, the code is here:

#!c:\perl\bin\perl.exe -w

use Socket;
use strict;

my ($host, $scan, $proto, $paddr);

my @ports=(1 .. 65000);

print "Enter host you want to scan: ";
chomp($host=<STDIN>);

open(RESULTS, &quot;>>results.txt&quot;);
print RESULTS &quot;\n$host: &quot;;
close(RESULTS);

foreach my $port (@ports){
print &quot;scanning $host, $port\n&quot;;
$scan=(gethostbyname($host))[4];
$paddr=sockaddr_in($port, $scan);
$proto=getprotobyname('tcp');

open(RESULTS, &quot;>>results.txt&quot;);

socket(SCAN, AF_INET, SOCK_STREAM, $proto);

connect(SCAN, $paddr);

select(SCAN);
$|=1;
select(STDOUT);

print SCAN &quot;GET index.html HTTP/1.0\n\n&quot;;

if (<SCAN>){
print &quot;\nPORT $port on HOST $host is running&quot;;
print RESULTS &quot;PORT $port on HOST $host is running, &quot;;
}
close(SCAN);
close(RESULTS);
}

Does anyone know what service may be running on port 135?? It is a win2000 pro machine.. skottieb:)
 
135, sounds like something in the vicinity of SMB (I know at least port 139 is used for that).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top