Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('Net/SSH2.php');
- $ssh = new Net_SSH2('-Redacted-');
- if (!$ssh->login('-Redacted-', '-Redacted-')) {
- exit('Login Failed');
- }
- echo $ssh->read('username@username:~$');
- $ssh->write("sudo ls -lan");
- $output = $ssh->read('#[pP]assword[^:]*:|username@username:~$#',
- NET_SSH2_READ_REGEX);
- echo $output;
- if (preg_match('#[pP]assword[^:]*:#', $output)) {
- $ssh->write("passwordn");
- echo $ssh->read('username@username:~$');
- }
- ?>
- PHP Fatal error: Maximum execution time of 30 seconds exceeded in
- C:Users-Redacted-DesktopApache2.2htdocsNetSSH2.php on line 2358
- if (isset($this->keyboard_requests_responses)) {
- for ($i = 0; $i < $num_prompts; $i++) {
- if (strlen($response) < 4) {
- return false;
- }
- extract(unpack('Nlength', $this->_string_shift($response, 4)));
- // prompt - ie. "Password: "; must not be empty
- Line 2358---- $prompt = $this->_string_shift($response, $length);
- //$echo = $this->_string_shift($response) != chr(0);
- foreach ($this->keyboard_requests_responses as $key => $value) {
- if (substr($prompt, 0, strlen($key)) == $key) {
- $responses[] = $value;
- break;
- }
- }
- }
- }
- <?php
- include('Net/SSH2.php');
- try{
- $ssh = new Net_SSH2('-redacted-');
- if (!$ssh->login('-redacted-', '-redacted-')) {
- exit('Login Failed');
- }
- echo $ssh->read('username@username:~$');
- $ssh->write("sudo ls -lan");
- $output = $ssh->read('#[pP]assword[^:]*:|username@username:~$#',
- NET_SSH2_READ_REGEX);
- echo $output;
- if (preg_match('#[pP]assword[^:]*:#', $output)) {
- $ssh->write("passwordn");
- echo $ssh->read('username@username:~$');
- }catch(Exception $ex){echo "You got an error".$ex->getMessage();}
- ?>
- ini_set('max_execution_time', 300);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement