CGI Bandwidth Bandit

Bandwidth Bandit

#!/usr/bin/perl

$domain = "mikesworld.net";
$busted = "http://www.example.com/testimage.gif";
$directory = "images";

unless ($ENV{'HTTP_REFERER'} =~ $domain) {
	print "Location: $busted\n\n";
	exit;
}

($name,$ext)=split('&',$ENV{'QUERY_STRING'});

print "Content-type: image/" . (($ext eq 'jpg') ? 'jpeg' : $ext) . "\n\n";
open (image,"$directory/"."$name".".$ext") or die; 
while (read image, $buf, 1024) { 
print $buf;					 
}
close image;