-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.pl
More file actions
executable file
·38 lines (29 loc) · 888 Bytes
/
Copy pathdecrypt.pl
File metadata and controls
executable file
·38 lines (29 loc) · 888 Bytes
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
# made by recanman
use strict;
use warnings;
use Getopt::Long;
sub xor_decrypt {
my ($input_file, $key) = @_;
open my $fh, '<:raw', $input_file or die "Cannot open file: $input_file\n";
my $encrypted_data = do { local $/; <$fh> };
close $fh;
my $key_len = length($key);
my $decrypted_data = '';
for (my $i = 0; $i < length($encrypted_data); $i++) {
my $byte = ord(substr($encrypted_data, $i, 1));
my $decrypted_byte = $byte ^ ord(substr($key, $i % $key_len, 1));
$decrypted_data .= chr($decrypted_byte);
}
return $decrypted_data;
}
sub main {
my $input_file;
GetOptions('file=s' => \$input_file) or die "Usage: $0 --file <encrypted_file>\n";
if (!$input_file) {
die "Usage: $0 --file <encrypted_file>\n";
}
my $key = pack('H*', '62122b0f3a1a5dd0f5ac261fdf24b99a');
my $decrypted_data = xor_decrypt($input_file, $key);
print $decrypted_data;
}
main();