Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <?php
  2. include('Net/SSH2.php');
  3.  
  4. $ssh = new Net_SSH2('-Redacted-');
  5. if (!$ssh->login('-Redacted-', '-Redacted-')) {
  6. exit('Login Failed');
  7. }
  8.  
  9. echo $ssh->read('username@username:~$');
  10. $ssh->write("sudo ls -lan");
  11. $output = $ssh->read('#[pP]assword[^:]*:|username@username:~$#',
  12. NET_SSH2_READ_REGEX);
  13. echo $output;
  14. if (preg_match('#[pP]assword[^:]*:#', $output)) {
  15. $ssh->write("passwordn");
  16. echo $ssh->read('username@username:~$');
  17. }
  18. ?>
  19.  
  20. PHP Fatal error: Maximum execution time of 30 seconds exceeded in
  21. C:Users-Redacted-DesktopApache2.2htdocsNetSSH2.php on line 2358
  22.  
  23. if (isset($this->keyboard_requests_responses)) {
  24. for ($i = 0; $i < $num_prompts; $i++) {
  25. if (strlen($response) < 4) {
  26. return false;
  27. }
  28. extract(unpack('Nlength', $this->_string_shift($response, 4)));
  29. // prompt - ie. "Password: "; must not be empty
  30. Line 2358---- $prompt = $this->_string_shift($response, $length);
  31. //$echo = $this->_string_shift($response) != chr(0);
  32. foreach ($this->keyboard_requests_responses as $key => $value) {
  33. if (substr($prompt, 0, strlen($key)) == $key) {
  34. $responses[] = $value;
  35. break;
  36. }
  37. }
  38. }
  39. }
  40.  
  41. <?php
  42. include('Net/SSH2.php');
  43. try{
  44. $ssh = new Net_SSH2('-redacted-');
  45. if (!$ssh->login('-redacted-', '-redacted-')) {
  46. exit('Login Failed');
  47. }
  48.  
  49. echo $ssh->read('username@username:~$');
  50. $ssh->write("sudo ls -lan");
  51. $output = $ssh->read('#[pP]assword[^:]*:|username@username:~$#',
  52. NET_SSH2_READ_REGEX);
  53. echo $output;
  54. if (preg_match('#[pP]assword[^:]*:#', $output)) {
  55. $ssh->write("passwordn");
  56. echo $ssh->read('username@username:~$');
  57. }catch(Exception $ex){echo "You got an error".$ex->getMessage();}
  58. ?>
  59.  
  60. ini_set('max_execution_time', 300);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement