#!/usr/bin/perl # Enfunker by Tyler Bletsch use IO::Socket::INET; # a much dumber web-getter sub manualget { my ($host,$port,$doc) = @_; $sock=new IO::Socket::INET(PeerAddr => $host,PeerPort => $port,Proto => 'tcp'); return unless ($sock); print $sock "GET $doc HTTP/1.0\n\n"; while (<$sock>) { last if (/^[\s]*$/); } # pass header my $content = join('',<$sock>); close $sock; return $content; } sub clean { my ($txt) = @_; $txt =~ s/\+/ /g; $txt =~ s/%([0-9a-f]{2})/chr hex $1/ige; return $txt; } $qs=$ENV{'QUERY_STRING'}; for $kvp (split("&",$qs)) { ($k,$v) = split("=",$kvp); $query{$k}=clean $v; } print "Content-type: text/html\n\n"; $funkRoot = "http://ds.nfshost.com/funk/"; $funkImg = $funkRoot."funk1.png"; $funkLink = $funkRoot; $goBack = qq(Return to Enfunker.); $funk = qq(
); $url = $query{u}; unless ($url =~ m(http://([^/:]*)(:(\d+))?(/?.*))) { $url = "http://$url"; } unless ($url =~ m(http://([^/:]*)(:(\d+))?(/?.*))) { print "Invalid URL. $goBack\n"; exit; } ($host,$port,$doc) = ($1,$3 || 80,$4); use LWP::Simple; unless (defined ($content = get $url)) { #resort to dumb getter unless (defined ($content = manualget($host,$port,$doc))) { print "Couldn't access content at '$url'. $goBack\n"; exit; } } open FP,">> log.txt"; print FP "$url\n"; close FP; for ($content) { s/(]*>)/\1