exec() public method

If $callback is set to false then Net_SSH2::_get_channel_packet(NET_SSH2_CHANNEL_EXEC) will need to be called manually. In all likelihood, this is not a feature you want to be taking advantage of.
public exec ( string $command, Callback $callback = null ) : string
$command string
$callback Callback
return string
コード例 #1
16
ファイル: AriiExec.php プロジェクト: AriiPortal/I5Bundle
 public function Exec($command)
 {
     $engine = $this->session->getSpooler();
     if (!isset($engine[0]['shell'])) {
         print "?!";
         exit;
     }
     $shell = $engine[0]['shell'];
     $host = $shell['host'];
     $user = $shell['user'];
     $password = $shell['password'];
     $method = 'CURL';
     set_include_path(get_include_path() . PATH_SEPARATOR . '../vendor/phpseclib');
     include 'Net/SSH2.php';
     include 'Crypt/RSA.php';
     $ssh = new \Net_SSH2($host);
     if (1) {
         $key = new \Crypt_RSA();
         $ret = $key->loadKey("-----BEGIN RSA PRIVATE KEY-----\nMIICWgIBAAKBgQCzRy01HoHIzBJJb/D8A/eTV3qiZxy0NIR97NE14rJblnJZT5Kg\noP2DvIRzlB0msL5cHQJ/qXYAoemHRDKqNZuj89+MYsBeZqNu3/DXdZLq9XJ8e2rb\nsGrDjHvCHEDWL0JIRFnRacem55+XsUsKTIs4tbcD6adMPIYJSQQ7oB/8AQIBIwKB\ngB67vptkUMNWLwVGY9NuZPSv6SMnnoVK1OJjHIzlCKH8iKGYnMsUSLd/ZynBnpjr\nGVGekrbMl+LZ7YTnHqDV/WxGoWEc3xiHE8/HwZwQZxP92K70inz8+6dGEagsrSqO\nQkdAPR/+qen7uQ9yXqj7WAoNFicPJ2cpo8kuEW33KywzAkEA4yH4jf0uNBFDUkR6\ni9DQC5bsgEloVezWnCsm6eIm5o5SGKPZ6Rpro/h3pq5qvPmCtjrZFnK0Dab9xkFr\n/F9lkwJBAMoQMqxYdnPz74Bto99o0PZrk2ikROwXR9eURi3B4bWGq9+mvN3OEQdE\n8JofGyq60LMlnFAkE7v49fYHziyaFJsCQHTPpGZHsVybKe/LcjlG0WULyhYXH7cp\nWG2SiQqRkFlQgf4LH5xz/Nf8IEcX3x9bv5DrEI8zrQ5V4Zko9bT93HcCQQCEyNDX\np9jP2tCWOWuwEa3jwwkY4PoXfQNTJuxJ9G/AbnDyDnwcup15zje1vKtz2dmaS+pg\njLyC1s2Ea4d8ZUC9AkAeUr/N+011K2zGTjxZnAFY/Ow348bomzddiJYAYA+76exV\n3wUYsjeDxqq8Km93+iMQ8DDNZIvoVcfYQW9BfDlf\n-----END RSA PRIVATE KEY-----   ");
         if (!$ret) {
             echo "loadKey failed\n";
             print "<pre>" . $ssh->getLog() . '</pre>';
             exit;
         }
     } elseif (isset($shell['password'])) {
         $key = $shell['password'];
     } else {
         $key = '';
         // ?! possible ?
     }
     if (!$ssh->login($user, $key)) {
         exit("Login Failed ({$user})");
     }
     return $ssh->exec("system '{$command}'");
 }
コード例 #2
0
 public function execute($com = false)
 {
     if ($com == false) {
         die("Epic Fail! Yes, it was epic");
     }
     $oldPath = set_include_path("/home/sites/berrics.dev/sharedVendors/phpseclib");
     App::import("Vendor", "SSH2", array("file" => "phpseclib/Net/SSH2.php"));
     set_include_path($oldPath);
     $ssh = new Net_SSH2('10.181.67.27');
     $login = $ssh->login('root', 'WEB1MH0r5t7Wn');
     $out = '';
     switch ($com) {
         case "sync-berrics-all":
             $out .= $ssh->exec("/home/sites/berrics.shell/sync-berrics-all");
             $out .= $ssh->exec("/home/sites/berrics.shell/clear-cache");
             break;
         case "sync-berrics-all-check":
             $out .= $ssh->exec("/home/sites/berrics.shell/sync-berrics-all-check");
             break;
         case "sync-berrics-splash":
             $out .= $ssh->exec("/home/sites/berrics.shell/sync-berrics-splash");
             break;
         default:
             $out .= "Nothing to do...";
             break;
     }
     $this->set(compact("out"));
     //echo $ssh->exec('/home/sites/berrics.shell/sync-berrics-all-check');
 }
コード例 #3
0
ファイル: Release.class.php プロジェクト: Warkot/Bolt
 public function deploy()
 {
     $releaseId = $this->dataBase->startRelease();
     $ssh = new Net_SSH2(SSH_SERVER);
     $key = new Crypt_RSA();
     $key->setPassword(SSH_PASSWORD);
     $key->loadKey(file_get_contents(PATH_TO_PRIVATE_KEY));
     if (!$ssh->login(SSH_LOGIN, $key)) {
         $this->dataBase->logStep($releaseId, 'ssh ' . SSH_SERVER, ['error' => 'Login failed'], 1);
         exit('Login Failed');
     }
     $ssh->enableQuietMode();
     $command = $this->bash->dtLock('sandbox-mercury', 'mercury');
     $output['success'] = $ssh->exec($command);
     $output['error'] = $ssh->getStdError();
     $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus());
     $command = $this->bash->dtPrep('sandbox-mercury', 'mercury', ["mercury" => "dev"]);
     $output['success'] = $ssh->exec($command);
     $output['error'] = $ssh->getStdError();
     $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus());
     $command = $this->bash->dtPush('sandbox-mercury', 'mercury');
     $output['success'] = $ssh->exec($command);
     $output['error'] = $ssh->getStdError();
     $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus());
 }
コード例 #4
0
ファイル: AriiExec.php プロジェクト: AriiPortal/ATSBundle
    public function Exec($command, $stdin = '')
    {
        $database = $this->session->getDatabase();
        $name = $database['name'];
        $engine = $this->session->getSpoolerByName($name, 'waae');
        if (!isset($engine[0]['shell'])) {
            print "?!";
            exit;
        }
        set_include_path('../vendor/phpseclib' . PATH_SEPARATOR . get_include_path());
        include 'Net/SSH2.php';
        include 'Crypt/RSA.php';
        $shell = $engine[0]['shell'];
        $host = $shell['host'];
        $user = $shell['user'];
        $ssh = new \Net_SSH2($host);
        if (isset($shell['key'])) {
            $key = new \Crypt_RSA();
            $ret = $key->loadKey($shell['key']);
            if (!$ret) {
                echo "loadKey failed\n";
                print "<pre>" . $ssh->getLog() . '</pre>';
                exit;
            }
        } elseif (isset($shell['password'])) {
            $key = $shell['password'];
        } else {
            $key = '';
            // ?! possible ?
        }
        if (!$ssh->login('autosys', $key)) {
            print 'Login Failed';
            print "<pre>" . $ssh->getLog() . '</pre>';
            exit;
        }
        if ($stdin == '') {
            return $ssh->exec(". ~/.bash_profile;{$command}");
        }
        // Test STDIN
        $ssh->enablePTY();
        print "profile" . $ssh->exec(". ~/.bash_profile");
        print "sort" . ($exec = $ssh->exec('sort'));
        $ssh->write(<<<EOF
echo "update_job: SE.ERIC.JOB.JobType_UNIX"
echo "description: 'ok!!'
EOF
);
        $ssh->reset(true);
        $ssh->setTimeout(2);
        print $ssh->read();
        return;
        return $ssh->read();
        // outputs the echo above
    }
コード例 #5
0
ファイル: Ssh.php プロジェクト: sayiho/Jumper
 /**
  * @param $command
  *
  * @throws \RuntimeException
  * @throws \Jumper\Exception\CommunicatorException
  * @return String
  */
 public function run($command)
 {
     $result = $this->ssh->exec($command);
     if ($result === false) {
         throw new CommunicatorException($this->ssh->getLastError());
     }
     $error = $this->ssh->getStdError();
     if (!empty($error)) {
         throw new \RuntimeException($error);
     }
     return $result;
 }
コード例 #6
0
function getPing($sourceIP, $destinationIP)
{
    // This will work with any pfSense install. $sourceIP is the IP address of the WAN that you want to
    // use to ping with. This allows you to ping the same address from multiple WANs if you need to.
    global $local_pfsense_ip;
    global $pfSense_username;
    global $pfSense_password;
    $ssh = new Net_SSH2($local_pfsense_ip);
    if (!$ssh->login($pfSense_username, $pfSense_password)) {
        //exit('Login Failed');
        return array(0, 0);
    }
    $terminal_output = $ssh->exec('ping -c 5 -q -S ' . $sourceIP . ' ' . $destinationIP);
    // If using something besides OS X you might want to customize the following variables for proper output of average ping.
    $findme_start = '= ';
    $start = strpos($terminal_output, $findme_start);
    $ping_return_value_str = substr($terminal_output, $start + 2, 100);
    $findme_stop1 = '.';
    $stop = strpos($ping_return_value_str, $findme_stop1);
    $findme_avgPing_decimal = '.';
    $avgPing_decimal = strpos($ping_return_value_str, $findme_avgPing_decimal, 6);
    $findme_forward_slash = '/';
    $avgPing_forward_slash = strpos($ping_return_value_str, $findme_forward_slash);
    $avgPing = substr($ping_return_value_str, $stop + 5, $avgPing_decimal - $avgPing_forward_slash - 1);
    return $avgPing;
}
コード例 #7
0
ファイル: AriiSSH.php プロジェクト: AxelANGENAULT/CoreBundle
 public function Exec($host, $user, $password, $command)
 {
     $ssh = new Net_SSH2($host);
     if (!$ssh->login($user, $password)) {
         exit('Login Failed');
     }
     echo $ssh->exec("system '{$command}'");
 }
