znuff's notepad

Extending Upside-Down-Ternet

a picture of the result of the script

I was sick of people freeloading on my WiFi and I didn’t want to password protect it (for various reasons I’m too lazy to explain).

So I remembered about Upside-Down-Ternet and I extended it a bit with 23 more annoyances:

For the initial set-up I followed the fine How-To at the Ubuntu Community Website. And here is my modified script:

UPDATE: I added YouTube video redirection, too!

#!/usr/bin/perl
$|=1;
$count = 0;
$pid = $$;
while (<>) {
        chomp $_;
        if (/(.*\.jpg)/i) {
                $url = $1;
                system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.jpg", $url);
                system("/usr/bin/mogrify", "-flip", "-modulate", "100,0", "/var/www/images/$pid-$count.jpg");
                print "http://127.0.0.1/images/$pid-$count.jpg\n";
        }
        elsif (/(.*\.gif)/i) {
                $url = $1;
                system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.gif", $url);
                system("/usr/bin/mogrify", "-flip", "-modulate", "100,0", "/var/www/images/$pid-$count.gif");
                print "http://127.0.0.1/images/$pid-$count.gif\n";

        }
        elsif (/(.*\.png)/i) {
                $url = $1;
                system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.png", $url);
                system("/usr/bin/mogrify", "-flip", "-modulate", "100,0", "/var/www/images/$pid-$count.png");
                print "http://127.0.0.1/images/$pid-$count.png\n";

        }
        elsif (/(.*\.swf)/i) {
               print "http://127.0.0.1/meow.swf\n";
        }
        elsif (/^http:\/\/([0-9.]{4}|.*\.youtube\.com|.*\.googlevideo\.com|.*\.video\.google\.com).*?videoplayback.*id=/i) {
               print "http://127.0.0.1/dramatic_cat.mp4\n";
        }
        else {
                print "$_\n";;
        }
        $count++;
}

Here is how it looks on an Android phone:

a picture of the result of the script

Also, one more thing:


I’ve redirected all websites trough rotateme.org:

#!/usr/bin/perl
use URI::Escape;
use IO::Handle;
use POSIX strftime;
$|=1;
$count = 0;
$pid = $$;
open (DEBUG, '>>/tmp/asciiImages_debug.log');
autoflush DEBUG 1;

print DEBUG "########################################################################\n";

while (<>) {
        chomp $_;
        if (/(.*\.jpg)/i) {
                $url = $1;
                system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.jpg", $url);
                system("/usr/bin/mogrify", "-flip", "-modulate", "100,0", "/var/www/images/$pid-$count.jpg");
                print "http://127.0.0.1/images/$pid-$count.jpg\n";
        }
        elsif (/(.*\.gif)/i) {
                $url = $1;
                system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.gif", $url);
                system("/usr/bin/mogrify", "-flip", "-modulate", "100,0", "/var/www/images/$pid-$count.gif");
                print "http://127.0.0.1/images/$pid-$count.gif\n";

        }
        elsif (/(.*\.png)/i) {
                $url = $1;
                system("/usr/bin/wget", "-q", "-O","/var/www/images/$pid-$count.png", $url);
                system("/usr/bin/mogrify", "-flip", "-modulate", "100,0", "/var/www/images/$pid-$count.png");
                print "http://127.0.0.1/images/$pid-$count.png\n";

        }
        elsif (/(.*\.swf)/i) {
               print "http://127.0.0.1/meow.swf\n";
        }
        elsif (/^http:\/\/([0-9.]{4}|.*\.youtube\.com|.*\.googlevideo\.com|.*\.video\.google\.com).*?videoplayback.*id=/i) {
               print "http://127.0.0.1/dramatic_cat.mp4\n";
        }
        elsif (m/.google\.*/) {
               $url = $_;
               $url =~ s/(q=.+?)&/$1+in+pula+mea&/;
               print "$url\n";
        }
        elsif (m/nosquid/) {
              print DEBUG "Input NOSQUID: $url\n";
              print "$_\n";
              print DEBUG "Output NOSQUID: $_\n";
        }
        elsif (m/^http:\/\/.*\/\ /) {
               $url = $_;
               print DEBUG "Input: $url\n";
               my @url = split(" ",$url);
               #print @url[0];
               print "http://rotateme.org/?r=l&u=$url[0]?nosquid\n";
               print DEBUG "Output: http://rotateme.org/?r=l&u=$url[0]?nosquid\n";
        }

        else {
               print "$_\n";
        }
        $count++;
}

The “?nosquid” part is added to stop an infinite loop with rotateme.org. Couldn’t be arsed to figure out a more elegant way, feel free to correct me on that 🙂

Exit mobile version