...

View Full Version : PHP Remote Ultra VNC script



azler
12-15-2010, 11:51 AM
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
$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

knightcon
01-13-2011, 06:54 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum