-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoder.pl
43 lines (38 loc) · 848 Bytes
/
coder.pl
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
39
40
41
42
43
#!/usr/bin/env perl
use strict;
use warnings;
sub getfile {
my $filename = $_[0];
my $file;
my $res = "";
if (!open($file, "<:encoding(UTF-8)", $filename)) {
print "Could not open file '$filename' $!";
return "";
}
while (my $s = <$file>) {
$res .= $s;
}
close($file);
return $res;
}
sub main {
my $n = scalar(@_);
if ($n != 1 && $n != 2) {
print "Usage:\tcoder [file] [-e string]\n";
print "\t'eval pack('H*', \$code);' in your programs\n\n";
return -1;
};
my $code = "";
if ($n == 1) {
$code = getfile(shift);
} elsif (shift eq "-e") {
$code = shift;
} else {
print "Invalid key.\n";
}
my $obf = unpack("H*", $code);
# eval pack('H*', $var);
print $obf;
return 0;
}
exit(main(@ARGV));