Accessing VBoxManage info from a webserver

Discussions related to using VirtualBox on Windows hosts.
Post Reply
cryptic
Posts: 1
Joined: 16. May 2008, 15:46

Accessing VBoxManage info from a webserver

Post by cryptic »

Im currently trying to develop a PHP class so that we can access info regarding any virtual box loaded on the web server and possibly control that box from the web site, the web server is Win 2003 ( not my choise ) and ive run some tests so far and found a few issues.

Firstly i cant run the VBoxManage commands as administrator that easly as it gives me this error because it see's me as the nt authority\system user and not <domain>\administrator.

I created a Batch file like this :

Code: Select all

:: Check if a VBox is active
@echo OFF
Cls
Set defaultserver="ETSIC-BASE"

::IF dummy==dummy%1 (
    ::echo run : runme.bat [servername]
    echo useing default server %defaultserver%
    set vboxname=%defaultserver%
::) ELSE (
::    set vboxname=%1
::)


whoami

VBoxManage showvminfo %vboxname%"

::SANUR
::runas /u:etsic1\administrator "whoami > bat_file_output.log" | sanur password && echo/Succeeded || echo/Failed

::LSRUNAS
::lsrunas /user:administrator /password:password /domain:etsic /command:notepad.exe /runpath:c:\


:: runs on box when logged in as admin but not from the website.
:: VBoxManage showvminfo %vboxname%

:: Run as Admin but prompts for password.
:: runas /noprofile /env /user:password1\administrator "VBoxManage showvminfo %vboxname%"

:: http://www.joeware.net/freetools/tools/cpau/usage.htm
:: run as admin program loaded.
:: CPAU doesn't support running from LocalSystem.
:: cpau -u password1\administrator -p password -ex VBoxManage showvminfo %vboxname%
TIMEOUT 5
And i get this error message:

Code: Select all

VirtualBox Command Line Management Interface Version 1.5.6
(C) 2005-2008 innotek GmbH
All rights reserved.

[!] Failed to create the VirtualBox object!
[!] Primary RC  = E_FAIL (0x80004005) - Unspecified error
[!] Full error info present: true , basic error info present: true 
[!] Result Code = E_FAIL (0x80004005) - Unspecified error
[!] Text        = Could not lock the settings file 'C:\Documents and Settings\Default User\.VirtualBox\VirtualBox.xml' (VERR_SHARING_VIOLATION)
[!] Component   = VirtualBox, Interface: IVirtualBox, {76b25f3c-15d4-4785-a9d3-adc6a462beec}
[!] Callee      = <NULL>, {00000000-0000-0000-0000-000000000000}
I assume its because the nt authority\system cant access C:\Documents and Settings\Default User\.VirtualBox\VirtualBox.xml where the admin can.

You will see that ive tried runas, lsrunas and sanur and none seam to be helping me out. So please please any help on this issue would be cool.

here is a test execute script you can use with php:

Code: Select all

<?php
/* BAT File save in C:\htdocs\runas.bat
save log file C:\htdocs\bat_file_output.log
-----------------
whoami
VBoxManage showvminfo %vboxname%"
-----------------
*/
$run=5;

if ($run == 1){
    $commandTest = 'lsrunas /user:administrator /password:password /domain:etsic1 /command:C:\Apache\Apache2.2\htdocs\aum2\ajax\runas.bat > bat_file_output.log /runpath:C:\Apache\Apache2.2\htdocs\aum2\ajax\ ';
}elseif($run == 2){
    $commandTest = 'runas /u:etsic1\administrator "C:\Apache\Apache2.2\htdocs\aum2\ajax\runas.bat > bat_file_output.log" | sanur password && echo/Succeeded || echo/Failed ';
}elseif($run == 3){
    $commandTest = 'lsrunas /user:administrator /password:password /domain:etsic1 /command:whoami > bat_file_output.log /runpath:C:\Apache\Apache2.2\htdocs\aum2\ajax\ ';
}elseif($run == 4){
    $commandTest = 'runas /u:etsic1\administrator "whoami > bat_file_output.log" | sanur password && echo/Succeeded || echo/Failed ';
}else{
    $commandTest = 'runas.bat > bat_file_output.log';
}

$result = exec_batfile($commandTest);
echo "<hr /><pre>";
echo $result;
echo "</pre>";

function exec_batfile($command){
   echo $command;
   exec($command);
   $handle = fopen("C:\Apache\Apache2.2\htdocs\aum2\ajax\bat_file_output.log", "r");
   if ($handle) {
        $buffer = '';
        while (!feof($handle)) {
            $buffer .= fgets($handle, 4096);
        }
        fclose($handle);
    }
    return $buffer;
}
?>
Michelin
Posts: 6
Joined: 18. Sep 2012, 10:39

Re: Accessing VBoxManage info from a webserver

Post by Michelin »

Hi cryptic,

I suppose that you will never see this post, but I have to try.

Did you manage to solve the issue at your side? I have a similar issue, that I can not resolve and I need some help. :?
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Accessing VBoxManage info from a webserver

Post by noteirak »

Do you have the same issue?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply