@@ -49,31 +49,34 @@ def http_verb
49
49
50
50
# Try to auto detect the target architecture and platform
51
51
#
52
- # @param [String ] The available targets
52
+ # @param [Array ] The available targets
53
53
# @return [Msf::Module::Target, nil] The detected target or nil
54
54
def auto_target ( available_targets )
55
- if http_verb == 'HEAD' then
55
+ if http_verb == 'HEAD'
56
56
print_status ( "Sorry, automatic target detection doesn't work with HEAD requests" )
57
57
else
58
58
print_status ( "Attempting to automatically select a target..." )
59
59
res = query_serverinfo
60
- if not ( plat = detect_platform ( res ) )
60
+ plat = detect_platform ( res )
61
+ unless plat
61
62
print_warning ( 'Unable to detect platform!' )
62
63
return nil
63
64
end
64
65
65
- if not ( arch = detect_architecture ( res ) )
66
+ arch = detect_architecture ( res )
67
+ unless arch
66
68
print_warning ( 'Unable to detect architecture!' )
67
69
return nil
68
70
end
69
71
70
72
# 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 }
72
74
end
73
75
74
76
# no matching target found, use Java as fallback
75
77
java_targets = available_targets . select { |t | t . name =~ /^Java/ }
76
- return java_targets [ 0 ]
78
+
79
+ java_targets [ 0 ]
77
80
end
78
81
79
82
# Query the server information from HtmlAdaptor
@@ -102,6 +105,7 @@ def query_serverinfo
102
105
103
106
# Try to autodetect the target platform
104
107
#
108
+ # @param res [Rex::Proto::Http::Response] the http response where fingerprint platform from
105
109
# @return [String, nil] The target platform or nil
106
110
def detect_platform ( res )
107
111
if res && res . body =~ /<td.*?OSName.*?(Linux|FreeBSD|Windows).*?<\/ td>/m
@@ -120,13 +124,14 @@ def detect_platform(res)
120
124
121
125
# Try to autodetect the target architecture
122
126
#
127
+ # @param res [Rex::Proto::Http::Response] the http response where fingerprint architecture from
123
128
# @return [String, nil] The target architecture or nil
124
129
def detect_architecture ( res )
125
130
if res && res . body =~ /<td.*?OSArch.*?(x86|i386|i686|x86_64|amd64).*?<\/ td>/m
126
131
arch = $1
127
- if ( arch =~ /(x86|i386|i686)/i )
132
+ if arch =~ /(x86|i386|i686)/i
128
133
return ARCH_X86
129
- elsif ( arch =~ /(x86_64|amd64)/i )
134
+ elsif arch =~ /(x86_64|amd64)/i
130
135
return ARCH_X86
131
136
end
132
137
end
0 commit comments