-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand_user.pl
More file actions
32 lines (23 loc) · 771 Bytes
/
rand_user.pl
File metadata and controls
32 lines (23 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
use strict;
use warnings;
use String::Random qw/random_regex/;
use Digest::MD5 qw/md5_base64/;
use Apache::Htpasswd;
my $pass = new String::Random;
die "You need to provide a filename (must exist already), a prefix for your users and optionally the number of users to be added" unless $ARGV[1];
my $file = $ARGV[0];
my $inp = $ARGV[1];
my $count = $ARGV[2] || 10;
my $ht = new Apache::Htpasswd("$file");
my $usrlist;
for my $i (0..$count) {
my $randuser = $inp . int(rand(3456) + 1000);
$usrlist->{$randuser} = random_regex('\w\w\w\W\d\d\w\w..');
$usrlist->{$randuser} =~ s/0/O/;
$usrlist->{$randuser} =~ s/1/l/;
$usrlist->{$randuser} = md5_base64($usrlist->{$randuser});
}
foreach (keys %{$usrlist}) {
$ht->htpasswd($_, $usrlist->{$_});
}