1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anti Image Protection Script

Discussion in 'PHP & Perl' started by banabot, May 12, 2010.

  1. banabot

    banabot Newbie

    Joined:
    Jan 2, 2010
    Messages:
    5
    Likes Received:
    0
    Hi,
    with this script you can include images form refere protected sites (http://www.yourhtmlsource.com/sitemanagement/bandwidththeft.html).

    PHP:
    <?php
    $url 
    $_GET['img'];
    $urex "^(https?|ftp)\:\/\/([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
    if (!
    eregi($urex$url)) {print 'invalid image'; exit;}
    $userAgent 'Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)';
    $ref explode('/'$url);
    $ref 'http://'.$ref[2].'/';
    $ch curl_init();  
    curl_setopt($ch,CURLOPT_REFERER$ref);
    curl_setopt($chCURLOPT_URL$url);  
    curl_setopt ($chCURLOPT_RETURNTRANSFER1);  
    curl_setopt($chCURLOPT_USERAGENT$userAgent);
    $image curl_exec ($ch);  
    curl_close ($ch);
    header('Content-Type: image');
    print 
    $image;
    ?>
    PHP:
    without script: <img src="http://www.test.com/image.jpg">
    with script: <img src="image-stealer.php?img=http://www.test.com/image.jpg">

    Have fun.
     
  2. youngguy

    youngguy Senior Member

    Joined:
    Apr 11, 2009
    Messages:
    1,053
    Likes Received:
    1,560
    Location:
    Hell
    And waste both bandwidth and resouces too lool. Why don't you download the image to local folder instead?
     
  3. banabot

    banabot Newbie

    Joined:
    Jan 2, 2010
    Messages:
    5
    Likes Received:
    0
    Sorry that I answer so late. Last year I coded an (adult) image grabber. For that this was the better way because the images are only needed for one visitor.
     
  4. youngguy

    youngguy Senior Member

    Joined:
    Apr 11, 2009
    Messages:
    1,053
    Likes Received:
    1,560
    Location:
    Hell
    Yeah, it's good just in case you use it only in your tool. Imagine you have 1000 visitors at the same time, this script will kill your server.
     
  5. xpressioniz

    xpressioniz Junior Member

    Joined:
    Jun 4, 2008
    Messages:
    121
    Likes Received:
    15
    Agreed with youngguy, this script will kill your server. It's better using .htaccess to protect hotlinking images.