@@ -41,84 +41,89 @@ def initialize
41
41
def run
42
42
wordlist = Rex ::Quickfile . new ( "jtrtmp" )
43
43
44
- wordlist . write ( build_seed ( ) . join ( "\n " ) + "\n " )
45
- wordlist . close
46
-
47
- hashlist = Rex ::Quickfile . new ( "jtrtmp" )
44
+ begin
45
+ wordlist . write ( build_seed ( ) . join ( "\n " ) + "\n " )
46
+ ensure
47
+ wordlist . close
48
+ end
48
49
49
50
myloots = myworkspace . loots . where ( 'ltype=?' , 'linux.hashes' )
50
- unless myloots . nil? or myloots . empty?
51
- myloots . each do |myloot |
52
- begin
53
- usf = File . open ( myloot . path , "rb" )
54
- rescue Exception => e
55
- print_error ( "Unable to read #{ myloot . path } \n #{ e } " )
56
- end
57
- usf . each_line do |row |
58
- row . gsub! ( /\n / , ":#{ myloot . host . address } \n " )
59
- hashlist . write ( row )
51
+ return if myloots . nil? or myloots . empty?
52
+
53
+ loot_data = ''
54
+
55
+ myloots . each do |myloot |
56
+ usf = ''
57
+ begin
58
+ File . open ( myloot . path , "rb" ) do |f |
59
+ usf = f . read
60
60
end
61
+ rescue Exception => e
62
+ print_error ( "Unable to read #{ myloot . path } \n #{ e } " )
61
63
end
62
- hashlist . close
63
-
64
- print_status ( "HashList: #{ hashlist . path } " )
65
-
66
- print_status ( "Trying Format:md5 Wordlist: #{ wordlist . path } " )
67
- john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'md5' )
68
- print_status ( "Trying Format:md5 Rule: All4..." )
69
- john_crack ( hashlist . path , :incremental => "All4" , :format => 'md5' )
70
- print_status ( "Trying Format:md5 Rule: Digits5..." )
71
- john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'md5' )
72
-
73
-
74
- print_status ( "Trying Format:des Wordlist: #{ wordlist . path } " )
75
- john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'des' )
76
- print_status ( "Trying Format:des Rule: All4..." )
77
- john_crack ( hashlist . path , :incremental => "All4" , :format => 'des' )
78
- print_status ( "Trying Format:des Rule: Digits5..." )
79
- john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'des' )
80
-
81
- print_status ( "Trying Format:bsdi Wordlist: #{ wordlist . path } " )
82
- john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'bsdi' )
83
- print_status ( "Trying Format:bsdi Rule: All4..." )
84
- john_crack ( hashlist . path , :incremental => "All4" , :format => 'bsdi' )
85
- print_status ( "Trying Format:bsdi Rule: Digits5..." )
86
- john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'bsdi' )
87
-
88
- if datastore [ 'Crypt' ]
89
- print_status ( "Trying Format:crypt Wordlist: #{ wordlist . path } " )
90
- john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'crypt' )
91
- print_status ( "Trying Rule: All4..." )
92
- john_crack ( hashlist . path , :incremental => "All4" , :format => 'crypt' )
93
- print_status ( "Trying Rule: Digits5..." )
94
- john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'crypt' )
64
+ usf . each_line do |row |
65
+ row . gsub! ( /\n / , ":#{ myloot . host . address } \n " )
66
+ loot_data << row
95
67
end
68
+ end
96
69
70
+ hashlist = Rex ::Quickfile . new ( "jtrtmp" )
71
+ hashlist . write ( loot_data )
72
+ hashlist . close
73
+
74
+ print_status ( "HashList: #{ hashlist . path } " )
75
+
76
+ print_status ( "Trying Format:md5 Wordlist: #{ wordlist . path } " )
77
+ john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'md5' )
78
+ print_status ( "Trying Format:md5 Rule: All4..." )
79
+ john_crack ( hashlist . path , :incremental => "All4" , :format => 'md5' )
80
+ print_status ( "Trying Format:md5 Rule: Digits5..." )
81
+ john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'md5' )
82
+
83
+
84
+ print_status ( "Trying Format:des Wordlist: #{ wordlist . path } " )
85
+ john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'des' )
86
+ print_status ( "Trying Format:des Rule: All4..." )
87
+ john_crack ( hashlist . path , :incremental => "All4" , :format => 'des' )
88
+ print_status ( "Trying Format:des Rule: Digits5..." )
89
+ john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'des' )
90
+
91
+ print_status ( "Trying Format:bsdi Wordlist: #{ wordlist . path } " )
92
+ john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'bsdi' )
93
+ print_status ( "Trying Format:bsdi Rule: All4..." )
94
+ john_crack ( hashlist . path , :incremental => "All4" , :format => 'bsdi' )
95
+ print_status ( "Trying Format:bsdi Rule: Digits5..." )
96
+ john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'bsdi' )
97
+
98
+ if datastore [ 'Crypt' ]
99
+ print_status ( "Trying Format:crypt Wordlist: #{ wordlist . path } " )
100
+ john_crack ( hashlist . path , :wordlist => wordlist . path , :rules => 'single' , :format => 'crypt' )
101
+ print_status ( "Trying Rule: All4..." )
102
+ john_crack ( hashlist . path , :incremental => "All4" , :format => 'crypt' )
103
+ print_status ( "Trying Rule: Digits5..." )
104
+ john_crack ( hashlist . path , :incremental => "Digits5" , :format => 'crypt' )
105
+ end
97
106
98
- cracked = john_show_passwords ( hashlist . path )
99
107
108
+ cracked = john_show_passwords ( hashlist . path )
100
109
101
- print_status ( "#{ cracked [ :cracked ] } hashes were cracked!" )
102
110
103
- cracked [ :users ] . each_pair do |k , v |
104
- if v [ 0 ] == "NO PASSWORD"
105
- passwd = ""
106
- else
107
- passwd = v [ 0 ]
108
- end
109
- print_good ( "Host: #{ v . last } User: #{ k } Pass: #{ passwd } " )
110
- report_auth_info (
111
- :host => v . last ,
112
- :port => 22 ,
113
- :sname => 'ssh' ,
114
- :user => k ,
115
- :pass => passwd
116
- )
111
+ print_status ( "#{ cracked [ :cracked ] } hashes were cracked!" )
112
+
113
+ cracked [ :users ] . each_pair do |k , v |
114
+ if v [ 0 ] == "NO PASSWORD"
115
+ passwd = ""
116
+ else
117
+ passwd = v [ 0 ]
117
118
end
119
+ print_good ( "Host: #{ v . last } User: #{ k } Pass: #{ passwd } " )
120
+ report_auth_info (
121
+ :host => v . last ,
122
+ :port => 22 ,
123
+ :sname => 'ssh' ,
124
+ :user => k ,
125
+ :pass => passwd
126
+ )
118
127
end
119
-
120
128
end
121
-
122
-
123
-
124
129
end
0 commit comments