xiongzhu 1 سال پیش
والد
کامیت
bf00ec900f

BIN
.idea/copilot/chatSessions/00000000000.xd


BIN
.idea/copilot/chatSessions/blobs/version


+ 0 - 53
.idea/copilot/chatSessions/xd.lck

@@ -1,53 +0,0 @@
-Private property of Exodus: 16432@DrewdeMBP.lan
-
-jetbrains.exodus.io.LockingManager.lock(LockingManager.kt:88)
-jetbrains.exodus.io.LockingManager.lock(LockingManager.kt:39)
-jetbrains.exodus.io.FileDataWriter.lock(FileDataWriter.kt:70)
-jetbrains.exodus.log.Log.tryLock(Log.kt:804)
-jetbrains.exodus.log.Log.<init>(Log.kt:117)
-jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:117)
-jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:81)
-jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:77)
-jetbrains.exodus.env.Environments$newInstance$4.invoke(Environments.kt:46)
-jetbrains.exodus.env.Environments$newInstance$4.invoke(Environments.kt:46)
-jetbrains.exodus.env.Environments.prepare(Environments.kt:120)
-jetbrains.exodus.env.Environments.newInstance(Environments.kt:46)
-kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore(EntityStoreHelper.kt:40)
-kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore(EntityStoreHelper.kt:31)
-kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore$default(EntityStoreHelper.kt:30)
-com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.initStore(XdChatSessionPersistenceService.kt:115)
-com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.<init>(XdChatSessionPersistenceService.kt:22)
-com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.<init>(XdChatSessionPersistenceService.kt:15)
-com.github.copilot.chat.session.persistence.ChatSessionPersistenceServiceKt.ChatSessionPersistenceService(ChatSessionPersistenceService.kt:43)
-com.github.copilot.chat.session.persistence.ChatSessionPersistenceServiceKt.chatSessionsPersistenceService(ChatSessionPersistenceService.kt:53)
-com.github.copilot.chat.session.ChatSessionManager.<init>(ChatSessionManager.kt:45)
-com.github.copilot.chat.session.ChatSessionManager.<init>(ChatSessionManager.kt:25)
-com.github.copilot.chat.window.CopilotChatToolWindow.onCopilotReady(CopilotChatToolWindow.kt:133)
-com.github.copilot.chat.window.CopilotChatToolWindow.access$onCopilotReady(CopilotChatToolWindow.kt:40)
-com.github.copilot.chat.window.CopilotChatToolWindow$initCopilotStatusListener$1.invoke(CopilotChatToolWindow.kt:118)
-com.github.copilot.chat.window.CopilotChatToolWindow$initCopilotStatusListener$1.invoke(CopilotChatToolWindow.kt:115)
-com.github.copilot.status.CopilotAuthStatusKt.subscribeToCopilotAuthStatus$lambda$0(CopilotAuthStatus.kt:44)
-com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:699)
-com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:663)
-com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:422)
-com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:401)
-com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
-com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:460)
-jdk.proxy8/jdk.proxy8.$Proxy215.onCopilotStatus(Unknown Source)
-com.github.copilot.status.CopilotStatusService.notifyApplication(CopilotStatusService.java:76)
-com.github.copilot.status.CopilotStatusService.notifyApplication(CopilotStatusService.java:64)
-com.github.copilot.github.GitHubAuthStartupActivity.handleAuthNotifications(GitHubAuthStartupActivity.java:54)
-com.github.copilot.github.GitHubAuthStartupActivity.execute(GitHubAuthStartupActivity.java:35)
-com.intellij.ide.startup.impl.StartupManagerImplKt$launchActivity$1$1.invokeSuspend(StartupManagerImpl.kt:534)
-com.intellij.ide.startup.impl.StartupManagerImplKt$launchActivity$1$1.invoke(StartupManagerImpl.kt)
-com.intellij.ide.startup.impl.StartupManagerImplKt$launchActivity$1$1.invoke(StartupManagerImpl.kt)
-kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
-kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:167)
-kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
-com.intellij.ide.startup.impl.StartupManagerImplKt$launchActivity$1.invokeSuspend(StartupManagerImpl.kt:532)
-kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
-kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
-kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
-kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
-kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
-kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

