There are some errors in my Perl script, I looked though the source code but couldn't find the problem.
#Tool: decoding shell codes/making shell codes
use strict;
use Getopt::Std;
my %opts=();
getopts("f:xa", \%opts);
my($infile, $hex);
my($gen_hex, $gen_ascii);
sub usage() {
print "$0 -f <file> [-x | -a] \n\t";
print '-p <path to input file>'."\n\t";
print '-x convert "\nxXX" hex to readable ascii'."\n\t";
print '-a convert ascii to "\xXX" hex'."\n\t";
print "\n";
exit;
}
$infile = $opts{f};
$gen_hex = $opts{a};
$gen_ascii = $opts{x};use
if((!opts{f} || (!$gen_hex && !$gen_ascii)) {
usage();
exit;
}
if($infile) {
open(INFILE,$infile) || die "Error Opening '$infile': $!\n";
while(<INFILE>) {
#Strips newlines
s/\n/g;
#Strips tabs
s/\t//g;
#Strips quotes
s/"//g;
$hex .= $_;
}
}
if($gen_ascii) {
# \xXX hex style to ASCII
$hex =~ s/\\x([a-fA-F0-9]{2,2})/chr(hex($1)/eg;
}
elsif ($gen_hex) {
$hex =~ s/([\W|\w)/"\\x" . uc(sprintf("%2.2x",ord($1)))/eg;
}
print "\n$hex\n";
if($infile) {
close(INFILE);
}
gives me the errors
Backslash found where operator expected at 2.txt line 36, near "s/\"
(Might be runaway multi-line // string starting on line 34)
syntax error at 2.txt line 25, near ") {"
syntax error at 2.txt line 28, near "}"
syntax error at 2.txt line 36, near "s/\"
syntax error at 2.txt line 41. nar "}"
Execution of 2.txt aborted due to compilation errors
Do you see the problems?