#!/usr/bin/perl
#
# XOR FILE Encryption/Decryption
#
# Copyright 2018 (c) Todor Donev <todor.donev at gmail.com>
# https://ethical-hacker.org/
# https://faceboo #!/usr/bin/perl
#
# XOR FILE Encryption/Decryption
#
# Copyright 2018 (c) Todor Donev <todor.donev at gmail.com>
# https://ethical-hacker.org/
# https://facebook.com/ethicalhackerorg
#
# Disclaimer:
# This or previous programs is for Educational
# purpose ONLY. Do not use it without permission.
# The usual disclaimer applies, especially the
# fact that Todor Donev is not liable for any
# damages caused by direct or indirect use of the
# information or functionality provided by these
# programs. The author or any Internet provider
# bears NO responsibility for content or misuse
# of these programs or any derivatives thereof.
# By using these programs you accept the fact
# that any damage (dataloss, system crash,
# system compromise, etc.) caused by the use
# of these programs is not Todor Donev's
# responsibility.
#
# Use them at your own risk!
#

use warnings;
use strict;

print "[ XOR FILE Encryption/Decryption ";
print "[ ====== ";
print "[ Author: Todor Donev <todor.donev at gmail.com> ";
print "[ https://ethical-hacker.org/ ";
print "[ https://fb.com/ethicalhackerorg ";
print "[ ====== ";
die "[ Usage: $0 <hex key> <input file> <output file> " if(@ARGV != 3);
my $key = chr(hex($ARGV[0]));
print "[ Opening $ARGV[1] ";
open(IN, "<$ARGV[1]") or die "[ Error: Can't read $ARGV[1]: $! ";
print "[ Error: $ARGV[1] is empty file " and exit if (-z $ARGV[1]);
open(OUT, ">$ARGV[2]") or die "[ Error: Can't wrote $ARGV[2]: $! ";
binmode(IN); binmode(OUT);
print "[ Calculation.. ";
while( sysread(IN,my $in,length($key))) {
print OUT $in^substr($key,0,length($in));
}
print "[ Ready and $ARGV[2] file is closed. ";
close(IN);
close(OUT);