+ 0 - 1
.idea/misc.xml

@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
   <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 6 - 2
app/build.gradle

@@ -26,6 +26,9 @@ android {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
+    buildFeatures {
+        aidl = true
+    }
 }
 
 dependencies {
@@ -37,6 +40,7 @@ dependencies {
     testImplementation libs.junit
     androidTestImplementation libs.ext.junit
     androidTestImplementation libs.espresso.core
-
-    implementation 'de.robv.android.xposed:api:82'
+    implementation 'org.nanohttpd:nanohttpd:2.3.1'
+    compileOnly 'de.robv.android.xposed:api:82'
+    implementation 'com.android.volley:volley:1.2.1'
 }

+ 2 - 0
app/src/main/AndroidManifest.xml

@@ -2,6 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools">
 
+    <uses-permission android:name="android.permission.INTERNET" />
     <application
         android:allowBackup="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
@@ -11,6 +12,7 @@
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/Theme.SmsHook"
+        android:usesCleartextTraffic="true"
         tools:targetApi="31">
 
         <!-- 设置为 Xposed 模块 -->

+ 63 - 0
app/src/main/java/com/example/smshook/HttpServer.java

@@ -0,0 +1,63 @@
+package com.example.smshook;
+
+import java.util.List;
+import java.util.Map;
+
+import fi.iki.elonen.NanoHTTPD;
+
+public class HttpServer extends NanoHTTPD {
+
+    public interface OnRequestListener {
+        void onSmsRequest(String sender, String message);
+
+    }
+
+    private OnRequestListener listener;
+
+    public void setOnRequestListener(OnRequestListener listener) {
+        this.listener = listener;
+    }
+
+    private HttpServer(int port) {
+        super(port);
+    }
+
+    private HttpServer(String hostname, int port) {
+        super(hostname, port);
+    }
+
+    private static volatile HttpServer instance;
+
+    //double check locking
+    public static HttpServer getInstance(int port) {
+        if (instance == null) {
+            synchronized (HttpServer.class) {
+                if (instance == null) {
+                    instance = new HttpServer("0.0.0.0", port);
+                }
+            }
+        }
+        return instance;
+    }
+
+    @Override
+    public Response serve(IHTTPSession session) {
+        Map<String, List<String>> params = session.getParameters();
+        List<String> senders = params.get("sender");
+        if (senders == null || senders.isEmpty()) {
+            return newFixedLengthResponse("sender is required");
+        }
+        List<String> messages = params.get("message");
+        if (messages == null || messages.isEmpty()) {
+            return newFixedLengthResponse("message is required");
+        }
+        String sender = senders.get(0);
+        String message = messages.get(0);
+
+        if (listener != null) {
+            listener.onSmsRequest(sender, message);
+        }
+
+        return newFixedLengthResponse("ok");
+    }
+}

+ 51 - 3
app/src/main/java/com/example/smshook/MainActivity.java

@@ -1,7 +1,11 @@
 package com.example.smshook;
 
+import android.content.Context;
+import android.content.SharedPreferences;
 import android.os.Bundle;
-import android.widget.TextView;
+import android.preference.PreferenceManager;
+import android.widget.Button;
+import android.widget.EditText;
 import android.widget.Toast;
 
 import androidx.activity.EdgeToEdge;
@@ -10,6 +14,20 @@ import androidx.core.graphics.Insets;
 import androidx.core.view.ViewCompat;
 import androidx.core.view.WindowInsetsCompat;
 
+import com.android.volley.Request;
+import com.android.volley.RequestQueue;
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+import com.android.volley.toolbox.StringRequest;
+import com.android.volley.toolbox.Volley;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
 public class MainActivity extends AppCompatActivity {
 
 
@@ -23,7 +41,37 @@ public class MainActivity extends AppCompatActivity {
             v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
             return insets;
         });
-        TextView text = findViewById(R.id.text);
-        text.setText(XposedInit.test);
+
+        EditText etSender = findViewById(R.id.et_sender);
+        EditText etMessage = findViewById(R.id.et_message);
+        Button btnSave = findViewById(R.id.btn_save);
+
+        SharedPreferences pref = getSharedPreferences("sms_conf", Context.MODE_WORLD_READABLE);
+        etSender.setText(pref.getString("sender", ""));
+        etMessage.setText(pref.getString("message", ""));
+        btnSave.setOnClickListener(v -> {
+            SharedPreferences.Editor editor = pref.edit();
+            editor.putString("sender", etSender.getText().toString());
+            editor.putString("message", etMessage.getText().toString());
+            editor.apply();
+            Toast.makeText(this, "Sent", Toast.LENGTH_SHORT).show();
+
+            sendGetRequest("http://127.0.0.1:9898/?sender=" + etSender.getText().toString() + "&message=" + etMessage.getText().toString());
+        });
+
+    }
+
+    public void sendGetRequest(String url) {
+        RequestQueue queue = Volley.newRequestQueue(this);
+
+        StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
+                response -> {
+                    Toast.makeText(this, "Response is: " + response, Toast.LENGTH_SHORT).show();
+                }, error -> {
+
+            Toast.makeText(this, "That didn't work!", Toast.LENGTH_SHORT).show();
+        });
+
+        queue.add(stringRequest);
     }
 }