コード例 #8
0
function ConectSSHStation($server)
{
    $ssh = new Net_SSH2($server);
    if (!$ssh->login(userubnt, passubnt)) {
        print "Login Failed {$server}";
    }
    $mca = $ssh->exec("mca-status");
    return $mca;
}
コード例 #9
0
ファイル: lib.php プロジェクト: istrwei/vpn_manager
 function delete_user($username, $server_host, $server_username, $server_password)
 {
     $ssh = new Net_SSH2($server_host);
     if ($ssh->login($server_username, $server_password) == false) {
         exit('Login Failed');
     }
     $command = 'userdel -r ' . $username;
     echo $ssh->exec($command);
 }
コード例 #10
0
ファイル: AriiExec.php プロジェクト: AriiPortal/Arii
 public function Exec($command)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . '../vendor/phpseclib');
     include 'Net/SSH2.php';
     $ssh = new \Net_SSH2($this->host);
     if (!$ssh->login($this->user, $this->password)) {
         exit('Login Failed');
     }
     return $ssh->exec("system '{$command}'");
 }
コード例 #11
0
ファイル: runbash.php プロジェクト: raulastu/sshmail
function runcmd($cmd)
{
    include 'Net/SSH2.php';
    $ssh = new Net_SSH2('localhost');
    if (!$ssh->login('rc', 'cacapedo')) {
        exit('Login Failed');
    }
    // echo $ssh->exec('pwd');
    $r = $ssh->exec($cmd);
    return str_replace("\n", "<br>", $r);
}
コード例 #12
0
function set_addr($subnet, $interface)
{
    $interface = $interface != '' ? $interface : $GLOBALS['ethernet_forenaming_scheme'] . '1';
    $ip = explode('/', $subnet);
    $cidr = $ip[1];
    $ip_parts = explode('.', $ip[0]);
    $ip_parts[3] = $ip_parts[3] + 1;
    $gw = implode('.', $ip_parts);
    $ip_parts[3] = $ip_parts[3] + 1;
    $ip = implode('.', $ip_parts);
    $ssh = new Net_SSH2('192.168.88.1');
    if ($ssh->login('admin', $GLOBALS['admin_password'])) {
        //while we're here we might as well reset the mac addresses again.
        $detail = $ssh->exec('int eth print');
        if (preg_match_all("/{$GLOBALS['ethernet_forenaming_scheme']}/", $detail, $matches)) {
            $i = 1;
            foreach ($matches[0] as $match) {
                $ssh->exec('int ethernet reset-mac-address ' . $GLOBALS['ethernet_forenaming_scheme'] . $i);
                $ssh->exec(':beep frequency=120 length=2ms;');
                $i++;
                if ($i == '10') {
                    $ssh->exec('int ethernet reset-mac-address ' . $GLOBALS['sfp_forenaming_scheme'] . '1');
                }
            }
        }
        $ssh->exec('ip address add address=' . $ip . '/' . $cidr . ' interface=' . $interface);
        //set the ip on the specified interface.
        $ssh->exec('ip route add dst-address=0.0.0.0/0 gateway=' . $gw);
        //add the default route
    }
}
コード例 #13
0
function getInfo($ip, $sshkey_location)
{
    $ssh = new Net_SSH2($ip);
    //key
    $key = new Crypt_RSA();
    $key->loadKey(file_get_contents($sshkey_location));
    if (!$ssh->login('root', $key)) {
        die("SSH Login Failed!");
    } else {
        $return['disk_usage'] = $ssh->exec("df -k .|awk 'NR==2 {print \$5}'");
        $return['disk_remaining'] = 100 - substr($return['disk_usage'], 0, -1) . "%";
        $uptime = $ssh->exec('echo `uptime`');
        list($uptime, $load) = explode('load average:', $uptime);
        list($trash, $uptime) = explode(' up ', $uptime);
        list($uptime, $trash) = explode(', ', $uptime);
        $return['uptime'] = $uptime;
        $return['load'] = $load;
        //get memory
        $return['memory_free'] = $ssh->exec("cat /proc/meminfo|grep 'MemFree'");
        list($trash, $return['memory_free']) = explode('MemFree:', $return['memory_free']);
    }
    return $return;
}
コード例 #14
0
ファイル: SshHelper.php プロジェクト: rafeco/simpledeployer
 public function runCommand($cmd)
 {
     if (!empty($this->key_path)) {
         $key = new Crypt_RSA();
         $key->loadKey(file_get_contents($this->key_path));
     }
     $ssh = new Net_SSH2($this->host, $this->port);
     if ($key) {
         $ssh->login($this->user, $key);
     } else {
         $ssh->login($this->user, $this->password);
     }
     $out = $ssh->exec($cmd);
     return $out;
 }
