· 7 years ago · Jan 22, 2019, 01:14 PM
1#!/usr/bin/perl
2#
3# XOR FILE Encryption/Decryption
4#
5# Copyright 2018 (c) Todor Donev <todor.donev at gmail.com>
6# https://ethical-hacker.org/
7# https://facebook.com/ethicalhackerorg
8#
9# Disclaimer:
10# This or previous programs is for Educational
11# purpose ONLY. Do not use it without permission.
12# The usual disclaimer applies, especially the
13# fact that Todor Donev is not liable for any
14# damages caused by direct or indirect use of the
15# information or functionality provided by these
16# programs. The author or any Internet provider
17# bears NO responsibility for content or misuse
18# of these programs or any derivatives thereof.
19# By using these programs you accept the fact
20# that any damage (dataloss, system crash,
21# system compromise, etc.) caused by the use
22# of these programs is not Todor Donev's
23# responsibility.
24#
25# Use them at your own risk!
26#
27
28use warnings;
29use strict;
30
31print "[ XOR FILE Encryption/Decryption\n";
32print "[ ======\n";
33print "[ Author: Todor Donev <todor.donev at gmail.com>\n";
34print "[ https://ethical-hacker.org/\n";
35print "[ https://fb.com/ethicalhackerorg\n";
36print "[ ======\n";
37die "[ Usage: $0 <hex key> <input file> <output file>\n" if(@ARGV != 3);
38my $key = chr(hex($ARGV[0]));
39print "[ Opening $ARGV[1]\n";
40open(IN, "<$ARGV[1]") or die "[ Error: Can't read $ARGV[1]: $!\n";
41print "[ Error: $ARGV[1] is empty file\n" and exit if (-z $ARGV[1]);
42open(OUT, ">$ARGV[2]") or die "[ Error: Can't wrote $ARGV[2]: $!\n";
43binmode(IN); binmode(OUT);
44print "[ Calculation..\n";
45while( sysread(IN,my $in,length($key))) {
46 print OUT $in^substr($key,0,length($in));
47}
48print "[ Ready and $ARGV[2] file is closed.\n";
49close(IN);
50close(OUT);