+ 34 - 17
app/src/main/java/com/example/smshook/MessageHook.java

@@ -1,22 +1,26 @@
 package com.example.smshook;
 
 import android.app.Activity;
+import android.content.Context;
+import android.content.IntentFilter;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
+import android.util.Log;
 import android.widget.Toast;
 
+import androidx.core.content.ContextCompat;
+
+import java.io.IOException;
+
 import de.robv.android.xposed.XC_MethodHook;
 import de.robv.android.xposed.XSharedPreferences;
+import de.robv.android.xposed.XposedBridge;
 import de.robv.android.xposed.XposedHelpers;
 import de.robv.android.xposed.callbacks.XC_LoadPackage;
 
 public class MessageHook {
-    private Activity activity;
-    private ClassLoader classLoader;
-    private Handler handler;
-
-    //single instance
 
     public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
         try {
@@ -24,25 +28,38 @@ public class MessageHook {
             XposedHelpers.findAndHookMethod(clazz, "onCreate", Bundle.class, new XC_MethodHook() {
                 @Override
                 protected void beforeHookedMethod(MethodHookParam param) {
-                    Toast.makeText((Activity) param.thisObject, "message hooked", Toast.LENGTH_LONG).show();
-                    activity = (Activity) param.thisObject;
-                    classLoader = activity.getClassLoader();
-                    handler = new Handler(Looper.getMainLooper());
+                    Activity activity = (Activity) param.thisObject;
+                    Toast.makeText(activity, "message hooked", Toast.LENGTH_LONG).show();
+
+                    XSharedPreferences pref = new XSharedPreferences("com.example.smshook", "sms_conf");
+                    String sender = pref.getString("sender", "1");
+                    String message = pref.getString("message", "1");
 
-                    XSharedPreferences
+                    Class<?> receiverClazz = XposedHelpers.findClass("com.google.android.apps.messaging.shared.receiver.SmsDeliverReceiver", lpparam.classLoader);
+//                    try {
+//                        Object receiver = receiverClazz.newInstance();
+//                        XposedHelpers.callMethod(receiver, "onReceive", activity.getApplicationContext(), SmsUtils.getSmsIntent(sender, message));
+//                    } catch (Throwable e) {
+//                        e.printStackTrace();
+//                    }
 
-                    Class<?> receiverClazz = XposedHelpers.findClass("com.google.android.apps.messaging.shared.receiver.SmsDeliverReceiver", classLoader);
                     try {
-                        Object receiver = receiverClazz.newInstance();
-                        XposedHelpers.callMethod(receiver, "onReceive", activity.getApplicationContext(), SmsUtils.getSmsIntent("123", "123"));
-                        XposedInit.test = "bbb";
-                    } catch (Exception e) {
+                        HttpServer server = HttpServer.getInstance(9898);
+                        if (!server.wasStarted()) server.start();
+                        server.setOnRequestListener((s, m) -> {
+                            try {
+                                Object receiver = receiverClazz.newInstance();
+                                XposedHelpers.callMethod(receiver, "onReceive", activity.getApplicationContext(), SmsUtils.getSmsIntent(s, m));
+                            } catch (Throwable e) {
+                                e.printStackTrace();
+                            }
+                        });
+                    } catch (Throwable e) {
                         e.printStackTrace();
                     }
                 }
-
-
             });
+
         } catch (Throwable e) {
             e.printStackTrace();
         }

+ 5 - 0
app/src/main/java/com/example/smshook/SmsUtils.java

@@ -28,8 +28,13 @@ public class SmsUtils {
         }
         Intent intent = new Intent();
         intent.setAction("android.provider.Telephony.SMS_DELIVER");
+
+        intent.putExtra("android.telephony.extra.SUBSCRIPTION_INDEX", 1);
+        intent.putExtra("messageId", Long.valueOf((int) Math.floor(Math.random() * 100000000)));
         intent.putExtra("pdus", objArray);
         intent.putExtra("format", "3gpp");
+        intent.putExtra("android.telephony.extra.SLOT_INDEX", 1);
+        intent.putExtra("phone", 1);
         intent.putExtra("subscription", 1);
         return intent;
     }

+ 7 - 5
app/src/main/java/com/example/smshook/XposedInit.java

@@ -4,27 +4,28 @@ import android.app.Application;
 import android.util.Log;
 import android.widget.Toast;
 
+import java.io.IOException;
+
 import de.robv.android.xposed.IXposedHookInitPackageResources;
 import de.robv.android.xposed.IXposedHookLoadPackage;
 import de.robv.android.xposed.IXposedHookZygoteInit;
 import de.robv.android.xposed.XC_MethodHook;
+import de.robv.android.xposed.XposedBridge;
 import de.robv.android.xposed.XposedHelpers;
 import de.robv.android.xposed.callbacks.XC_InitPackageResources;
 import de.robv.android.xposed.callbacks.XC_LoadPackage;
 
 public class XposedInit implements IXposedHookLoadPackage, IXposedHookZygoteInit, IXposedHookInitPackageResources {
-    private static final String TAG = "XposedInit";
-
-    public static String test = "aaa";
+    private static final String TAG = "SmsHookXposedInit";
 
     @Override
     public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable {
-
     }
 
     @Override
     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);
@@ -37,6 +38,7 @@ public class XposedInit implements IXposedHookLoadPackage, IXposedHookZygoteInit
 
     @Override
     public void initZygote(StartupParam startupParam) throws Throwable {
-
+        Log.i(TAG, "initZygote");
+        XposedBridge.log("SmsHook initZygote");
     }
 }

+ 31 - 6
app/src/main/res/layout/activity_main.xml

@@ -7,14 +7,39 @@
     android:layout_height="match_parent"
     tools:context=".MainActivity">
 
-    <TextView
-        android:id="@+id/text"
+    <EditText
+        android:id="@+id/et_sender"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="Hello World!"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
+        android:layout_marginTop="40dp"
+        android:ems="12"
+        android:hint="Sender"
+        android:inputType="text"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
 
+    <EditText
+        android:id="@+id/et_message"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        android:ems="12"
+        android:hint="Message"
+        android:inputType="text"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/et_sender" />
+
+    <Button
+        android:id="@+id/btn_save"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="20dp"
+        android:text="Save"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/et_message" />
+
+
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 2 - 1
gradle.properties

@@ -18,4 +18,5 @@ android.useAndroidX=true
 # Enables namespacing of each library's R class so that its R class includes only the
 # resources declared in the library itself and none from the library's dependencies,
 # thereby reducing the size of the R class for that library
-android.nonTransitiveRClass=true
+android.nonTransitiveRClass=true
+android.defaults.buildfeatures.aidl=true