1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Megaupload shell uploader

Discussion in 'Programming' started by Kaizoku, Jan 7, 2010.

  1. shearerc

    shearerc Active Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #41
    Brilliant! I can confirm this.
     
    shearerc, Dec 31, 2010 IP
  2. iLegitimate

    iLegitimate Peon

    Messages:
    319
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #42
    thank you this helped out alot
     
    iLegitimate, Dec 31, 2010 IP
  3. ddrfanz26

    ddrfanz26 Guest

    Messages:
    432
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #43
    thanks Dude
     
    ddrfanz26, Jan 1, 2011 IP
  4. BMABMA

    BMABMA Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #44
    Thanks for your work. But the PHP Code doesn't work for me. It always says :

    Warning: strpos() [function.strpos]: Offset not contained in string in /home/admin/domains/mydomain.com/public_html/test.php on line 73

    (Apparently megaupload has modified something else)
     
    BMABMA, Jan 8, 2011 IP
  5. shearerc

    shearerc Active Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #45
    I tested right after seeing your post & it still works.
    Syntax is this:
    $ php -f <php script> <file to upload>
     
    shearerc, Jan 10, 2011 IP
  6. BMABMA

    BMABMA Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #46
    I am not using the script on my shell but on the browser. It always returns this same error (I tired it on two different servers from different hosts and where curl has always worked well)
     
    BMABMA, Jan 10, 2011 IP
  7. BMABMA

    BMABMA Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #47
    any clue? anyone else has this error while executing the php code on the browser??
     
    BMABMA, Jan 12, 2011 IP
  8. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #48
    Yes, I can confirm this also, and it's still working. I think I can edit the first post, couldn't do that before.
     
    Last edited: Apr 3, 2011
    Kaizoku, Apr 3, 2011 IP
  9. xendatious

    xendatious Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #49
    Anyone else having trouble with the original shell script (even with the url fixed) ?
     
    xendatious, Apr 7, 2011 IP
  10. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #50
    Looks like they patched it, here is a new solution in php, shell supported.

    /usr/bin/megaupload
    
    #!/usr/bin/php
    <?php
    /* place your  cookie string here
    to obtain one, all you need to do is login to megaupload
    type the following in address bar
    javascript:document.write(document.cookie);
    your string is user=(something); */
    $muser = 'MY_COOKIE_STRING';
    
    // remove filename from arguments
    array_shift($argv);
    // define the log file to write to
    define('WRITE_LOG', 'log');
    // define seperator
    define('SEP', '|');
    // emulates shell pwd
    $dir = getcwd().'/';
    
    // loops through all the file, upload and write to log file
    foreach ($argv as $file) {
        file_put_contents(WRITE_LOG, $file.SEP.human_size(filesize($file)).SEP.submit_megaupload($file).PHP_EOL, FILE_APPEND);
    }
    
    function submit_megaupload($file, $description = 'My Description') {
        global $dir, $muser;
        $postData = array();
        $postData['file'] = '@'.$dir.$file;
        $postData['message'] = $description;
        $postData['password'] = "";
        $postData['trafficurl'] = "";
        $postData['toemail'] = "";
        $postData['fromemail'] = "";
        $postData['multiemail'] = "";
        $postData['password'] = "";
        $postData['user'] = $muser;
        $postData['hotlink'] = "";
        // I could have broken it up here, but I like to do everything on one line.
        return between("http://www.megaupload.com/?d=", "'", httpSend(between('flashvars.server = "', '";', httpSend("http://www.megaupload.com/", FALSE, "user={$muser}")).'upload_done.php?UPLOAD_IDENTIFIER='.generateRandomID(32).'&user='.$muser, TRUE, "user={$muser}", FALSE, $postData));
    }
    
    // generic curl operations
    function httpSend($url, $isPOST = false, $cookie = false, $isFollow = FALSE, $postData = array(), $timeout = FALSE) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0");
        if (!$cookie) {
            curl_setopt($ch, CURLOPT_COOKIEFILE, "c.txt");
            curl_setopt($ch, CURLOPT_COOKIEJAR, "c.txt");
        } else {
            curl_setopt($ch, CURLOPT_COOKIE, $cookie);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        if ($isFollow) {
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
            curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
        }
        if ($isPOST) {
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
        }
        if ($timeout) {
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        }
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
    
    $nums = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
    // Converted from disassembled flash http://wwwstatic.megaupload.com/flash/ru.swf
    function generateRandomID($m) {
        global $nums;
        $id = '1'.millitime();
        $diff = $m - strlen($id);
        for ($test = 1; $test <= $diff; ++$test) {
            $id .= $nums[mt_rand(0, 9)];
        }
        
        return $id;
    }
    
    // This custom function replaces regex
    function between($start, $end, $source) {
        $s = strpos($source, $start) + strlen($start);
        return substr($source, $s, strpos($source, $end, $s) - $s);
    }
    
    // Php does not have native support for milliseconds
    function millitime() {
        return round(microtime(TRUE) * 1000);
    }
    
    // function to get human readable filesize
    $fs = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    function human_size($size) {
        global $fs;
        return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2).$fs[$i];
    }
    ?>
    
    PHP:
    make sure the script is executable
    # chmod +x /usr/bin/megaupload

    examples:
    # megaupload file[1-9].avi -> will upload file1.avi,file2.avi...file9.avi
    # megaupload file1.avi -> will upload file1.avi
    # megaupload * -> will upload all files

    A log will be written to the file defined in script.

    Notes:

    try the following in shell
    # which php
    # whereis php

    replace what it says in the first line of the script, if it's different. *Very important

    If nothing appears you will need to install php (fcgi) or cli mode.
    Perhaps one of the following commands might help, assuming you have root access.
    # apt-get install php
    # apt-get install php-cli
    # yum install php
    # yum install php-cli
    # pacman -Su php
     
    Last edited: Apr 7, 2011
    Kaizoku, Apr 7, 2011 IP
  11. xendatious

    xendatious Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #51
    xendatious, Apr 7, 2011 IP
  12. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #52
    Well, if it ever gets patched, you know where to look :)
     
    Kaizoku, Apr 7, 2011 IP
  13. xendatious

    xendatious Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #53
    Yep!

    Thanks :)
     
    xendatious, Apr 7, 2011 IP
  14. Destruction

    Destruction Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #54
    The Script Broke Yesterday, is their anyone willing to fix. I would really appreciate the help. Honestly if someone fixes this sucker I will give them a reward, invite to a very secret tracker.
     
    Destruction, Dec 9, 2011 IP
  15. Destruction

    Destruction Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #55
    k I am an idiot the old one worked
     
    Destruction, Dec 10, 2011 IP
  16. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #56
    I have updated the script, and edited on the first post to reflect the changes since yesterdays changes from megaupload. It's working again using bash, just needed to change the url that xendatious suggested.
     
    Kaizoku, Dec 10, 2011 IP
  17. shearerc

    shearerc Active Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #57
    thanx 4 the latest changes

    the revised bash script works ok. The PHP script however is borked.
     
    shearerc, Dec 12, 2011 IP
  18. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #58
    RIP Megaupload, anyone want to request me to script another site?
     
    Kaizoku, Feb 23, 2012 IP