-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipallow.cgi
More file actions
68 lines (51 loc) · 1.55 KB
/
ipallow.cgi
File metadata and controls
68 lines (51 loc) · 1.55 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
#!/usr/bin/perl
use CGI qw( param header );
my $first_pass=param('gopon');
print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>This is your PERL IP allow Program</title>";
print "</head>";
print "<body>";
use CGI;
use warnings;
use strict;
use Crypt::CBC;
my $KEY = 'secrect_foo';
my $readfile ="pass.txt";
open my $passfile, '<', $readfile or die "could not open file";
my $readpass = do{ local $/; <$passfile> };
# print "Reading pass from file: $readpass\n";
close ($readfile);
my $dec = decryptString($readpass);
if($dec eq $first_pass)
{
print "<h2>Password Matched<h2>\n";
my $q = new CGI;
# print $q->remote_host();
my $ip = $q->remote_host();
# print "\n $ip \n";
system("sudo /sbin/iptables -F");
system("sudo /sbin/iptables -A INPUT -s $ip -j ACCEPT");
# system("sudo /sbin/iptables -A INPUT -j DROP"); // uncomment this line if you want all IP block to access
# the server acept your current public ip. Use it at your own risk.
print "\n Your IP : $ip is allow in this system.\n";
}
else{
print "Stored Pass mismatch\n";
}
print "Change Password: ";
print '<a href="changepass.cgi">Click Here</a>';
print "</body>";
print "</html>";
sub decryptString {
my $string = shift;
my $cipher = Crypt::CBC->new(
-key => $KEY,
-cipher => 'Blowfish',
-padding => 'space',
-add_header => 1
);
my $dec = $cipher->decrypt($string);
return $dec;
}