Category: NT Admin
Author/Contact Info OzzyOsbourne
Description: Sweep a subnet for the status of the guest account.
#checks the guest account status across a range of IPs

use strict;
use Win32::AdminMisc;
use Win32::NetAdmin qw(LocalGroupGetMembers LocalGroupIsMember UsersEx

use Net::Ping;
my (%Hash, @accounts,$p);
my $subnet='40';

open OUT, ">guestcheck.txt" or die "can't open outfile\n";

  my $ip="10.1.$subnet.$_";
  $p = Net::Ping->new("icmp");
  if ($p->ping("$ip")){
      my $Domain="\\\\$ip";
      my $User='Guest';
      if (UsersExist($Domain, $User)){
        Win32::AdminMisc::UserGetMiscAttributes( $Domain, $User, \%Has
+h );
        my $Disable=$Hash{USER_FLAGS}&UF_ACCOUNTDISABLE;
        if ($Disable==2){
          print "$ip: $User Disabled\t";
          print OUT "$ip: $User Disabled\t";
        elsif ($Disable==0){
          print "$ip: $User ENABLED\t";
          print OUT "$ip: $User ENABLED\t";
        if (@accounts&&LocalGroupIsMember($ip,"Administrators", "Guest
      print OUT "Guest in Admin Group";
      print "Guest in Admin Group";
        print "$ip: $User does not exist or Access Denied";
        print OUT "$ip: $User does not exist or Access Denied";

      print "$ip: not available";
      print OUT "$ip: not available";
  print "\n";
  print OUT "\n"