コード例 #15
0
ファイル: Remote.php プロジェクト: FluentDevelopment/piwik
 private function doRunTests($testSuite, array $arguments)
 {
     $arguments = implode(' ', $arguments);
     $this->ssh->exec("ps -ef | grep \"php console tests:run\" | grep -v grep | awk '{print \$2}' | xargs kill -9");
     if ('all' === $testSuite) {
         $this->ssh->exec('php console tests:run --options="--colors" ' . $arguments);
     } elseif ('ui' === $testSuite) {
         $this->ssh->exec('php console tests:run-ui --persist-fixture-data --assume-artifacts ' . $arguments);
     } else {
         $this->ssh->exec('php console tests:run --options="--colors" --testsuite="unit" ' . $arguments);
         $this->ssh->exec('php console tests:run --options="--colors" --testsuite="' . $testSuite . '" ' . $arguments);
     }
     if ('system' === $testSuite) {
         $this->ssh->exec("tar -cjf tests/PHPUnit/System/processed/processed.tar.bz2 tests/PHPUnit/System/processed/ plugins/*/tests/System/processed/ --exclude='.gitkeep' --exclude='tests/PHPUnit/System/processed/processed.tar.bz2'");
     }
 }
コード例 #16
0
ファイル: Ssh.php プロジェクト: Leemo/deployer
 /**
  * Execute task and return report info
  *
  * @return \Deployer\Task
  */
 public function execute()
 {
     $info = '';
     foreach ($this->params() as $param => $value) {
         $this->_params[$param] = \Deployer::applyGlobalParams($value);
     }
     $ssh = new \Net_SSH2($this->param('host'), $this->param('port'));
     if (!$ssh->login($this->param('username'), $this->param('password'))) {
         throw new \Deployer\TaskException('Can\'t connect to remote host');
     }
     foreach ((array) $this->param('cmd') as $cmd) {
         $command = 'cd ' . $this->param('directory') . ' && ' . $cmd;
         $command = \Deployer::applyGlobalParams($command);
         $result = $ssh->exec($command);
         $info .= '$ ' . $command . PHP_EOL . $result . PHP_EOL;
     }
     return $this->info($info);
 }
コード例 #17
0
ファイル: bandit6.php プロジェクト: agamenom/Bandit
<html>
<head><meta charset="utf-8"><title>Bandit</title></head>
<body>
<?php 
set_include_path(get_include_path() . PATH_SEPARATOR . 'c:\\wamp\\www\\bandit\\phpseclib');
include 'phpseclib\\Net\\SSH2.php';
$ssh = new Net_SSH2('bandit6.labs.overthewire.org');
if (!$ssh->login('bandit6', 'DXjZPULLxYr17uwoI01bNLQbtFemEgo7')) {
    exit('Login Failed');
} else {
    echo "<b>CONECTADO!</b> <p>";
}
echo "Bandit6 Pass Walkthough<p>\n\t++ find -size 33c | grep \"bandit7\"<BR>\n\t++ cat /var/lib/dpkg/info/bandit7.password<p>";
echo "<h1>" . $ssh->exec('cat \\/var\\/lib\\/dpkg\\/info\\/bandit7.password') . "</h1>";
echo $ssh->exec('exit');
?>
</body>
</html>


