PDA

View Full Version : ISP Block and Search (HELP!)


Artemis
08-19-2001, 04:12 PM
Not sure if this is possible, but a non-reputable place is stealing artwork off of our websites and I was wondering if there was a way to block an incoming ISP?

Second, is there a way to trace and ISP? Or find one from a domain name?

Thanks we are tired of our working being sold as "bogus stamps from Russia".

<ticked>

Not sure if it belonged here in this section I just didn't know where else to ask. :-(

cjhamm
08-20-2001, 05:50 PM
Do you want others to be unable to refer to your pictures. (It's just because you can't avoid pictures from being downloaded !!!)

If so, you could copy the following script and save it as pics (without .cgi !)

--------

#!/usr/bin/perl

# set vars
#
$dbg = 0; # debug output
@all = ('artemis.net', 'artemis.com'); # allowed referers... fill in the appropriate ones
$src = '/home/artemis/public_html'; # httpd root
$thb = $src.'/thumbs'; # cgi-tempout
$cvt = '/usr/local/bin/convert'; # convert binary

#
# check: referer ok ?
#
#
if (!defined $ENV{'HTTP_REFERER'}) { $err="No Referer / Direct Access forbidden"; &amp;errorhtml; }
$ref = $ENV{'HTTP_REFERER'};
foreach $ral (@all) { if ($ref =~ /^https?:\/\/[a-zA-Z0-9_\-\.]*$ral\/[a-zA-Z0-9\.\/]*$/) {$rok = 'ok';last;} }
if ($rok ne 'ok') { $err="Unauthorized Referer ($ref); ask the webmaster to get access!"; &amp;errorhtml;}


#
# check: pic requested ?
#
#
if (!defined $ENV{'PATH_INFO'}) { $err='No Picture requested (Server Error???)'; &amp;errorhtml; }
$tpic = $ENV{'PATH_INFO'};


#
# check: pic string ok ?
#
#
if ($tpic =~ /^(\/[a-zA-Z0-9_\-\.\/]*\.[efgijp]{3,4})$/) {$pic=$1} else { $err="Bad Filename ($tpic)"; &amp;errorhtml; }
$fil = $src.$pic;


#
# check: thumbnail request ?
#
#
$tqry = $ENV{'QUERY_STRING'} if (defined $ENV{'QUERY_STRING'});
if ((defined $tqry) && ($tqry !~ /^t?$/ )) { $err="Bad Query-Tag ($tqry)"; &amp;errorhtml; }
if ($tqry eq 't') { $pnn = $pic; $pnn =~ s/\//_/g; $new = $thb.'/'.$pnn;
if (open(TST, $new)) { close TST; } else { system($cvt, '-geometry', '150x150+0+0', $fil, $new); }
$fil = $new; }


#
# check: file exists ?
#
#
if (!open(BIN, $fil)) { $err="File not found: $pic"; &amp;errorhtml; }


#
# extract type / set date for server
#
#
if ($pic =~ /\.jpe?g$/ ) { $tp = 'image/jpeg'; } else { $tp = 'image/gif'; }
@tim = localtime;
$tim = ['Sun', 'Mon','Tue','Wed','Thu','Fri','Sat','Sun']->[$tim[6]].', '.sprintf("%02d", $tim[3]).' ';
$tim .= ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']->[$tim[4]].' ';
$tim .= sprintf("%04d", (1900 + $tim[5])).' '.sprintf("%02d:%02d:%02d GMT", $tim[2], $tim[1], $tim[0]);


#
# input / output
#
#
print "Date: $tim\nExpires: Tue, 01 Jan 2002 00:00:00 GMT\n";
print "Last-Modified: Sun, 05 Aug 2001 00:00:00 GMT\n";
print "Content-Type: $tp\n"; binmode BIN; @bin = &lt;BIN&gt;; close BIN; $bin = join('',@bin); $lbin = length($bin);
print "Content-Length: $lbin\n\n";
binmode STDOUT; print @bin; exit;



#
# subs
#
# SUB ERRORHTML
sub errorhtml() {
print &lt;&lt;"END_ERROR_HTML";
Content-Type: text/html

&lt;HTML&gt;
&lt;HEAD&gt;&lt;TITLE&gt;Access forbidden&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY BGCOLOR="#FFFFFF"&gt;&lt;FONT SIZE="+1" COLOR="#FF0000"&gt;&lt;B&gt;
An error occured when you tried to access a picture at Artemis.net.&lt;BR&gt;&lt;/B&gt;
Error: $err&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT SIZE="+0" COLOR="#000000"&gt;
END_ERROR_HTML
;

if ($dbg) { foreach $key (sort(keys(%ENV))) { print " &lt;B&gt;$key:&lt;/B&gt; $ENV{$key}&lt;BR&gt;\n"; } }
print " &lt;/FONT&gt;&lt;/BODY&gt;\n&lt;/HTML&gt;\n";
exit;
}

--------

put it into your scgi-bin dir and chmod it 700. If you wish to use thumbnails, make sure to mkdir the 'thumbs' directory in the public_html folder. You can chmod it 700 as well. If you now want to use a picture, use the following tags:

&lt;img src="/scgi-bin/pics/picturepath/picturename.jpg"&gt;

-- or

&lt;img src="/scgi-bin/pics/picturepath/picturename.jpg?t"&gt;


The trailing '?t' makes a thumbnail with a width of 150 pixels (can be changed in the script!). The best thing is, all thumbnails will only be created once in your directory (by magic) and if they are created, they can directly be used (which reduces the CPU usage ;-)


Hope this does it, CJ Hammond
PS: Since I did the script for myself, just today, you can ask me, if something's missing...
PPS: Hopefully, I did everything right with the &lt;, &gt;, and &amp; stuff !

cjhamm
08-20-2001, 07:05 PM
To make pictures yet "unsavable as...",

change the following lines:

------

# bug removed from referer ;-)
foreach $ral (@all) { if ($ref =~ /^https?:\/\/[a-zA-Z0-9_\-\.]*$ral\/[a-zA-Z0-9_\-\.\/]*$/) {$rok = 'ok';last;} }
#

# suppresses caching ;-) and with "Image save as..." only the error message will be saved *lol*
print "Pragma: no-cache\nCache-Control: no-cache\nDate: $tim\nExpires: $tim\n";
#

Be aware that you only can use standard image tags, but no
&lt;body background="..."&gt; tags, since they do _not_ pass the referer to the server !!!

Regards, CJ Hammond.

cjhamm
08-20-2001, 07:08 PM
BTW., this all only makes sense, if you chmod all picture files you wish to protect with "chmod 700", so that they can't be accessed via standard http!!

Artemis
08-21-2001, 04:50 AM
Its just ONE person (ISP) that is stealing ALLOT of folks stuff and selling them. I just want to block that one person, or at the very least try and get thier ISP and report them. I am sure they are breaking their TOS with their providers.

HELP!

BbBoy
08-21-2001, 05:24 AM
OK, in the directory you want to deny him from, edit the file .htaccess (Use the file manager, you won't see it via FTP).

Add this to the end:

order allow,deny
allow from all
deny from <b>.bellsouth.net</b>

Change the .bellsouth.net to whatever ISP they use (with a . before it) or their IP address/range. :)

MagaBoy
02-09-2003, 11:50 AM
Hey cjhamm,

What would the picturepath look like? "/scgi-bin/pics/../../thumbs/picturename.jpg" or something.

Thanks.

JimDog
02-23-2003, 12:46 PM
you could just block the whole isp's ip block. I think its possible with cpanel 6.0