el8linuxel8 Posted March 5, 2008 Posted March 5, 2008 I knocked this script up this morning because the teachers are trying to force teachers to start using their emails, trouble is half of them have used it once and forgotten their pw's. This script is just a mass password reset at the moment, but i will be adding more features soon. If anyone is interested i will keep you updated. Anyway, thoughts and improvements are welcome #!/usr/bin/perl #mylgfl script - reset all passwords #by josh hall for BBEC use strict; use warnings; use Getopt::Long; use LWP::UserAgent; use HTTP::Request::Common; my %options; GetOptions( \%options, 'user=s', 'pass=s', 'domain=s', 'password=s', ); help() unless $options{'domain'}; my $username = $options{'user'} . '@' . $options{'domain'}; my $ua = LWP::UserAgent->new(); $ua->cookie_jar({}); $ua->agent('Mozilla/5.0'); $ua->env_proxy(); push @{ $ua->requests_redirectable }, 'POST'; #ok now we need to login my $check = $ua->request(GET 'http://www.lancsngfl.ac.uk/email-admin/login.php'); $check = $ua->request(POST 'http://www.lancsngfl.ac.uk/email-admin/login.php', [ do => 'login', user => $username, password => $options{'pass'}, submit => 1, ], ); die "You are not logged in\n" unless $check->content =~ /Logged in as/; #grab all the usernames $check = $ua->request(GET 'http://www.lancsngfl.ac.uk/email-admin/view.php'); print $check->content(); my @users = $check->content() =~ /(\w+)@[a-z\.]+<\/td>/g; #reset all users for my $user (@users) { print "Resetings User: $user\n"; edituser($user, $options{'password'}) } sub edituser { my ($username, $password) = @_; my ($surname, $initial) = $username =~ /(\w+)([a-z0-9])$/; my $check = $ua->request(POST 'http://www.lancsngfl.ac.uk/email-admin/edit.php', [ task => 'editSingle', uid => $username, forename => $initial, surname => $surname, password => $password, password2 => $password, ], ); } sub help { print <<"ENDDOC"; -------------------------------------------- MYLGFL all user Password reset version 0.1 Code grabs all usernames from view.php and then proceeds to reset the passwords to one you specified. Usage: perl mylgflreset.pl -user LGFLADMIN -pass LGFLPASSWORD -domain SCHOOLDOMAIN -password DEFAULTPASSWORD ENDDOC exit; }
el8linuxel8 Posted March 5, 2008 Author Posted March 5, 2008 https://www.lancsngfl.ac.uk/email-admin/login.php Not Found The requested URL /email-admin/login.php was not found on this server. Apache Server at http://www.lancsngfl.ac.uk Port 443
el8linuxel8 Posted March 5, 2008 Author Posted March 5, 2008 the client login lacks https too, pretty silly. Btw, i have a few moodle scripts too if anyone is interested i can dig them out.
SimpleSi Posted March 5, 2008 Posted March 5, 2008 Do you fancy posting this stuff over in the lancs forum http://www.lancsngfl.ac.uk/forums/dg as its just specfic to us? regards Simon
Geoff Posted March 5, 2008 Posted March 5, 2008 To be fair, it might not be. LancsNGFL was trying to sell the system to other LEAs/RBCs.
el8linuxel8 Posted March 5, 2008 Author Posted March 5, 2008 Feel free to post it on my behalf. Im looking at it from more of a techie aspect cos tbh, lancsngfl should be adding features like this to their apps ;-)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now