Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. require 'rubygems'
  2. require 'net/ssh'
  3. host="192.168.69.1"
  4. user='admin'
  5. pass='password'
  6. result=''
  7. Net::SSH.start(host, user, :password => pass) do |ssh|
  8. # Open a channel
  9. channel = ssh.open_channel do |channel, success|
  10. channel.request_pty
  11. channel.exec("help")
  12.  
  13. channel.on_data do |channel, data|
  14. puts data
  15. # Send the password
  16. if data.include?("login")
  17. channel.send_data "#{user}\n"
  18. print("#{user} send user")
  19. end
  20. if data.include?("password")
  21. channel.send_data("#{pass}\n")
  22. print("#{pass} sending pass")
  23. end
  24. if data.include?('rkscli:')
  25. puts("exec cmd")
  26. channel.send_data("help\n"){|c,d| puts d}
  27. channel.wait
  28. end
  29. end
  30.  
  31. end
  32. # Wait for opened channel
  33. channel.wait
  34.  
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement