[FREE] Clone Website in Real Time

Status
Not open for further replies.

GoDesain

Regular Member
Joined
Feb 26, 2011
Messages
491
Reaction score
224
Just make this tread because someone ask me about clone website and re-brand it in real time.

First step :
PHP:
<?php
session_save_path(dirname($_SERVER['DOCUMENT_ROOT']) . '/tmp');
session_start();
ob_start();

$base = "http://example.net"; //SET THIS TO THE URL OF THE WEBSITE THAT YOU WANT TO MIRROR

$ckfile       = '/tmp/cookie-' . session_id();
$cookiedomain = str_replace("http://www.", "", $base);
$cookiedomain = str_replace("https://www.", "", $cookiedomain);
$cookiedomain = str_replace("www.", "", $cookiedomain);
$url          = $base . $_SERVER['REQUEST_URI'];
if ($_SERVER['HTTPS'] == 'on') {
    $mydomain = 'https://' . $_SERVER['HTTP_HOST'];
} else {
    $mydomain = 'http://' . $_SERVER['HTTP_HOST'];
}
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_HEADER, 1);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $postinfo = '';
    foreach ($_POST as $key => $value) {
        $postinfo .= $key . '=' . urlencode($value) . '&';
    }
    rtrim($postinfo, '&');
    curl_setopt($curlSession, CURLOPT_POST, 1);
    curl_setopt($curlSession, CURLOPT_POSTFIELDS, $postinfo);
}
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
curl_setopt($curlSession, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($curlSession, CURLOPT_COOKIEFILE, $ckfile);
foreach ($_COOKIE as $k => $v) {
    if (is_array($v)) {
        $v = serialize($v);
    }
    curl_setopt($curlSession, CURLOPT_COOKIE, "$k=$v; domain=.$cookiedomain ; path=/");
}
$response = curl_exec($curlSession);
if (curl_error($curlSession)) {
    print curl_error($curlSession);
} else {
    $response  = str_replace("HTTP/1.1 100 Continue\r\n\r\n", "", $response);
    $ar        = explode("\r\n\r\n", $response, 2);
    $header    = $ar[0];
    $body      = $ar[1];
    $header_ar = split(chr(10), $header);
    foreach ($header_ar as $k => $v) {
        if (!preg_match("/^Transfer-Encoding/", $v)) {
            $v = str_replace($base, $mydomain, $v);
            header(trim($v));
        }
    }
    $body = str_replace($base, $mydomain, $body);
    
    //USE THE REPLACE FUNCTION BELOW TO REPLACE CONTENT/CODE OF THE ORIGIN SITE
    // eg. $body = str_replace('Welcome to SiteA','Welcome to SiteB', $body);
    
    $body = str_replace('REPLACE THIS', 'WITH THIS', $body);
    $body = str_replace('REPLACE THIS', 'WITH THIS', $body);
    $body = str_replace('REPLACE THIS', 'WITH THIS', $body);
    print $body;
}
curl_close($curlSession);
copy php above with name "index.php".

Second step :
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]
copy code above with name ".htaccess"

Third step :
Before upload both code in your hosting, change example dot net with website you want to clone.

Demo :
- torbay.ga ( no re-brand )
- movio.ga ( re-brand )

Please make sure, not all website can be clone easy. especially if they use cloudflare.
this is basic script, make sure to re-code to make better.
 
Seems a bit strange script for me, may be Im new in copying sites, but can you explain why it is rewriting incoming POST data and cookies to request?
And I think it is old script as well - 'split' function doesn't exist in recent php versions.
 
Last edited:
Seems a bit strange script for me, may be Im new in copying sites, but can you explain why it is rewriting incoming POST data and cookies to request?
And I think it is old script as well - 'split' function doesn't exist in recent php versions.
Hi.. i also noob in php.. that's script not mine.. got from my husband laptop..
because that will rewrite all request betwen client and server.. if i'm not wrong..
about split, for new php version you can use explode..
if you have any idea to make it better, let me know..
 
I believe it's mirroring a site. Not copying site's script and data on your hosting. Still you don't have the data. CMIIW
 
I believe it's mirroring a site. Not copying site's script and data on your hosting. Still you don't have the data. CMIIW
i'm not sure what this script name... clone or mirror..
but if you need data, you need scrapper script..
this script only caching data from origin for each user on server and distribute to client view..
 
It is just mirroring the website.
i don't know what this call, sorry if i put wrong title..
HTTrack seems to be the better option?
but if the site origin update their website, you must scrap again and upload to your hosting....
if you have idea combine both and make it bot, will be better..

Advantage using this one :
- each time site origin update their website, you will got it..
- re-write all code on the fly

Disavantage :
- If site origin down, your script will down. ( you must take action in this part )
 
Just make this tread because someone ask me about clone website and re-brand it in real time.

First step :
PHP:
<?php
session_save_path(dirname($_SERVER['DOCUMENT_ROOT']) . '/tmp');
session_start();
ob_start();

$base = "http://example.net"; //SET THIS TO THE URL OF THE WEBSITE THAT YOU WANT TO MIRROR

