Jason,

Thanks for the info.  However, here is a script I wrote several months 
back when I was just starting with Perl.  I used the AdminMisc extension. 
I have issues when I turn OFF the file and printer sharing on the target 
machine, the script cannot compare the passwords at all.  But if the file 
and printer sharing is ON, this script works fine.  Basically what the 
script does is it tries to compare the local administrator password of a 
machine to a list.  If it doesn't match the standard password, it gives 
you an option to change it.


use warnings;
use Win32::AdminMisc;
use Net::Ping;

print "Please enter standard password: ";
chomp ( my $standard = <STDIN>);

my @machines = @ARGV;
my @names = qw(administrator);
my @passwords = ($standard, "password", "welcome", "");

my $p = Net::Ping->new("icmp");

foreach (@machines)
{
   print "pinging $_...\n";
   if ($p->ping($_, 2))
   {
      OUTER: foreach my $name (@names)
      {
         print "\\\\$_\\$name";
 
         foreach my $password (@passwords)
         {
 if(Win32::AdminMisc::UserCheckPassword("\\\\$_",$name,$password))
            {
               if ($password eq $standard)
               {
                  print ",password matched the standard\n"; 
                  next OUTER;
               }
               elsif ($password eq "")
               {
                  print ",password is blank\n";
                  change_password($_, $name);
                  next OUTER;
               }
               else
               {
                  print ",password is \"$password\"\n";
                  change_password($_, $name);
                  next OUTER;
               }
            }
            else
            {
               if ($password eq $passwords[-1])
               {
                  print ",password is unknown\n";
                  change_password($_, $name);
               }
               else
               {
                  next;
               }
            }
         }
      }
   }
   else
   {
      print "$_ is NOT reachable\n";
      next;
   }
   sleep(1);
}

$p->close();

sub change_password
{
   my ($machine, $name) = @_;
   print "\nDo you want to change the local admin password for $_? [Y/N] 
";
   chomp (my $answer = <STDIN>);
   if ($answer=~/^y$/i)
   {
      print "\nType new local admin password: ";
      chomp (my $newpassword = <STDIN>); 
      Win32::AdminMisc::SetPassword("\\\\$_",$name,$newpassword);
      if(Win32::AdminMisc::UserCheckPassword("\\\\$_",$name,$newpassword))
      {
         print "\n\\\\$_\\$name,password changed.\n";
      }
      else
      {
         print "\n\\\\$_\\$name,not able to change password.\n";
      }
   }
}


Regards,
Sam Dela Cruz










"King, Jason G" <[EMAIL PROTECTED]>
Sent by: 
[EMAIL PROTECTED]
03/25/2003 02:55 PM

 
        To:     <[EMAIL PROTECTED]>
        cc:     (bcc: Sam Dela Cruz/SVL/SC/PHILIPS)
        Subject:        RE: turn off file and printer sharing for windows machines
        Classification: 



Sam writes ..

>I just want to find out what your opinion is with regards to turning
>off file and printer sharing for windows machines in a network. Would
>turning this off cause you from not being able to do management tasks
>on machines via scripts? Or those tasks can be done but will just be
>limited by the privilege you have? etch. I remember at some point,
>there is a perl script that I did in the past that I wasn't able to
>make a query on a machine because the file and printer sharing was off.
>What could be a way around it if that happens? Just want to find out
>general opinions about this. Thanks.

"File and Printer Sharing" is Microsoft's euphemism for "NetBIOS" (aka
SMB, CIFS, NTLM, etc.) it is the protocol that Windows machines use to
talk to each other to share files and do some management tasks (not
all). Disabling it on a machine means that machine will no longer be
listening for that protocol and will ignore any requests sent to it.
This is irrespective of the permissions/privileges that you have set on
that machine. Once the protocol is disabled there can be no activity for
those requests.

It is always advisable to switch NetBIOS off on internet-facing network
connections. So, unless your network is behind a firewall that blocks
NetBIOS or a NAT that prevents external machines from accessing internal
machines then it's definitely recommended to switch off NetBIOS on all
network interfaces within your network. But if you have either a
firewall or some NATting going on, then leave it enabled because your
network is closed and probably not susceptible to NetBIOS
attacks/probes/interrogations.

Btw, this has nothing to do with Perl, so you'll definitely get a better
answer in a different forum. There are plenty of security websites
around that talk about this, and plenty of security forums as well.

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



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

Reply via email to