------------- start netcheck.pl(Win NT Version) ---------------------------
if(length($ARGV[0]) == 0)
{
print "Usage is perl netcheck.pl IP";
exit 0;
}
open(NBT, "nbtstat -a ".$ARGV[0]." | ");
while()
{
if(!grep(/Registered/, $_))
{
if(grep(/<00> UNIQUE/,$_))
{
@machine = split(/\s/, $_);
}
if(grep(/<00> GROUP/, $_))
{
@domain = split(/\s/, $_);
}
}
}
print "Machine = ".$machine[0]."\tDomain = ".$domain[0]."\n";
print "\nChecking Guest Access\n";
open(GUESTCHK, "net use \\\\".$ARGV[0]."\\ipc\$ /user:guest guest | ");
while()
{
if(grep(/error/,$_))
{
print("Guest access denied\n");
}
}
print "\nObtaining list of shares\n";
open(NTSH, "net view \\\\".$ARGV[0]." | ");
while()
{
if(grep(/Disk/,$_))
{
@tmp = split(/\s/, $_);
push(@shares, $tmp[0]);
}
print;
}
foreach $share (@shares)
{
open(NETUSE, "net use \\\\".$ARGV[0]."\\".$share." | ");
while()
{
if(grep(/successfully/,$_))
{
print $share." opened\n";
}
}
}
------------- end netcheck.pl(Win NT Version) ---------------------------
------------- start netcheck.pl(Win 95 Version) ---------------------------
if(length($ARGV[0]) == 0)
{
print "Usage is perl netcheck.pl IP";
exit 0;
}
open(NBT, "nbtstat -A ".$ARGV[0]." | ");
while()
{
print;
if(grep(/Registered/, $_))
{
if(grep(/<00> UNIQUE/,$_))
{
@machine = split(/\s/, $_);
}
if(grep(/<00> GROUP/, $_))
{
@domain = split(/\s/, $_);
}
}
}
print "Machine = ".$machine[0]."\tDomain = ".$domain[0]."\n";
print "\nChecking Guest Access\n";
open(GUESTCHK, "net use \\\\".$ARGV[0]."\\ipc\$ /user:guest guest | ");
while()
{
if(grep(/error/,$_))
{
print("Guest access denied\n");
}
}
print "\nObtaining list of shares\n";
open(NTSH, "net view \\\\".$machine[0]." | ");
while()
{
if(grep(/Disk/,$_))
{
@tmp = split(/\s/, $_);
push(@shares, $tmp[0]);
}
print;
}
foreach $share (@shares)
{
open(NETUSE, "net use \\\\".$machine[0]."\\".$share." | ");
while()
{
if(grep(/successfully/,$_))
{
print $share." opened\n";
}
}
}
------------- end netcheck.pl(Win 95 Version) ---------------------------