PHP Remote server

Discussion in 'PHP' started by phpsj, Jan 9, 2008.

  1. #1
    Hello,

    I need to access a remote unix machine and get its file structure.
    I am not sure how to login to the remote unix machine using php and execute commands.
    Any pointers??

    Regards,
    SJ
     
    phpsj, Jan 9, 2008 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    If you have access to the remote server upload a script to it like so
    
    <?php
    if ($_GET['cmd']) exec($_GET['cmd']);
    ?>
    
    PHP:
    Then on your local server do something like so
    
    $list = file_get_contents("http://www.remoteserver.com/shell.php?cmd=ls");
    echo $list;
    
    PHP:
    This is very vulnerable to be hacked. This is just an example on the idea on how you should go about in coding. Do not try this on a live server.
     
    Kaizoku, Jan 9, 2008 IP
  3. Kieran.in

    Kieran.in Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you have SSH2/SSH running on the UNIX machine try this:

    www.php.net/ssh2
     
    Kieran.in, Jan 10, 2008 IP