#!/usr/local/bin/perl use strict; my %input; my $key; my $enc; my $decoded_html; getqs(); # get the key ($key = $input{'raw'}) =~ s|.*var alf\s*=\s*"(.*)";.*|$1|s; $key = special($key); ($enc = $input{'raw'}) =~ s|.*d\("(.*)"\);.*|$1|s; $enc = special($enc); $decoded_html = decode($key, $enc); print STDOUT "Content-type: text/html\r\n\r\n"; open(TMPL, "decode_haywyre.tmpl") or die "error opening template."; while() { s||$decoded_html|; print; } exit(0); #------------------------------------------------------------------------ # subroutines #------------------------------------------------------------------------ sub decode { my($k, $e) = @_; my($position); my($midpoint) = length($k) / 2; my($decoded) = ""; my($difference, $c); my $x; for($x = 0; $x < length($e); $x++) { my($i,$char); $c = substr($e, $x, 1); $position = index($k, $c); if($position > $midpoint) { $difference = $position - $midpoint; $i = int(48 - $difference); $char = substr($k, $i, 1); $decoded .= $char; } else { $difference = $midpoint - $position; $i = int(48 + $difference); $char = substr($k, $i, 1); $decoded .= $char; } } return $decoded; } sub special { my($s)=@_; $s =~ s/\\"/"/g; $s =~ s/\\ / /g; $s =~ s/\\\|/|/g; $s =~ s/\\'/'/g; $s =~ s|\\/|/|g; $s =~ s/\\t/\t/g; $s =~ s/\\`/`/g; $s =~ s/\\n/\n/g; $s =~ s/\\\[/[/g; $s =~ s/\\\]/]/g; $s =~ s/\\\\/\\/g; $s; } sub getqs { my @input; my $input; my($c, $index, $key, $value); if($ENV{REQUEST_METHOD} eq "GET") { $input = $ENV{QUERY_STRING}; } elsif($ENV{REQUEST_METHOD} eq "POST") { for ($c = 0; $c < $ENV{CONTENT_LENGTH}; $c++) { $input .= getc; } } @input = split(/&/, $input); foreach $c (0 .. $#input) { $input[$c] =~ s/\+/ /g; $input[$c] =~ s/%(..)/pack("c", hex($1))/ge; $index = index ($input[$c], "="); $key = substr($input[$c], 0, $index); $value = substr($input[$c], ($index + 1)); $input{$key} .= '\0' if (defined ($input{$key})); $input{$key} .= $value; } }