@@ -101,10 +101,17 @@ def john_cracked_passwords
101
101
def john_show_passwords ( hfile , format = nil )
102
102
res = { :cracked => 0 , :uncracked => 0 , :users => { } }
103
103
104
+ john_command = john_binary_path
105
+
106
+ if john_command . nil?
107
+ print_error ( "John the Ripper executable not found" )
108
+ return res
109
+ end
110
+
104
111
pot = john_pot_file
105
112
conf = ::File . join ( john_base_path , "confs" , "john.conf" )
106
113
107
- cmd = [ john_binary_path , "--show" , "--conf=#{ conf } " , "--pot=#{ pot } " , hfile ]
114
+ cmd = [ john_command , "--show" , "--conf=#{ conf } " , "--pot=#{ pot } " , hfile ]
108
115
109
116
if format
110
117
cmd << "--format=" + format
@@ -140,6 +147,13 @@ def john_unshadow(passwd_file,shadow_file)
140
147
141
148
retval = ""
142
149
150
+ john_command = john_binary_path
151
+
152
+ if john_command . nil?
153
+ print_error ( "John the Ripper executable not found" )
154
+ return nil
155
+ end
156
+
143
157
if File . exists? ( passwd_file )
144
158
unless File . readable? ( passwd_file )
145
159
print_error ( "We do not have permission to read #{ passwd_file } " )
@@ -161,7 +175,7 @@ def john_unshadow(passwd_file,shadow_file)
161
175
end
162
176
163
177
164
- cmd = [ john_binary_path . gsub ( /john$/ , "unshadow" ) , passwd_file , shadow_file ]
178
+ cmd = [ john_command . gsub ( /john$/ , "unshadow" ) , passwd_file , shadow_file ]
165
179
166
180
if RUBY_VERSION =~ /^1\. 8\. /
167
181
cmd = cmd . join ( " " )
@@ -237,9 +251,16 @@ def john_crack(hfile, opts={})
237
251
238
252
res = { :cracked => 0 , :uncracked => 0 , :users => { } }
239
253
254
+ john_command = john_binary_path
255
+
256
+ if john_command . nil?
257
+ print_error ( "John the Ripper executable not found" )
258
+ return nil
259
+ end
260
+
240
261
# Don't bother making a log file, we'd just have to rm it when we're
241
262
# done anyway.
242
- cmd = [ john_binary_path , "--session=" + john_session_id , "--nolog" ]
263
+ cmd = [ john_command , "--session=" + john_session_id , "--nolog" ]
243
264
244
265
if opts [ :conf ]
245
266
cmd << ( "--conf=" + opts [ :conf ] )
0 commit comments