|
|
@@ -1,10 +1,16 @@
|
|
|
package com.example.smshook;
|
|
|
|
|
|
import android.app.Application;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.provider.Telephony;
|
|
|
+import android.telephony.SmsMessage;
|
|
|
import android.util.Log;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
import de.robv.android.xposed.IXposedHookInitPackageResources;
|
|
|
import de.robv.android.xposed.IXposedHookLoadPackage;
|
|
|
@@ -26,13 +32,54 @@ public class XposedInit implements IXposedHookLoadPackage, IXposedHookZygoteInit
|
|
|
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
|
|
|
Log.i(TAG, "handleLoadPackage: " + lpparam.packageName);
|
|
|
XposedBridge.log("SmsHook handleLoadPackage");
|
|
|
- switch (lpparam.packageName) {
|
|
|
- case "com.example.mysmsapp":
|
|
|
- new SmsHook().handleLoadPackage(lpparam);
|
|
|
- break;
|
|
|
- case "com.google.android.apps.messaging":
|
|
|
- new MessageHook().handleLoadPackage(lpparam);
|
|
|
- break;
|
|
|
+// switch (lpparam.packageName) {
|
|
|
+// case "com.example.mysmsapp":
|
|
|
+// new SmsHook().handleLoadPackage(lpparam);
|
|
|
+// break;
|
|
|
+// case "com.google.android.apps.messaging":
|
|
|
+// new MessageHook().handleLoadPackage(lpparam);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ Class<?> clazz = XposedHelpers.findClass("ioy", lpparam.classLoader);
|
|
|
+ XposedHelpers.findAndHookMethod(clazz, "onReceive", Context.class, Intent.class, new XC_MethodHook() {
|
|
|
+ @Override
|
|
|
+ protected void beforeHookedMethod(MethodHookParam param) {
|
|
|
+ XposedBridge.log("SmsReceiverHook");
|
|
|
+
|
|
|
+
|
|
|
+ Intent intent = (Intent) param.args[1];
|
|
|
+ String packageName = intent.getPackage();
|
|
|
+ String action = intent.getAction();
|
|
|
+ String type = intent.getType();
|
|
|
+ String scheme = intent.getScheme();
|
|
|
+ String dataString = intent.getDataString();
|
|
|
+ String category = "";
|
|
|
+ if (intent.getCategories() != null) {
|
|
|
+ for (String c : intent.getCategories()) {
|
|
|
+ category += c + ", ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.i("SmsReceiverHook", "packageName=" + packageName + ", action=" + action + ", type=" + type + ", scheme=" + scheme + ", dataString=" + dataString + ", category=" + category);
|
|
|
+ printExtras(intent.getExtras());
|
|
|
+ if (Objects.equals(action, "android.provider.Telephony.SMS_RECEIVED") ||
|
|
|
+ Objects.equals(action, "android.provider.Telephony.SMS_DELIVER")) {
|
|
|
+ SmsMessage[] messages = Telephony.Sms.Intents.getMessagesFromIntent(intent);
|
|
|
+ if (messages != null) {
|
|
|
+ String body = messages[0].getMessageBody();
|
|
|
+ byte[] pdu0 = SmsUtils.createFakeSms("3456", "Your Messenger verification code is G-" + body);
|
|
|
+ Object[] pdus = new Object[1];
|
|
|
+ pdus[0] = pdu0;
|
|
|
+ intent.putExtra("pdus", pdus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Throwable e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -41,4 +88,22 @@ public class XposedInit implements IXposedHookLoadPackage, IXposedHookZygoteInit
|
|
|
Log.i(TAG, "initZygote");
|
|
|
XposedBridge.log("SmsHook initZygote");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public void printExtras(Bundle bundle) {
|
|
|
+ if (bundle != null) {
|
|
|
+ for (String key : bundle.keySet()) {
|
|
|
+ Object value = bundle.get(key);
|
|
|
+ Log.d("SmsBundle", "key=" + key + ", value=" + value.toString() + ", class=" + value.getClass().getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void printPdu(byte[] bytes) {
|
|
|
+ String s = "";
|
|
|
+ for (byte b : bytes) {
|
|
|
+ s += b + ", ";
|
|
|
+ }
|
|
|
+ Log.d("PDU", s);
|
|
|
+ }
|
|
|
}
|