@@ -49,31 +49,34 @@ def http_verb
4949
5050 # Try to auto detect the target architecture and platform
5151 #
52- # @param [String ] The available targets
52+ # @param [Array ] The available targets
5353 # @return [Msf::Module::Target, nil] The detected target or nil
5454 def auto_target ( available_targets )
55- if http_verb == 'HEAD' then
55+ if http_verb == 'HEAD'
5656 print_status ( "Sorry, automatic target detection doesn't work with HEAD requests" )
5757 else
5858 print_status ( "Attempting to automatically select a target..." )
5959 res = query_serverinfo
60- if not ( plat = detect_platform ( res ) )
60+ plat = detect_platform ( res )
61+ unless plat
6162 print_warning ( 'Unable to detect platform!' )
6263 return nil
6364 end
6465
65- if not ( arch = detect_architecture ( res ) )
66+ arch = detect_architecture ( res )
67+ unless arch
6668 print_warning ( 'Unable to detect architecture!' )
6769 return nil
6870 end
6971
7072 # see if we have a match
71- available_targets . each { |t | return t if ( t [ 'Platform' ] == plat ) and ( t [ 'Arch' ] == arch ) }
73+ available_targets . each { |t | return t if t [ 'Platform' ] == plat && t [ 'Arch' ] == arch }
7274 end
7375
7476 # no matching target found, use Java as fallback
7577 java_targets = available_targets . select { |t | t . name =~ /^Java/ }
76- return java_targets [ 0 ]
78+
79+ java_targets [ 0 ]
7780 end
7881
7982 # Query the server information from HtmlAdaptor
@@ -102,6 +105,7 @@ def query_serverinfo
102105
103106 # Try to autodetect the target platform
104107 #
108+ # @param res [Rex::Proto::Http::Response] the http response where fingerprint platform from
105109 # @return [String, nil] The target platform or nil
106110 def detect_platform ( res )
107111 if res && res . body =~ /<td.*?OSName.*?(Linux|FreeBSD|Windows).*?<\/ td>/m
@@ -120,13 +124,14 @@ def detect_platform(res)
120124
121125 # Try to autodetect the target architecture
122126 #
127+ # @param res [Rex::Proto::Http::Response] the http response where fingerprint architecture from
123128 # @return [String, nil] The target architecture or nil
124129 def detect_architecture ( res )
125130 if res && res . body =~ /<td.*?OSArch.*?(x86|i386|i686|x86_64|amd64).*?<\/ td>/m
126131 arch = $1
127- if ( arch =~ /(x86|i386|i686)/i )
132+ if arch =~ /(x86|i386|i686)/i
128133 return ARCH_X86
129- elsif ( arch =~ /(x86_64|amd64)/i )
134+ elsif arch =~ /(x86_64|amd64)/i
130135 return ARCH_X86
131136 end
132137 end
0 commit comments