use strict; use Compress::Zlib; my $template = '@o=("'; my $file; open $file, "< templates/rikka1final.txt" or die $!; my $text = join '', <$file>; close $file; $template .= $text . '","'; open $file, "< templates/rikka2final.txt" or die $!; $text = join '', <$file>; close $file; $template .= $text . '");'; my $code = q% $t = $o[$O]; $s = 0; $s++ foreach ($t =~ /X/g); while( length($q) < $s - 129 ) { $i = $i < 0 ? int(rand(length($q))) : $i + 1; $q = substr($q, 0, $i) . chr(34 + int(rand(24))) . substr($q, $i); } $q = '$O=' . ($O ^ 1) . ';useCompress::Zlib;$q=q!' . $q . '!;$q=~s/["-9\s]//gs;$l=uncompress(unpack"u",join"",(map{chr($_==124?67:$_-25)}unpack"C*",$q));eval$l;'; @i = unpack 'C*', $q; foreach $x (unpack 'C*', $t) { $x = chr($x); print ("X" eq $x ? chr(shift @i) : $x); } %; $code =~ s/\s//gs; my $encoded = pack 'u', compress($template . $code); $encoded =~ s/\s//gs; $encoded = join '', map {chr($_ == 67 ? 124 : $_ + 25)} unpack 'C*', $encoded; $encoded =~ s/\\/#/g; open $file, "< templates/rikka0final.txt" or die; $template = join '', <$file>; close $file; my $header = 'useCompress::Zlib;$O=0;$q=q!'; my $footer = '!;' . '$q=~s/["-9\s]//gs;' . '$l=uncompress(' . '(q{}x0).' . 'unpack"u",' . 'join' . '#c2012' . '"",(map{chr($_==124?67:$_-25)}unpack"C*",$q));' . 'eval$l;'; my $encode_size = 0; foreach (unpack 'C*', $template) { if( chr($_) eq 'X' ) { $encode_size++; } } while( length($encoded) < $encode_size - length($header) - length($footer) ) { my $p = int(rand(length($encoded))); $encoded = substr($encoded, 0, $p) . chr(34 + int(rand(24))) . substr($encoded, $p); } my @i = unpack 'C*', $header . $encoded . $footer; foreach my $j (unpack 'C*', $template) { $j = chr($j); if( $j eq 'X' ) { print chr(shift(@i)); } else { print $j; } }