You could try using use Win32::NetAdmin.  It has a various options
for looking at different machines on the network, eg use

      Win32::NetAdmin::GetServers($Opdc, $dom, SV_TYPE_NT, \%nt);

and the keys in %nt will be the NT machines your network,

      Win32::NetAdmin::GetServers($Opdc, $dom, SV_TYPE_WINDOWS, \%win);

gets windows 95 (and I think lower versions).

The different SV_ constants aren't described in the documentation
for the module.  I can send what I've found out about them to you
if you're interested.

Cheers,

Kev.


-----Original Message-----
From: Geoffrey Leeming [mailto:geoffleeming@;lycos.com]
Sent: 13 November 2002 11:39
To: [EMAIL PROTECTED]
Subject: Browsing for SMB machines using a network broadcast?


I'm trying to get a list of all Windows machines on my network.  I
currently
ping each IP address in turn (using Net::Ping).  For every machine that
responds to a ping, I use IO::Socket to open a tcp connection to port 139.
Once that's done, I have a list of all machines on the local network that
respond on port 139, which (I believe) corresponds pretty closely to the
list of all Windows machines with our standard build.

Unfortunately, this is way too slow for my purposes.  Non-windows machines
(that don't have SMB turned on) will not respond on port 139, and the
socket
connect attempt eventually times out.  It's that 'eventually' bit that
makes
the whole script run horribly slowly.  I'm scanning all machines in the
10.5.x.x range (my local network) and this takes about five hours to
complete.

As I'm running the script on Win32, the IO::Socket timeout option isn't
enabled, and I can't use alarm() to interrupt the attempt earlier.

>From what little I understand of networking, I think I should be able to
broadcast a UDP packet to port 139 (or 138? not sure) on the network, then
set up a listener to field the replies as they come in.  However, that's
all
I know so far and I'm somewhat wary of experimenting with broadcasts on a
live network... and no, I don't have a test network :-(

Is there anyone out there who's done this or similar before and can point
me
in the right direction?  How do I craft that UDP packet?  What port should
I
be listening on for replies?  What should I be listening for?  Is there a
simpler way (preferably native perl, not shelling out to other tools) to
retrieve a list of Windows boxes?

NB I've tried using nmap's ping scanning and OS fingerprinting but that
seems even slower...


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to