コード例 #18
0
    #$bitcoin = new Bitcoin($row['rpc_username'],$row['rpc_password'],$row['ip_rpc'],$row['port_rpc']);
    $result2 = mysqli_query($con, "SELECT name FROM coind_templates WHERE id='" . $row['templateid'] . "'");
    $row2 = mysqli_fetch_row($result2);
    echo "<tr><td>" . $row['id'] . "</td><td>" . $row2[0] . "</td><td>" . $row['ip_p2p'] . "</td><td>P2P: " . $row['port_p2p'] . "<br>RPC:" . $row['port_rpc'] . "</td>";
    echo "<td>";
    echo "[ <a href=coinds.remove.php?id=" . $row['id'] . ">Remove</a> ]";
    $result3 = mysqli_query($con, "SELECT ip FROM servers WHERE id='" . $row['serverid'] . "'");
    $serverinfo = mysqli_fetch_row($result3);
    //log into server.,
    $ssh = new Net_SSH2($serverinfo[0]);
    $key = new Crypt_RSA();
    $key->loadKey(file_get_contents($sshkey_location));
    if (!$ssh->login('root', $key)) {
        $debug[]['ssh'] = "SSH Login Failed!";
    } else {
        $debug[$rows]['pid'] = $ssh->exec('cat /home/' . $row['username'] . '/.' . $row['coinname'] . '/' . $row['coind'] . '.pid');
        echo "[ <a href=coinds.info.php?id=" . $row['id'] . ">Info</a> ]";
        if ($debug[$rows]['pid'] > 0) {
            echo "<br>[ <a href=coinds.ioflip.php?id=" . $row['id'] . "&type=stop>Stop</a> |";
            echo " <a href=coinds.ioflip.php?id=" . $row['id'] . "&type=restart>Restart</a> ]";
        } else {
            echo "<br>[ <a href=coinds.ioflip.php?id=" . $row['id'] . "&type=start>Start</a> ]";
        }
    }
    echo "</td></tr>";
    ++$rows;
}
if ($rows <= 0) {
    echo "<tr><td>0</td><td colspan=5><i>There are no coin instances currently being managed!</i></td></tr>";
}
echo "<tr><td>+</td><td colspan=5><a href=coinds.add.php>Create Coind Instance</a></td></tr>";
コード例 #19
0
    flush();
}
if (!isset($_GET['id'])) {
    die("Please go back and select a server to update.");
}
$result = mysqli_query($con, "SELECT ip FROM servers WHERE id='" . $_GET['id'] . "'");
$serverinfo = mysqli_fetch_row($result);
//log into server.,
$ssh = new Net_SSH2($serverinfo[0]);
$key = new Crypt_RSA();
$key->loadKey(file_get_contents($sshkey_location));
if (!$ssh->login('root', $key)) {
    $debug[] = "SSH Login Failed!";
} else {
    echo "Updating repository files";
    $debug['exec_apt-get_update'] = $ssh->exec('apt-get update', 'packet_handler');
    echo "Updated!<br>";
    echo "Upgrading server";
    $debug['exec_apt-get_upgrade'] = $ssh->exec('apt-get upgrade -y', 'packet_handler');
    echo "Upgraded!<br>";
    #echo "Downloading & Installing required libboost1.53-dev";
    #$debug['exec_libboost1.53-dev'] = $ssh->exec('wget http://p2pmine.com/tools/repo/libboost1.53-dev_1.53.0-6+exp3ubuntu8_amd64.deb; dpkg -i libboost1.53-dev_1.53.0-6+exp3ubuntu8_amd64.deb');
    #echo "Finished!<br>";
    echo "Installing required files";
    $debug['exec_apt-get_install'] = $ssh->exec('apt-get install -y libtool autotools-dev autoconf build-essential make libssl-dev libboost-dev libboost-all-dev libdb++-dev libminiupnpc-dev python-dev git python2.7 python-zope.interface python-twisted python-twisted-web pkg-config', 'packet_handler');
    echo "Finished!<br>";
}
mysqli_close($con);
print_r($debug);
?>
<a href=/manager>go back</a>
コード例 #20
0
ファイル: get_all_stats.php プロジェクト: cloudseo/nginad
function get_json_info_from_server($ip_address, $username, $password, $start_date, $end_date = null)
{
    global $path_to_logfile_rollup;
    $ssh = new Net_SSH2($ip_address);
    if (!$ssh->login($username, $password)) {
        exit('Login Failed');
    }
    $command = 'php ' . $path_to_logfile_rollup . 'logfile_rollup.php ' . $start_date;
    if ($end_date !== null) {
        $command .= ' ' . $end_date;
    }
    $json_response = null;
    try {
        $json_response = $ssh->exec($command);
    } catch (Exception $e) {
        die($e->getMessage());
    }
    return $json_response;
}
コード例 #21
0
     echo "<pre>Copying keys to {$config_dir}</pre>";
     //TODO.. multiple commands if server key is blank
     $keys_dir = $var_dir . "keys";
     $server_crt = $server_name . ".crt";
     $server_key = $server_name . ".key";
     echo "<pre>Running Command: sudo cd {$keys_dir};cp ca.crt ca.key dh1024.pem {$server_crt} {$server_key} {$config_dir}</pre>";
     $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
     echo $ssh->write("sudo cd {$keys_dir};cp ca.crt ca.key dh1024.pem {$server_crt} {$server_key} {$config_dir}\n");
     $result = $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
     echo "<pre>{$result}</pre>";
     echo str_repeat(' ', 1024 * 64);
     //END BETA (NON ROOT) LOOP
 } else {
     //Root user!
     //Can now run commmands as root, easiest method
     $ssh->exec("sed -i 's/KEY_COUNTRY=.*/KEY_COUNTRY=\"{$key_country}\"/g' {$var_file}");
     $ssh->exec("sed -i 's/KEY_PROVINCE=.*/KEY_PROVINCE=\"{$key_province}\"/g' {$var_file}");
     $ssh->exec("sed -i 's/KEY_CITY=.*/KEY_CITY=\"{$key_city}\"/g' {$var_file}");
     $ssh->exec("sed -i 's/KEY_ORG=.*/KEY_ORG=\"{$key_org}\"/g' {$var_file}");
     $ssh->exec("sed -i 's/KEY_EMAIL=.*/KEY_EMAIL=\"{$key_email}\"/g' {$var_file}");
     $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
     echo "<pre>Running . ./vars</pre>";
     echo str_repeat(' ', 1024 * 64);
     //purge buffer
     $ssh->write("cd " . $var_dir . ";source ./vars\n");
     $ssh->setTimeout(10);
     $output = $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
     echo "<pre>{$output}</pre>";
     echo str_repeat(' ', 1024 * 64);
     //still have to use read/write, since I need the session variables to remain the same.....
     echo "<pre>Running ./clean-all</pre>";
コード例 #22
0
ファイル: shower.php プロジェクト: nsbrown/DASA
$modestring = './dasademo mode ';
$modestring .= $mode;
$xstring = './dasademo x ';
$xstring .= $x;
$ystring = './dasademo y ';
$ystring .= $y;
$zstring = './dasademo z ';
$zstring .= $z;
echo "{$tempstring}";
echo "<br />";
echo "{$modestring}";
echo "<br />";
echo "{$xstring}";
echo "<br />";
echo "{$ystring}";
echo "<br />";
echo "{$zstring}";
$ssh = new Net_SSH2('155.42.112.199');
if (!$ssh->login('nathanbrown', 'dasa')) {
    exit('Login Failed');
}
echo $ssh->exec($tempstring);
echo $ssh->exec($modestring);
echo $ssh->exec($xstring);
echo $ssh->exec($ystring);
echo $ssh->exec($zstring);
include 'footer.php';
?>
</center>
<script src="includes/js/ui_tools.js"></script>
コード例 #23
0
ファイル: sshd.php プロジェクト: nulled/anypanel
$log = 1;
define('PANEL_BASE_PATH', '/home/nulled/www');
set_include_path(get_include_path() . PATH_SEPARATOR . PANEL_BASE_PATH . '/server/modules/core/phpseclib');
require_once PANEL_BASE_PATH . '/server/modules/core/phpseclib/Net/SSH2.php';
$ssh = new Net_SSH2('205.252.250.4');
if (!$ssh->login('user', 'pass')) {
    exit('Login Failed');
}
$cmd_file = '/home/nulled/www/server/logs/command.issue';
unlink($cmd_file);
$i = 0;
while (true) {
    if (is_file($cmd_file) and filesize($cmd_file) and ($command = file_get_contents($cmd_file)) !== false) {
        unlink($cmd_file);
        $i = 0;
        if ($log) {
            echo "{$cmd_file} found\n";
        }
        $return = $ssh->exec(trim($command));
        file_put_contents($cmd_file . '.receiving', $return);
        rename($cmd_file . '.receiving', $cmd_file . '.return');
    }
    $i++;
    if ($i > 10000) {
        $i--;
        // echo "usleep(200000)\n";
        usleep(200000);
    } else {
        usleep(1000);
    }
}
コード例 #24
0
$coindinfo['port_rpc'] = $coindinfo[5];
$result2 = mysqli_query($con, "SELECT ip FROM servers WHERE id='" . $_POST['serverid'] . "'");
$serverinfo = mysqli_fetch_row($result2);
$serverinfo['ip'] = $serverinfo[0];
//log into server.,
$ssh = new Net_SSH2($serverinfo['ip']);
$key = new Crypt_RSA();
$key->loadKey(file_get_contents($sshkey_location));
if (!$ssh->login('root', $key)) {
    $debug[] = "SSH Login Failed!";
} else {
    //insert into coind_instances $port_rpc,$port_p2p in database
    if (!mysqli_query($con, "INSERT INTO coind_instances (id,templateid,serverid,username,coinname,coind,ip_p2p,port_p2p,ip_rpc,port_rpc,rpc_user,rpc_password) VALUES (NULL,'" . $_POST['templateid'] . "','" . $_POST['serverid'] . "','" . $_POST['username'] . "','" . $coindinfo['name'] . "','" . $coindinfo['coind'] . "','" . $serverinfo['ip'] . "','" . $_POST['port_p2p'] . "','" . $serverinfo['ip'] . "','" . $_POST['port_rpc'] . "','" . $_POST['rpc_user'] . "','" . $_POST['rpc_password'] . "')")) {
        $debug['mysql_error'] = "Unable to add coind instance to database!";
        $debug['mysql_error_raw'] = mysqli_error($con);
    } else {
        $debug['mysql_success'] = "Success! Coind instance added to database.";
    }
    $debug['chmod_dir'] = $ssh->exec("chown -R " . $_POST['username'] . " /home/" . $_POST['username'] . "/sauce");
}
mysqli_close($con);
print_r($debug);
echo '
<form action=coinds.add-do.step-FIN.php method=post>
<input type=hidden name=templateid value="' . $_POST['templateid'] . '" />
<input type=hidden name=serverid value="' . $_POST['serverid'] . '" />
<input type=hidden name=username value="' . $_POST['username'] . '" />
<input type=hidden name=port_rpc value="' . $_POST['port_rpc'] . '" />
<input type=hidden name=port_p2p value="' . $_POST['port_p2p'] . '" />
<input type=submit value="[FIN]> Start Daemon" onclick="this.value = \\"Please wait...\\"; this.disabled = true"/>
</form>';
コード例 #25
0
ファイル: bandit4.php プロジェクト: agamenom/Bandit
<html>
<head><meta charset="utf-8"><title>Bandit</title></head>
<body>
<?php 
set_include_path(get_include_path() . PATH_SEPARATOR . 'c:\\wamp\\www\\bandit\\phpseclib');
include 'phpseclib\\Net\\SSH2.php';
$ssh = new Net_SSH2('bandit4.labs.overthewire.org');
if (!$ssh->login('bandit4', 'pIwrPrtPN36QITSp3EQaw936yaFoFgAB')) {
    exit('Login Failed');
} else {
    echo "<b>CONECTADO!</b> <p>";
}
echo "Bandit5 Pass Walkthrough<p>\n\t++ file inhere/.-* (the file07 is the only ASCII file type)<br>\n\t++ cat inhere/.-file07<p>";
echo "<h1>" . $ssh->exec('cat inhere\\/./-file07') . "</h1>";
echo $ssh->exec('exit');
?>
</body>
</html>


コード例 #26
0
ファイル: bandit2.php プロジェクト: agamenom/Bandit
<html>
<head><title>Bandit</title></head>
<body>
<?php 
set_include_path(get_include_path() . PATH_SEPARATOR . 'c:\\wamp\\www\\bandit\\phpseclib');
include 'phpseclib\\Net\\SSH2.php';
$ssh = new Net_SSH2('bandit2.labs.overthewire.org');
if (!$ssh->login('bandit2', 'CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9')) {
    exit('Login Failed');
} else {
    echo "<b>CONECTADO!</b> <p>";
}
echo "Bandit3 Pass Walkthrough<p>\n\t++ cat spaces\\ in\\ this\\ filename\\<br>\n\t(or cat \"spaces in this filename\")<p>";
echo "<h1>" . $ssh->exec('cat spaces\\ in\\ this\\ filename\\') . "</h1>";
echo $ssh->exec('exit');
?>
</body>
</html>


コード例 #27
0
ファイル: api.php プロジェクト: masroore/chrisreloaded
     if (!$ssh_connection->login($_SESSION['username'], $_SESSION['password'])) {
         die('Login Failed');
     }
     $result['result'] = FeedC::cancel($id, $ssh_connection);
 } else {
     if ($what == 'file') {
         $ssh_connection = new Net_SSH2(CLUSTER_HOST);
         if (!$ssh_connection->login($_SESSION['username'], $_SESSION['password'])) {
             die('Login Failed');
         }
         // here we store content to a file
         $name = joinPaths(CHRIS_USERS, $parameters[0]);
         // make sure to escape line breaks etc.
         $content = escapeshellarg($parameters[1]);
         // replace file contents
         $ssh_connection->exec("echo " . $content . " > " . $name);
         $result['result'] = $name . ' written.';
     } else {
         if ($what == 'feed_merge') {
             // login since we will modify things on the file system
             $ssh_connection = new Net_SSH2(CLUSTER_HOST);
             if (!$ssh_connection->login($_SESSION['username'], $_SESSION['password'])) {
                 die('Login Failed');
             }
             // grab the master id
             $master_feed_id = $id;
             // .. and the slave id
             $slave_feed_id = $parameters;
             // merge the feeds
             $merged = FeedC::mergeFeeds($master_feed_id, $slave_feed_id, $ssh_connection);
             if ($merged) {
コード例 #28
0
         //exit;
     } else {
         gameserver_restart($type, $ssh, $gs_login, $name_internal, $port, $ip, $map, $slots, $parameter, $gameq, $row[3], $app_set_config);
         //event_add(7,"Der Gameserver ".$ip.":".$port." ist abgestürtzt und wurde neu gestartet.");
         event_add(10, $ip . ":" . $port);
     }
 }
 //Log Cleanup
 if ($db_log_gs_cleanup == 1) {
     $stmt = $mysqli->prepare("SELECT ip,port,user,password FROM dedicated WHERE id = ?");
     $ssh = new Net_SSH2($dedi_ip, $dedi_port);
     if (!$ssh->login($dedi_login, $dedi_password)) {
         //exit;
     } else {
         if ($db_type == "steamcmd") {
             $ssh->exec("sudo -u " . $row[0] . " bash -c 'tail -n 150 /home/" . $row[0] . "/game/screenlog.0 > /home/" . $row[0] . "/game/screenlog.tmp'");
             $ssh->exec("sudo -u " . $row[0] . " bash -c 'cat /home/" . $row[0] . "/game/screenlog.tmp > /home/" . $row[0] . "/game/screenlog.0'");
             $ssh->exec("sudo -u " . $row[0] . " bash -c 'rm /home/" . $row[0] . "/game/screenlog.tmp'");
         } elseif ($db_type == "image") {
             $ssh->exec("sudo -u " . $row[0] . " bash -c 'tail -n 150 /home/" . $row[0] . "/screenlog.0 > /home/" . $row[0] . "/screenlog.tmp'");
             $ssh->exec("sudo -u " . $row[0] . " bash -c 'cat /home/" . $row[0] . "/screenlog.tmp > /home/" . $row[0] . "/screenlog.0'");
             $ssh->exec("sudo -u " . $row[0] . " bash -c 'rm /home/" . $row[0] . "/screenlog.tmp'");
         }
     }
 }
 //Daily Restart
 if ($row[11] == 1 and date('H') == $row['12'] and date('i') == 5) {
     $ssh = new Net_SSH2($dedi_ip, $dedi_port);
     if (!$ssh->login($dedi_login, $dedi_password)) {
         //exit;
     } else {
コード例 #29
0
ファイル: bandit1.php プロジェクト: agamenom/Bandit
<html>
<head><title>Bandit</title></head>
<body>
<?php 
set_include_path(get_include_path() . PATH_SEPARATOR . 'c:\\wamp\\www\\bandit\\phpseclib');
include 'phpseclib\\Net\\SSH2.php';
$ssh = new Net_SSH2('bandit1.labs.overthewire.org');
if (!$ssh->login('bandit1', 'boJ9jbbUNNfktd78OOpsqOltutMc3MY1')) {
    exit('Login Failed');
} else {
    echo "<b>CONECTADO!</b> <p>";
}
echo "Bandit2 Pass Walkthrough<p>\n\t++ ls -la (to see all files)<br>\n\t++ cat ./- (special character filename)<p>";
echo "<h1>" . $ssh->exec('cat ./-') . "</h1>";
echo $ssh->exec('exit');
?>
</body>
</html>


コード例 #30
0
    echo ".";
    @ob_flush();
    flush();
}
$result = mysqli_query($con, "SELECT name,coind,gitsrc,cd_gitsrc,port_p2p,port_rpc FROM coind_templates WHERE id='" . $_POST['templateid'] . "'");
$coindinfo = mysqli_fetch_row($result);
$coindinfo['name'] = $coindinfo[0];
$coindinfo['coind'] = $coindinfo[1];
$coindinfo['gitsrc'] = $coindinfo[2];
$coindinfo['cd_gitsrc'] = $coindinfo[3];
$coindinfo['port_p2p'] = $coindinfo[4];
$coindinfo['port_rpc'] = $coindinfo[5];
$result2 = mysqli_query($con, "SELECT ip FROM servers WHERE id='" . $_POST['serverid'] . "'");
$serverinfo = mysqli_fetch_row($result2);
$serverinfo['ip'] = $serverinfo[0];
//log into server.,
$ssh = new Net_SSH2($serverinfo['ip']);
$key = new Crypt_RSA();
$key->loadKey(file_get_contents($sshkey_location));
if (!$ssh->login('root', $key)) {
    $debug[] = "SSH Login Failed!";
} else {
    $ssh->setTimeout(25);
    $debug['exec_fixutf8bug'] = $ssh->exec('su -c "export LC_ALL=\\"en_US.UTF-8\\"" -s /bin/sh ' . $_POST['username'], 'packet_handler');
    $cmd = "cd /home/" . $_POST['username'] . "/sauce/" . $coindinfo['cd_gitsrc'] . "/;";
    $cmd .= "./" . $coindinfo['coind'] . " -daemon &";
    $debug['exec_service'] = $ssh->exec('su -c "' . $cmd . '" -s /bin/sh ' . $_POST['username'], 'packet_handler');
    $debug['step'] = "Daemon Started! <a href=coinds.php>Enjoy your service.</a>";
}
mysqli_close($con);
print_r($debug);