-
Notifications
You must be signed in to change notification settings - Fork 0
/
runme.pl
65 lines (51 loc) · 1.2 KB
/
runme.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
61
62
63
64
65
#!/usr/bin/perl
# ip inicial
$inicio=1;
# ip final
$fim=253;
$var=$inicio;
$var2=$inicio+1;
# porta udp inicial
$porta='7064';
# classe da vpn
$class_vpn="11.0.1";
# classe que a vpn tera acesso dentro da empresa
$class_access="192.168.0.0";
# ip servidor vpn
$remote_host="200.204.0.10";
while ($var <= $fim ) {
# ARQUIVO DE CONF DO SERVIDOR
open(CONF, ">temporario${porta}.conf");
print CONF "
dev tun
ifconfig $class_vpn.$var $class_vpn.$var2
cd /etc/openvpn
secret temporario${porta}_key
port $porta
user nobody
group nobody
comp-lzo
ping 15
verb 3
";
close(CONF);
system("openvpn --genkey --secret temporario${porta}_key");
# ARQUIVO DE CONF DO CLIENT
open(CONFC, ">cl_temporario${porta}.conf");
print CONFC "dev tun\r\nifconfig $class_vpn.$var2 $class_vpn.$var\r\nremote $remote_host\r\nport $porta\r\nsecret cl_temporario${porta}_key\r\ncomp-lzo\r\nverb 6\r\n";
close(CONFC);
open(KEY, "temporario${porta}_key");
open(CLKEY, ">cl_temporario${porta}_key");
while (<KEY>) {
s/\n/\r\n/g;
print CLKEY "$_";
}
close(KEY);
close(CLKEY);
open(ROTA, ">rota_$porta.bat");
print ROTA "route add $class_access mask 255.255.255.0 $class_vpn.$var metric 3\r\n";
close(ROTA);
$var+=4;
$var2=$var+1;
++$porta;
}