openvpn-install/revoke-cleaner.pl

55 lines
1.3 KiB
Perl
Raw Normal View History

2023-01-17 11:53:20 +01:00
#!/usr/bin/perl
# Author @nu11secur1ty
use strict;
use warnings;
use diagnostics;
use Term::ANSIColor;
print color('GREEN');
print "You should remove all lines which you see on this print with the path";
print color('RESET');
print color('BLUE');
print " (/etc/openvpn/easy-rsa/pki/index.txt)\n";
print color('RESET');
print color('GREEN');
print "because these users are already";
print color('RESET');
print color('RED');
2023-01-17 13:26:22 +01:00
print " revoked!\n";
2023-01-17 11:53:20 +01:00
print color('RESET');
2023-01-17 13:24:48 +01:00
print color('GREEN');
2023-01-17 13:25:45 +01:00
print "If you do not see lines with (R) in the beginning, you will have nothing to clean!\n\n\n";
2023-01-17 13:24:48 +01:00
print color('RESET');
2023-01-17 11:53:20 +01:00
my $ENV = `cat /etc/openvpn/easy-rsa/pki/index.txt | grep R`;
2023-01-17 14:47:17 +01:00
print "$ENV";
2023-01-17 11:53:20 +01:00
2023-01-17 13:20:47 +01:00
print color('Yellow');
print "This is your issued crt's\n";
print color('RESET');
2023-01-17 13:22:01 +01:00
my $issued = `ls -all /etc/openvpn/easy-rsa/pki/issued/`;
2023-01-17 14:47:17 +01:00
print "$issued";
2023-01-17 13:20:47 +01:00
2023-01-17 11:53:20 +01:00
## Cleaning
my $ENVPKI = "/etc/openvpn/easy-rsa/pki/index.txt";
2023-01-17 14:47:17 +01:00
print "Preparing for cleaning...\n";
2023-01-17 13:29:33 +01:00
print color('RED');
2023-01-17 13:28:38 +01:00
print "Please, choose the username, or if you are not really sure, just press Enter to exit the cleaner...\n";
2023-01-17 13:29:33 +01:00
print color('RESET');
2023-01-17 11:53:20 +01:00
chomp (my $username = <STDIN>);
2023-01-17 14:47:17 +01:00
my $cleaner = `sed -i '/$username/d' $ENVPKI`;
2023-01-17 11:53:20 +01:00
2023-01-17 14:48:32 +01:00
print color('YELLOW');
2023-01-17 14:47:17 +01:00
print"You clint configurations are...\n";
2023-01-17 14:48:32 +01:00
print color('RESET');
2023-01-17 14:47:17 +01:00
my $configs = `ls -all /etc/openvpn/client/`;
print"$configs";
2023-01-17 11:53:20 +01:00
exit 0;