Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Guest Account Subnet Sweep

by OzzyOsbourne (Chaplain)
on Mar 07, 2002 at 20:27 UTC ( #150115=sourcecode: print w/ replies, xml ) Need Help??

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
+ist);

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

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

for(1..239){
  chomp;
  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";
        }
        LocalGroupGetMembers($ip,"Administrators",\@accounts);
        if (@accounts&&LocalGroupIsMember($ip,"Administrators", "Guest
+")){
      print OUT "Guest in Admin Group";
      print "Guest in Admin Group";
        }
      }else{
        print "$ip: $User does not exist or Access Denied";
        print OUT "$ip: $User does not exist or Access Denied";
      }

  }else{
      print "$ip: not available";
      print OUT "$ip: not available";
  }
  $p->close();
  print "\n";
  print OUT "\n"
}

Comment on Guest Account Subnet Sweep
Download Code

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://150115]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2016-02-13 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (449 votes), past polls