@@ -27,13 +27,13 @@ def self.parse(data)
27
27
xml . elements . to_a ( "//Properties" ) . each do |node |
28
28
epassword = node . attributes [ 'cpassword' ]
29
29
next if epassword . to_s . empty?
30
- pass = self . decrypt ( epassword )
30
+ password = self . decrypt ( epassword )
31
31
32
32
user = node . attributes [ 'runAs' ] if node . attributes [ 'runAs' ]
33
33
user = node . attributes [ 'accountName' ] if node . attributes [ 'accountName' ]
34
34
user = node . attributes [ 'username' ] if node . attributes [ 'username' ]
35
35
user = node . attributes [ 'userName' ] if node . attributes [ 'userName' ]
36
- user = node . attributes [ 'newName' ] unless node . attributes [ 'newName' ] . nil? or node . attributes [ 'newName' ] . empty?
36
+ user = node . attributes [ 'newName' ] unless node . attributes [ 'newName' ] . nil? || node . attributes [ 'newName' ] . empty?
37
37
changed = node . parent . attributes [ 'changed' ]
38
38
39
39
# Printers and Shares
@@ -56,18 +56,18 @@ def self.parse(data)
56
56
57
57
result = {
58
58
:USER => user ,
59
- :PASS => pass ,
59
+ :PASS => password ,
60
60
:CHANGED => changed
61
61
}
62
62
63
- result . merge! ( { :EXPIRES => expires } ) unless expires . nil? or expires . empty?
64
- result . merge! ( { :NEVER_EXPIRE => never_expires } ) unless never_expires . nil? or never_expires . empty?
65
- result . merge! ( { :DISABLED => disabled } ) unless disabled . nil? or disabled . empty?
66
- result . merge! ( { :PATH => path } ) unless path . nil? or path . empty?
67
- result . merge! ( { :DATASOURCE => dsn } ) unless dsn . nil? or dsn . empty?
68
- result . merge! ( { :DRIVER => driver } ) unless driver . nil? or driver . empty?
69
- result . merge! ( { :TASK => app_name } ) unless app_name . nil? or app_name . empty?
70
- result . merge! ( { :SERVICE => service } ) unless service . nil? or service . empty?
63
+ result . merge! ( { :EXPIRES => expires } ) unless expires . nil? || expires . empty?
64
+ result . merge! ( { :NEVER_EXPIRE => never_expires } ) unless never_expires . nil? || never_expires . empty?
65
+ result . merge! ( { :DISABLED => disabled } ) unless disabled . nil? || disabled . empty?
66
+ result . merge! ( { :PATH => path } ) unless path . nil? || path . empty?
67
+ result . merge! ( { :DATASOURCE => dsn } ) unless dsn . nil? || dsn . empty?
68
+ result . merge! ( { :DRIVER => driver } ) unless driver . nil? || driver . empty?
69
+ result . merge! ( { :TASK => app_name } ) unless app_name . nil? || app_name . empty?
70
+ result . merge! ( { :SERVICE => service } ) unless service . nil? || service . empty?
71
71
72
72
attributes = [ ]
73
73
node . elements . each ( '//Attributes//Attribute' ) do |dsn_attribute |
@@ -82,7 +82,7 @@ def self.parse(data)
82
82
results << result
83
83
end
84
84
85
- return results
85
+ results
86
86
end
87
87
88
88
def self . create_tables ( results , filetype , domain = nil , dc = nil )
@@ -102,19 +102,19 @@ def self.create_tables(results, filetype, domain=nil, dc=nil)
102
102
table << [ "TYPE" , filetype ]
103
103
table << [ "USERNAME" , result [ :USER ] ]
104
104
table << [ "PASSWORD" , result [ :PASS ] ]
105
- table << [ "DOMAIN CONTROLLER" , dc ] unless dc . nil? or dc . empty?
106
- table << [ "DOMAIN" , domain ] unless domain . nil? or domain . empty?
105
+ table << [ "DOMAIN CONTROLLER" , dc ] unless dc . nil? || dc . empty?
106
+ table << [ "DOMAIN" , domain ] unless domain . nil? || domain . empty?
107
107
table << [ "CHANGED" , result [ :CHANGED ] ]
108
- table << [ "EXPIRES" , result [ :EXPIRES ] ] unless result [ :EXPIRES ] . nil? or result [ :EXPIRES ] . empty?
109
- table << [ "NEVER_EXPIRES?" , result [ :NEVER_EXPIRE ] ] unless result [ :NEVER_EXPIRE ] . nil? or result [ :NEVER_EXPIRE ] . empty?
110
- table << [ "DISABLED" , result [ :DISABLED ] ] unless result [ :DISABLED ] . nil? or result [ :DISABLED ] . empty?
111
- table << [ "PATH" , result [ :PATH ] ] unless result [ :PATH ] . nil? or result [ :PATH ] . empty?
112
- table << [ "DATASOURCE" , result [ :DSN ] ] unless result [ :DSN ] . nil? or result [ :DSN ] . empty?
113
- table << [ "DRIVER" , result [ :DRIVER ] ] unless result [ :DRIVER ] . nil? or result [ :DRIVER ] . empty?
114
- table << [ "TASK" , result [ :TASK ] ] unless result [ :TASK ] . nil? or result [ :TASK ] . empty?
115
- table << [ "SERVICE" , result [ :SERVICE ] ] unless result [ :SERVICE ] . nil? or result [ :SERVICE ] . empty?
116
-
117
- unless result [ :ATTRIBUTES ] . nil? or result [ :ATTRIBUTES ] . empty?
108
+ table << [ "EXPIRES" , result [ :EXPIRES ] ] unless result [ :EXPIRES ] . nil? || result [ :EXPIRES ] . empty?
109
+ table << [ "NEVER_EXPIRES?" , result [ :NEVER_EXPIRE ] ] unless result [ :NEVER_EXPIRE ] . nil? || result [ :NEVER_EXPIRE ] . empty?
110
+ table << [ "DISABLED" , result [ :DISABLED ] ] unless result [ :DISABLED ] . nil? || result [ :DISABLED ] . empty?
111
+ table << [ "PATH" , result [ :PATH ] ] unless result [ :PATH ] . nil? || result [ :PATH ] . empty?
112
+ table << [ "DATASOURCE" , result [ :DSN ] ] unless result [ :DSN ] . nil? || result [ :DSN ] . empty?
113
+ table << [ "DRIVER" , result [ :DRIVER ] ] unless result [ :DRIVER ] . nil? || result [ :DRIVER ] . empty?
114
+ table << [ "TASK" , result [ :TASK ] ] unless result [ :TASK ] . nil? || result [ :TASK ] . empty?
115
+ table << [ "SERVICE" , result [ :SERVICE ] ] unless result [ :SERVICE ] . nil? || result [ :SERVICE ] . empty?
116
+
117
+ unless result [ :ATTRIBUTES ] . nil? || result [ :ATTRIBUTES ] . empty?
118
118
result [ :ATTRIBUTES ] . each do |dsn_attribute |
119
119
table << [ "ATTRIBUTE" , "#{ dsn_attribute [ :A_NAME ] } - #{ dsn_attribute [ :A_VALUE ] } " ]
120
120
end
@@ -123,7 +123,7 @@ def self.create_tables(results, filetype, domain=nil, dc=nil)
123
123
tables << table
124
124
end
125
125
126
- return tables
126
+ tables
127
127
end
128
128
129
129
# Decrypts passwords using Microsoft's published key:
@@ -132,8 +132,8 @@ def self.decrypt(encrypted_data)
132
132
unless encrypted_data
133
133
return ""
134
134
end
135
-
136
- pass = ""
135
+
136
+ password = ""
137
137
padding = "=" * ( 4 - ( encrypted_data . length % 4 ) )
138
138
epassword = "#{ encrypted_data } #{ padding } "
139
139
decoded = Rex ::Text . decode_base64 ( epassword )
@@ -145,12 +145,12 @@ def self.decrypt(encrypted_data)
145
145
aes . key = key
146
146
plaintext = aes . update ( decoded )
147
147
plaintext << aes . final
148
- pass = plaintext . unpack ( 'v*' ) . pack ( 'C*' ) # UNICODE conversion
148
+ password = plaintext . unpack ( 'v*' ) . pack ( 'C*' ) # UNICODE conversion
149
149
rescue OpenSSL ::Cipher ::CipherError => e
150
150
puts "Unable to decode: \" #{ encrypted_data } \" Exception: #{ e } "
151
151
end
152
152
153
- return pass
153
+ password
154
154
end
155
155
156
156
end
0 commit comments