PDA

View Full Version : PHP Source Code - CPAlead Survey Bypasser



Apolva
12-12-2010, 04:20 PM
PHP script to bypass most CPAlead survey.

Works like a proxy for the page only (ie. not images) - strips CPAlead code from pages and then dishes them up.

Features:
- To avoid usage as a proxy:
- Sends user's IP with page request in HTTP header and URL.
- Checks url and page content against a keyword blacklist.
- Won't display a page which didn't originally have a survey on it.

- Other Features:
- Rewrites other, same-domain links on page so that they will be bypassed too.
- Rewrites relative URLs to absolute URLs (to prevent broken images, stylesheets, etc.)
- Form completes URLs missing a 'http://' or 'https://' prefix on submission.
- Terms of Service page.

PHP Source:



<?php
// Configure:
$site_domain="example.com"; // Domain that this file is hosted on.
$external_location="http://example.com/tools/bypass.php"; // External URL of this PHP file.

function showp($pageTitle="",$pageContent=""){die("<head><title>{$pageTitle}</title></head><div style='font-size:36px;text-align:center;'>{$pageTitle}</div>{$pageContent}");}

ini_set('user_agent','Survey Bypasser ({$external_location}) (page requested by '.$_SERVER['REMOTE_ADDR'].', Mozilla-Compatible)');


function checkBlacklist($string=""){
$blacklist=array("mp3","torrent","xxx"); // etc.
foreach($blacklist as $keyword){
if(stripos($string,$keyword)!==FALSE) showp("Page not shown","The page contains one or more blacklisted keywords.");
}
}

$u=trim($_GET['u']); // URL
$ou=$u;

if($_GET['termsacbypass']=="yap") showp("Terms of Service","Do not use this site to access copyright, offensive, illegal or objectionable material. This includes, but is by no means limited to: hacking sites, pirated/copyright downloads, pornography or illegal discussions.<br /><br />We automatically block requests which are believed to be of this nature and may take appropriate action.<br /><br /><span style='color:red;font-weight:bold;'>You are not anonymous</span> - Your IP address is logged and is sent along with the page request.");
// If no URL is present, show the form.
if($u=="") showp("Survey Bypasser","<script>function fixUrl(){el=document.getElementById('u');url=el.va lue;if( url.substr(0,7)!='http://' && url.substr(0,8)!='https://'){el.value='http://'+el.value;}}</script><div style='text-align:center;margin-top:30px;margin-bottom:10px;'>This is just to bypass those annoying &quot;answer the survey to see the pic/watch the film&quot; sites (bypasses CPAlead).</div><form onsubmit='fixUrl();'><table style='margin:0 auto;'><tr><td><b>URL:</b></td><td><input type='text' value='http://' name='u' id='u' style='width:200px;' /></td></tr><tr><td colspan='2' style='text-align:center;'><a href='?termsacbypass=yap'>By using Survey Bypass, you agree fully with these ToS.</a><br /><br /><table style='margin:0 auto;'><tr><td style='padding-bottom:2px;'></td><td><input type='submit' value='Bypass &amp; Go &raquo;' /></td></tr></table></td></tr></table></form><div style='font-style:italic;text-align:center;'>Created by Apolva.com</div>");

// Blocks local file acess.
if(strlen($u)>500||strpos($u,$site_domain)!==FALSE||$u=="http://"||$u=="https://"||(substr($u,0,7)!="http://" && substr($u,0,8)!="https://")) showp("Not a valid site address.","A site address must start with the <b>http://</b> or <b>https://</b> prefix.");

if(strpos($u,"?")!==FALSE) $u.="&"; else $u.="?";
$u.="page_requested_by=".$_SERVER['REMOTE_ADDR'];

// Get remote page.
checkBlacklist($u);
$file=file_get_contents($u);
if(!$file) showp("Can't access the site.","The link you provided doesn't seem to work.");
checkBlacklist($file);

// To prevent it just being used as a proxy.
if(strpos($file,"cpalead.com")===FALSE){showp("The site doesn't have a survey on it.","To prevent abuse, we only deliver pages which originally had surveys on them.");}

// Add the base URL for the site.
$dirarray=parse_url($u);$dirname=$dirarray['scheme']."://".strtolower($dirarray['host']).dirname($dirarray['path']);
$file="<head><base href='".$dirname."' /></head>".$file;

// Rewrite most URLs.
$file=preg_replace('/(<[^>]*(href|src)\s*=\s*["\'])(?!http|javascript|https|ftp|vnc|ftps)([^"\'>]+)(["\'>])/','$1'.$dirname.'/$3$4',$file);

// Bypass links as well.
function repUrl($a){global $external_location; return $a[1]."{$external_location}?u=".urlencode($a[2]).$a[3].$a[4];}
$file=preg_replace_callback('/(<a[^>]*href\s*=\s*["\'])('.$dirarray['scheme'].':\/\/'.$dirarray['host'].')([^"\'>]+)(["\'>])/','repUrl',$file);
$file=preg_replace_callback('/(<a[^>]*href\s*=\s*["\'])('.$dirarray['scheme'].':\/\/www.'.$dirarray['host'].')([^"\'>]+)(["\'>])/','repUrl',$file);

// Tweak the survey script so that it doesn't work :-)
$file=str_replace("http://www.cpalead.com/mygateway.php?","",$file);
$file=str_replace("initGateway()","e".time()."=false",$file);
$file=str_replace("!isloaded","isloaded",$file);
$file=preg_replace("/<noscript>(.*?)<\/noscript>/","",$file);

// Output page.
echo $file;

?>


Requires PHP 5+ with allow_url_fopen enabled in php.ini.

If you make use of or distribute this, please leave credit to Apolva.com, cheers.

Want to hide these adverts? Register an account for free!