$ckfile       = '/tmp/cookie-' . session_id();
$cookiedomain = str_replace("http://www.", "", $base);
$cookiedomain = str_replace("https://www.", "", $cookiedomain);
$cookiedomain = str_replace("www.", "", $cookiedomain);
$url          = $base . $_SERVER['REQUEST_URI'];
if ($_SERVER['HTTPS'] == 'on') {
    $mydomain = 'https://' . $_SERVER['HTTP_HOST'];
} else {
    $mydomain = 'http://' . $_SERVER['HTTP_HOST'];
}
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_HEADER, 1);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $postinfo = '';
    foreach ($_POST as $key => $value) {
        $postinfo .= $key . '=' . urlencode($value) . '&';
    }
    rtrim($postinfo, '&');
    curl_setopt($curlSession, CURLOPT_POST, 1);
    curl_setopt($curlSession, CURLOPT_POSTFIELDS, $postinfo);
}
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
curl_setopt($curlSession, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($curlSession, CURLOPT_COOKIEFILE, $ckfile);
foreach ($_COOKIE as $k => $v) {
    if (is_array($v)) {
        $v = serialize($v);
    }
    curl_setopt($curlSession, CURLOPT_COOKIE, "$k=$v; domain=.$cookiedomain ; path=/");
}
$response = curl_exec($curlSession);
if (curl_error($curlSession)) {
    print curl_error($curlSession);
} else {
    $response  = str_replace("HTTP/1.1 100 Continue\r\n\r\n", "", $response);
    $ar        = explode("\r\n\r\n", $response, 2);
    $header    = $ar[0];
    $body      = $ar[1];
    $header_ar = split(chr(10), $header);
    foreach ($header_ar as $k => $v) {
        if (!preg_match("/^Transfer-Encoding/", $v)) {
            $v = str_replace($base, $mydomain, $v);
            header(trim($v));
        }
    }
    $body = str_replace($base, $mydomain, $body);
    
    //USE THE REPLACE FUNCTION BELOW TO REPLACE CONTENT/CODE OF THE ORIGIN SITE
    // eg. $body = str_replace('Welcome to SiteA','Welcome to SiteB', $body);
    
    $body = str_replace('REPLACE THIS', 'WITH THIS', $body);
    $body = str_replace('REPLACE THIS', 'WITH THIS', $body);
    $body = str_replace('REPLACE THIS', 'WITH THIS', $body);
    print $body;
}
curl_close($curlSession);
copy php above with name "index.php".

Second step :
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]
copy code above with name ".htaccess"

Third step :
Before upload both code in your hosting, change example dot net with website you want to clone.

Demo :
- torbay.ga ( no re-brand )
- movio.ga ( re-brand )

Please make sure, not all website can be clone easy. especially if they use cloudflare.
this is basic script, make sure to re-code to make better.
I tried to experiment with this code, but when i opened the site i get a 500 internal server error. Please what's amiss because i've checked everything as you've instructed but it's still not working. Please i really need assistance as the success of this script is going to be a life saver for me.
 
I tried to experiment with this code, but when i opened the site i get a 500 internal server error. Please what's amiss because i've checked everything as you've instructed but it's still not working. Please i really need assistance as the success of this script is going to be a life saver for me.
If you want clone website wich have cloudflare or anti DDOS you will got that..
try to evade, like add custom header and others..
like i said before.. this script is basic, you still need re-code depend your target need...
 
If you want clone website wich have cloudflare or anti DDOS you will got that..
try to evade, like add custom header and others..
like i said before.. this script is basic, you still need re-code depend your target need...
Am sorry for being so dumb, please how can i evade the script(like you said), add custom header and others. Please am a noob in php, like i said, forgive my dumb questions.
 
Am sorry for being so dumb, please how can i evade the script(like you said), add custom header and others. Please am a noob in php, like i said, forgive my dumb questions.
i also dumb and noob in php.. but about header try add something like this
PHP:
$headers = array(
    'Content-type: application/xml',
    'Authorization: gfhjui',
);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, $headers);
if you need custom referrer :
PHP:
curl_setopt($curlSession, CURLOPT_REFERER, 'firefox or another browser you want');
all reference about curl :
http://php.net/manual/en/function.curl-setopt.php
also you can search on stackoverflow...
 
Is there a way we can change ads on the site to our own ads otherwise it's pointless as we can't make the molar
 
Is there a way we can change ads on the site to our own ads otherwise it's pointless as we can't make the molar
as you can see
Code:
$body = str_replace($strpat, $strrep, $body);
that only replace string.. sometime they use lots code like javascript, so the solution is :
Code:
$body = preg_replace('/their ads regex/is', '<your ads code>', $body);
yes.. add preg replace, just regex their ads with your.
compare this both url :
Code:
movio.ga and gostream.is
 
Last edited:
how do you get traffic to a copy site? as you can't rank it in google
 
Are you sure lynda.ml is based on this technique? Thought it is something like a reverse proxy with authentication on the fly
yupz.. this script is basic reverse proxy.. i add some code inside to make all in on the fly..
 
I get these errors?

Warning: Unknown: open(**HOST** /tmp/sess_178c9aa528b33d1682e709ce8a1e9da5, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (**HOST**public_html/tmp) in Unknown on line 0
 
so apart from changing the url name what else do we need to change? as i get errors?
 
Status
Not open for further replies.
Back
Top