2016-10-29 4 views
0

アンドロイドで位置を偽造したいです。アンドロイドには、PendingIntentを使って場所を取得する方法があります。次に例を示しますとき、新しい場所の変更Xposed:PendingIntentを使用してメソッドをフックする方法

 LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); 
     String proximitys = "ACTION"; 
     IntentFilter filter = new IntentFilter(proximitys); 
     LocationReceiver mReceiver = new LocationReceiver(); 
     registerReceiver(mReceiver, filter); 
     Intent intent = new Intent(proximitys); 
     PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, 
       intent, PendingIntent.FLAG_CANCEL_CURRENT); 

     service.requestLocationUpdates("network", 1000, 0.001f, proximityIntent); 

そしてBroadcastReceiverがイベントを受信します:だから

public class LocationReceiver extends BroadcastReceiver { 
    @Override 
    public void onReceive(Context context, Intent intent) { 
     //Do this when the system sends the intent 
     Bundle b = intent.getExtras(); 
     Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED); 
    } 
} 

、私は、このメソッドをフックしたいです。しかし、私はこの種の方法をフックする方法を知らない(それはPendingIntentを使用している)。 PendingIntentには「ある未来」のデータがあるため、いつ発生するのか分かりません。したがって、PendingIntentにはまだデータがありませんので、方法requestLocationUpdatesの前と後の両方をフックすることは機能していないようです。

どうすればいいですか?

答えて

0

保留中のインテントではなく、ブロードキャストレシーバーをインターセプトする必要があります。 LocationReceiver.onReceiveを傍受して、インテントの内容を変更することができます。

onReceiveを傍受するには、beforeHookedMethodを定義します。インテント(params.args[1])を取得し、そのエキストラ(intent.replaceExtras(bundle))を変更するには、そのパラメータ(MethodHookParam params)を使用します。

あなたの新しいバンドルが同じキー(android.location.LocationManager.KEY_LOCATION_CHANGED)を持っていることを確認し、その値として、あなたはあなた自身の場所を設定することができます

Location loc = new Location("yourprovider"); 
loc.setLatitude(66.6); 
loc.setLongitude(66.6); 
関連する問題