-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword.pl
More file actions
103 lines (77 loc) · 2.64 KB
/
password.pl
File metadata and controls
103 lines (77 loc) · 2.64 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/perl -w
#
# mass mule password changer (c) supahacka@gmail.com
# v0.2
#
# example: perl password.pl mules.txt output.txt
# warning: don't re-run the script after the passwords have been changed ... or you risk to end up with all of your mules locked because of too many invalid password attempts (the script will of course use the old password from the mules.txt file again)
use strict;
use warnings;
use threads;
use Thread::Queue;
my $q = Thread::Queue->new(); # A new empty queue
die 'Please specify the input file as a command line argument.' if !defined $ARGV[0];
die 'Please specify the output file as a command line argument.' if !defined $ARGV[1];
my $infile = $ARGV[0];
my $outfile = $ARGV[1];
my $newPassword="";
my $output="";
open (MYFILE, ">$outfile") or die 'Can not open input file "output.txt": ' . $! . "\n";
open(INPUT,$infile) or die 'Can not open input file "mules.txt": ' . $! . "\n";
while(<INPUT>){
chomp();
my($guid,$password)=split(/\s+/,$_);
$newPassword = "";
my @letters = ('a'..'z');
for my $i (0..9) {
$newPassword .= $letters[int rand @letters];
}
$output = '"' . $guid . '": "' . $newPassword . '",'. "\n";
print MYFILE $output;
$q->enqueue([$guid, $password, $newPassword]);
}
print $q->pending() . ' mules queued for processing.' . "\n";
sleep 2;
sub start_thread {
while(my $mule=$q->dequeue_nb()){
# Format:
# POST https://realmofthemadgod.appspot.com/account/changePassword
# URLEncoded form
# guid: foo@foo.org
# ignore: 79341
# newPassword: futloch2
# password: futloch
my $content = [
'guid' => $mule->[0],
'ignore' => int(rand(1000)+1000),
'newPassword' => $mule->[2],
'password' => $mule->[1],
];
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
my $ua = LWP::UserAgent->new;
my $retry=1;
my $timesTried=0;
my $result=undef;
while($retry==1){
my $req = POST 'http://realmofthemadgod.appspot.com/account/changePassword', $content;
my $res = $ua->request($req);
$result=$res->decoded_content;
$timesTried++;
$retry=0 if ($result eq '<Success/>' || $timesTried>=2);
print 'Change password for mule ' . $mule->[0] . '/' . $mule->[1] . ' to ' . $mule->[2] . ' - result: ' . $result . ($timesTried>1 ? ' (retry #' . $timesTried .' )' : '') . "\n";
}
}
}
for(0..2){
my $thr = threads->create('start_thread');
}
while(threads->list(threads::running)){
print scalar(localtime(time())) . ' # of threads running: ' . scalar(threads->list(threads::running)) . "\n";
print $q->pending() . ' mules queued for processing.' . "\n";
sleep 5;
}
foreach (threads->list(threads::joinable)){
$_->join();
}
close (MYFILE);