usr bin perl Nodeny Авторизатор use IO Socket use Sys Hostname use Cry

 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
#!/usr/bin/perl
# =========================================================================
# Nodeny. Авторизатор
# =========================================================================
use IO::Socket;
use Sys::Hostname;
use Crypt::Rijndael;
# -------------------------------------------------------------------------
$yourpass = 'блаблабла'; # ваш пароль
$server = '192.168.42.1'; # сервер авторизации
$portno = 7723; # порт
# -------------------------------------------------------------------------
$ver = 14; # protocol version
$v = 0; # 1 - verbose
# =========================================================================
sub SEND
{
$sock1->send($_[0]);
}
sub GET
{
my ($i,$n,$str,$tmout,$rin,$txt,$ip,$addr) = (0,10,'',5,'','','','');
vec($rin,fileno($sock2),1) = 1;
while (select($txt = $rin, undef, undef, $tmout) && ++$i<$n)
{
$tmout = 0;
$addr = recv($sock2, $txt, 100, 0);
($ip, $addr) = sockaddr_in($addr);
$ip = join(".",unpack ("C4", $addr));
next if $ip ne $server;
$str=$txt;
}
unless ($str)
{
$noanswer++;
if ($noanswer>10) {$noanswer=0; sleep 20;}
print "no answer...\n" if $v;
}
return($str);
}
# ==============================================================================
$passwd_in = substr((substr $yourpass, 0, 3)."Z" x 16, 0, 16);
$passwd_out = substr((substr $yourpass, 3, 16)."0" x 16, 0, 16);
$sock1 = IO::Socket::INET->new(Proto => 'udp', PeerPort => $portno, PeerAddr => $server);
unless ($sock1) {print "Cannot create socket...exit\n"; exit;}
$proto = getprotobyname('udp');
unless (socket($sock2, PF_INET, SOCK_DGRAM, $proto) &&
bind($sock2, sockaddr_in($portno, INADDR_ANY)) )
{print "Cannot bind socket...exit\n"; exit;}
$id = substr(rand,2,6);
$noanswer = 0;
while(1)
{
$id = 999999 unless $id--;
&SEND("$ver$id");
print "BEGIN SESSION\n" if $v;
$p = &GET;
next unless $p;
if ($p !~ /^id(.{16})$ver$id$/s)
{
&GET;
&GET;
sleep 1;
next;
}
$cipher = new Crypt::Rijndael $passwd_in,Crypt::Rijndael::MODE_CBC;
$key = $cipher->decrypt($1);
$cipher = new Crypt::Rijndael $passwd_out,Crypt::Rijndael::MODE_CBC;
$skey = $cipher->encrypt($key);
&SEND($skey."a$ver$id");
$p = &GET;
next unless $p;
$stat = substr $p,0,2;
$stat = $stat eq 'ok' || $stat eq 'sv' ? "OK" : "NO";
print "AUTH $stat\n" if $v;
sleep 40;
}