Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Disable Guest Account Subnet Sweep

by OzzyOsbourne (Chaplain)
on Mar 07, 2002 at 20:28 UTC ( #150116=sourcecode: print w/replies, xml ) Need Help??
Category: NT Admin
Author/Contact Info OzzyOsbourne
Description: Disables guest accounts on all machines on a subnet
# Disables the guest account on every machine on a subnet

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

use Net::Ping;
my (%Hash, @accounts,$p);
my $subnet='117';
for(113..113){
  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";
        }
        elsif ($Disable==0){
          $Hash{USER_FLAGS} = $Hash{USER_FLAGS}|UF_ACCOUNTDISABLE;
          Win32::AdminMisc::UserSetMiscAttributes( $Domain, $User, USE
+R_FLAGS, $Hash{USER_FLAGS} );
          print "$ip: $User ENABLED\t";
        }
        LocalGroupGetMembers($ip,"Administrators",\@accounts);
        if (@accounts&&LocalGroupIsMember($ip,"Administrators", "Guest
+")){
      print "Guest in Admin Group";
        }
      }else{
        print "$ip: $User does not exist or Access Denied";
      }

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

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://150116]
help
Chatterbox?
[Cosmic37]: greetings earthlings please can someone improve my pathetic perl knowledge
[Cosmic37]: I have 2 files each with datetime and other data in unknown order and I want to find rows from both files matching by datetime and output them combined/ concatenated
[Corion]: Sure
[Corion]: Do you have any specific interests or general Perl knowledge?
[Cosmic37]: should I slurp? should I grep? Noble Lords I wish you good karma and beg your advice
[Corion]: Cosmic37: Ah, see perlfaq4, about How do I compute the intersection of two arrays
[Cosmic37]: I am out of practice; I use Perl for scientific programming for number crunching
[Corion]: Cosmic37: Basically, you read one file into a hash, keyed by your key, and then match the lines from the second file to that hash

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2017-06-29 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (672 votes). Check out past polls.