Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Remote Ultra VNC script

    I found a Script on the web that works with Ultra vnc for remote support, it came pretty blank and i have added a lot of stuff to it for security and ease of use, but i did all of this work on a linux box with apache and it all worked fine, but the main box it will be hosted on is a windows box with xampp (Apache) installed and its not working, basically the part this is not working is where is zips all the contents of a folder to a .msi package.
    PHP Code:
    <?php
    $ip 
    '0.0.0.0'// ip address of repeater
    $serverPort '80'// server listening port of repeater (YOUR client)
    $viewerPort '80'// viewer listening port of repeater (tech support agent)
    $sendFilename 'support.exe'// filename to be sent to user to download
    $useUPX false// compress executable with upx? true or false
    $tempFolder '/tmp'// location of temporary folder (must be writable by webserver), DON'T include trailing slash
    $filename7Z 'C:\Program Files\7-Zip\7z.exe'// 7zip executable filename '7za' or '7zr'
    $useAT false// enable or disable use of AT command to clean used executables. true or false
    $repName 'support specialist'// name of support tech (shown in balloon message box on client)


    $clientFile $sessionKey null;
    $configured false;
    $ret '';

    if (isset(
    $_POST['sessionKey']) && !empty($_POST['sessionKey'])) {
      
    $sessionKey escapeshellcmd($_POST['sessionKey']); // sanitize input since it will be used on the shell

      
    $clientConfig file_get_contents('client/helpdesk_default.txt'); // read default helpdesk config file
      
    $search = array('$IP''$PORT''$REP''$ID'); // replace these
      
    $replace = array($ip$serverPort$repName$sessionKey); // with these
      
    $clientConfig str_replace($search$replace$clientConfig); // perform replacements
      
    $configured file_put_contents('client/helpdesk.txt'$clientConfig); // update config file with current session data

      
    if ($configured) { // configure succeeded, initiate build
        
    $ret .= shell_exec('cd client;' $filename7Z ' a ' $tempFolder '/c' $sessionKey '.7z helpdesk.txt icon1.ico icon2.ico icon3.ico winvnc.exe;cd ..'); // compress vnc server and config files
        
    $ret .= shell_exec('cat support/7zS.sfx client/config.txt ' $tempFolder '/c' $sessionKey '.7z > ' $tempFolder '/c' $sessionKey '.exe'); // create self extracting executable

        
    if ($useUPX === true) {
          
    $ret .= shell_exec('upx -9 -f -k -o built/c' $sessionKey '.exe /tmp/c' $sessionKey '.exe'); // compress resulting executable into built directory
        
    } else {
          
    $ret .= shell_exec('cp ' $tempFolder '/c' $sessionKey '.exe built/c' $sessionKey '.exe');
        }

        
    $ret .= shell_exec('rm ' $tempFolder '/c' $sessionKey '.exe ' $tempFolder '/c' $sessionKey '.7z'); // clean up temporary files
        
    if ($useAT === true$ret .= shell_exec('at -f support/cleanBuilds  now + 2 minutes'); // schedule a clean up of built executables (2 minutes allows time to download file)
        
    $clientFile 'built/c' $sessionKey '.exe';
       
        if (
    file_exists($clientFile)) { // executable has been built, send it to the client
          
    header('Content-type: application/octet-stream');
          
    header('Content-Length: ' filesize($clientFile));
          
    header('Content-Disposition: attachment; filename=' $sendFilename);
          
    readfile($clientFile);
        } else { 
    // the build failed
          
    echo "There was an error building your session, please try again...";
        }
      } else { 
    // somehow the configure failed (likely a permissions issue)
        
    echo "There was an error building your session, please try again...";
      }

    }
    ?>
    As you can see this is because it is using linux shell commands, is there a way to convert this to work on a windows box?
    There is an admin page, but im sure if i can see how its done on this page i should be able to manage that one.

    Regards,
    Az

  • #2
    Regular Coder
    Join Date
    Apr 2007
    Location
    Griffith. Australia
    Posts
    138
    Thanks
    4
    Thanked 4 Times in 4 Posts
    This will be slightly beyond PHP development as the commands you are calling are specific to the operating system and not to PHP. The PHP exec function is there to pass commands to whatever shell is used whether it is linux or windows. I would recommend googling what each command in linux does and then trying to find the matching command in windows and what the syntax and variables are.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •