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

[FREE] Clone Website in Real Time

Discussion in 'PHP & Perl' started by GoDesain, Jul 22, 2017.

  1. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    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($curlSessionCURLOPT_URL$url);
    curl_setopt($curlSessionCURLOPT_HEADER1);
    if (
    $_SERVER['REQUEST_METHOD'] == 'POST') {
        
    $postinfo '';
        foreach (
    $_POST as $key => $value) {
            
    $postinfo .= $key '=' urlencode($value) . '&';
        }
        
    rtrim($postinfo'&');
        
    curl_setopt($curlSessionCURLOPT_POST1);
        
    curl_setopt($curlSessionCURLOPT_POSTFIELDS$postinfo);
    }
    curl_setopt($curlSessionCURLOPT_RETURNTRANSFER1);
    curl_setopt($curlSessionCURLOPT_TIMEOUT30);
    curl_setopt($curlSessionCURLOPT_COOKIEJAR$ckfile);
    curl_setopt($curlSessionCURLOPT_COOKIEFILE$ckfile);
    foreach (
    $_COOKIE as $k => $v) {
        if (
    is_array($v)) {
            
    $v serialize($v);
        }
        
    curl_setopt($curlSessionCURLOPT_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"$response2);
        
    $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.
     
    • Thanks Thanks x 1
  2. Sergey Yermak

    Sergey Yermak Newbie

    Joined:
    Mar 12, 2016
    Messages:
    29
    Likes Received:
    2
    Gender:
    Male
    Occupation:
    Node.js
    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: Jul 22, 2017
  3. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    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..
     
  4. KnightOfDust

    KnightOfDust Newbie

    Joined:
    Aug 18, 2013
    Messages:
    18
    Likes Received:
    0
    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
     
  5. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    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..
     
  6. LostLife

    LostLife Regular Member

    Joined:
    May 12, 2017
    Messages:
    258
    Likes Received:
    283
    Gender:
    Male
    Occupation:
    Software Engineer
    It is just mirroring the website.
     
  7. hippo123

    hippo123 Jr. VIP Jr. VIP

    Joined:
    Mar 9, 2016
    Messages:
    1,700
    Likes Received:
    362
    HTTrack seems to be the better option?
     
  8. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    i don't know what this call, sorry if i put wrong title..
    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 )
     
  9. Jahzrock

    Jahzrock Newbie

    Joined:
    Jul 7, 2017
    Messages:
    48
    Likes Received:
    4
    Gender:
    Male
    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.
     
  10. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    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...
     
  11. Jahzrock

    Jahzrock Newbie

    Joined:
    Jul 7, 2017
    Messages:
    48
    Likes Received:
    4
    Gender:
    Male
    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.
     
  12. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    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($curlSessionCURLOPT_HTTPHEADER$headers);
    if you need custom referrer :
    PHP:
    curl_setopt($curlSessionCURLOPT_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...
     
  13. AeroDynam

    AeroDynam Regular Member

    Joined:
    Nov 4, 2014
    Messages:
    229
    Likes Received:
    15
    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
     
  14. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    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: Aug 1, 2017
  15. CFT

    CFT Registered Member

    Joined:
    Feb 20, 2017
    Messages:
    94
    Likes Received:
    13
    how do you get traffic to a copy site? as you can't rank it in google
     
  16. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
  17. 1761

    1761 Newbie

    Joined:
    Dec 6, 2016
    Messages:
    10
    Likes Received:
    1
    Are you sure lynda.ml is based on this technique? Thought it is something like a reverse proxy with authentication on the fly
     
  18. GoDesain

    GoDesain Regular Member

    Joined:
    Feb 26, 2011
    Messages:
    443
    Likes Received:
    130
    Home Page:
    yupz.. this script is basic reverse proxy.. i add some code inside to make all in on the fly..
     
  19. AeroDynam

    AeroDynam Regular Member

    Joined:
    Nov 4, 2014
    Messages:
    229
    Likes Received:
    15
    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
     
  20. AeroDynam

    AeroDynam Regular Member

    Joined:
    Nov 4, 2014
    Messages:
    229
    Likes Received:
    15
    so apart from changing the url name what else do we need to change? as i get errors?