Skip to content

Commit

Permalink
getScanResults隐私调用拦截
Browse files Browse the repository at this point in the history
  • Loading branch information
Peakmain committed May 24, 2022
1 parent 9e2afec commit 6231aa7
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ dependencies {
}
monitorPlugin {
whiteList = [
"com.peakmain.asmactualcombat.utils.TestUtils",
//"com.peakmain.asmactualcombat.utils.TestUtils",
"com.peakmain.plugin"
]
methodStatus = 2
methodStatus = 1
disableStackMapFrame = false
interceptPackageName = "com.peakmain"
}
13 changes: 12 additions & 1 deletion app/src/main/java/com/peakmain/asmactualcombat/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
Expand All @@ -12,6 +13,7 @@

import com.peakmain.ui.utils.LogUtils;

import java.util.List;
import java.util.Locale;

/**
Expand Down Expand Up @@ -119,7 +121,16 @@ public final boolean a(ConnectivityManager var1) {
}
}


public List<ScanResult> getScanResults() {
if(this.mWifiManager!=null){
List<ScanResult> var1 = this.mWifiManager.getScanResults();
for (ScanResult scanResult : var1) {
LogUtils.e(scanResult.BSSID);
}
return var1;
}
return null;
}
public static String getAndroidId(Context context) {
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MonitorHookMethodConfig {
* 获取connectionInfo
*/
HashMap<String, String> connectionInfoMap = new HashMap<>()
connectionInfoMap.put(MethodFieldUtils.EMPTY_WIFI_INFO_DESC, MethodFieldUtils.EMPTY_WIFI_INFO_WIFI_INFO_DESC)
connectionInfoMap.put(MethodFieldUtils.EMPTY_WIFI_INFO_DESC, MethodFieldUtils.NEW_WIFI_INFO_WIFI_INFO_DESC)
MethodCalledBean connectionInfo = new MethodCalledBean(
MethodFieldUtils.WIFI_MANAGER_CLASS,
MethodFieldUtils.GET_CONNECTION_INFO_METHOD_NAME,
Expand All @@ -62,7 +62,7 @@ class MonitorHookMethodConfig {
* 获取Mac
*/
HashMap<String, String> macAddressMap = new HashMap<>()
macAddressMap.put(MethodFieldUtils.EMPTY_STRING_DESC, MethodFieldUtils.EMPTY_STRING_WIFI_INFO_DESC)
macAddressMap.put(MethodFieldUtils.EMPTY_STRING_DESC, MethodFieldUtils.NEW_STRING_WIFI_INFO_DESC)
MethodCalledBean macAddress = new MethodCalledBean(
MethodFieldUtils.WIFI_INFO_CLASS,
MethodFieldUtils.GET_MAC_ADDRESS_METHOD_NAME,
Expand All @@ -77,7 +77,7 @@ class MonitorHookMethodConfig {
* IP地址
*/
HashMap<String, String> ipAddressMap = new HashMap<>()
ipAddressMap.put(MethodFieldUtils.EMPTY_INT_DESC, MethodFieldUtils.EMPTY_INT_WIFI_INFO_DESC)
ipAddressMap.put(MethodFieldUtils.EMPTY_INT_DESC, MethodFieldUtils.NEW_INT_WIFI_INFO_DESC)
MethodCalledBean ipAddress = new MethodCalledBean(
MethodFieldUtils.WIFI_INFO_CLASS,
MethodFieldUtils.GET_IP_ADDRESS_METHOD_NAME,
Expand All @@ -103,6 +103,19 @@ class MonitorHookMethodConfig {
androidIdMap
)
addMethodCalledBean(androidId)

HashMap<String, String> scanResultMap = new HashMap<>()
scanResultMap.put(MethodFieldUtils.EMPTY_LIST_DESC, MethodFieldUtils.NEW_EMPTY_LIST_DESC)
MethodCalledBean scanResults = new MethodCalledBean(
MethodFieldUtils.WIFI_MANAGER_CLASS,
MethodFieldUtils.GET_SCAN_RESULTS_METHOD_NAME,
MethodFieldUtils.EMPTY_RETURN_LIST,
MethodFieldUtils.NEW_METHOD_OWNER,
MethodFieldUtils.GET_SCAN_RESULTS_METHOD_NAME,
MethodFieldUtils.STATIC_OPCODE,
scanResultMap
)
addMethodCalledBean(scanResults)
}

static void addMethodCalledBean(MethodCalledBean methodCalledBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,26 @@ class MethodFieldUtils {
static String GET_MAC_ADDRESS_METHOD_NAME = "getMacAddress"
static String GET_IP_ADDRESS_METHOD_NAME = "getIpAddress"
static String GET_STRING_METHOD_NAME = "getString"
static String GET_SCAN_RESULTS_METHOD_NAME = "getScanResults"
//desc
static final String EMPTY_STRING_DESC = "()Ljava/lang/String;"
static final String EMPTY_STRING_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiInfo;)Ljava/lang/String;"
static final String EMPTY_LIST_DESC = "()Ljava/util/List;"
static final String NEW_EMPTY_LIST_DESC = "(Landroid/net/wifi/WifiManager;)Ljava/util/List;"
static final String NEW_STRING_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiInfo;)Ljava/lang/String;"
static final String NEW_EMPTY_STRING_TELEPHONY_DESC = "(Landroid/telephony/TelephonyManager;)Ljava/lang/String;"
static final String INT_STRING_DESC = "(I)Ljava/lang/String;"
static final String NEW_INT_STRING_TELEPHONY_DESC = "(Landroid/telephony/TelephonyManager;I)Ljava/lang/String;"
static String[] EMPTY_INT_RETURN_STRING_DESC = [EMPTY_STRING_DESC, INT_STRING_DESC]
static final String EMPTY_WIFI_INFO_DESC = "()Landroid/net/wifi/WifiInfo;"
static final String EMPTY_WIFI_INFO_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiManager;)Landroid/net/wifi/WifiInfo;"
static final String NEW_WIFI_INFO_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiManager;)Landroid/net/wifi/WifiInfo;"
static String[] EMPTY_RETURN_WIFI_INFO_DESC = [EMPTY_WIFI_INFO_DESC]
static String[] EMPTY_RETURN_STRING_DESC = [EMPTY_STRING_DESC]
static final String EMPTY_INT_DESC = "()I"
static final String EMPTY_INT_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiInfo;)I"
static final String NEW_INT_WIFI_INFO_DESC = "(Landroid/net/wifi/WifiInfo;)I"
static String[] EMPTY_RETURN_INT_DESC = [EMPTY_INT_DESC]
static final String CONTENTRESOLVER_STRING_DESC = "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;"
static String[] CONTENTRESOLVER_STRING_RETURN_STRING_DESC = [CONTENTRESOLVER_STRING_DESC]

static String[] EMPTY_RETURN_LIST=[EMPTY_LIST_DESC]

//获取时间属性
static String getTimeFieldName(String methodName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class MonitorMethodCalledReplaceAdapter extends MonitorDefalutMethodAdapter {
if (!monitorConfig.whiteList.contains(mClassName) && !monitorConfig.exceptSet.contains(mClassName)&&methodReplaceBeans.containsKey(desc)) {
println("调用方法的class:" + mClassName + ",方法的名字:" + name + ",方法的描述符:" + descriptor)
MethodCalledBean bean = methodReplaceBeans.get(desc)
if(name=="getScanResults"){
println("getScanResults:"+bean.newOpcode+","+bean.newMethodOwner+","+bean.newMethodName+","+bean.newMethodDescriptor.get(descriptor))
}
super.visitMethodInsn(bean.newOpcode, bean.newMethodOwner, bean.newMethodName, bean.newMethodDescriptor.get(descriptor), false)
} else {
super.visitMethodInsn(opcodeAndSource, owner, name, descriptor, isInterface)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4a16b8ad02b86449f53725f01c849ed6
b4c17a7fd0b505c4dc894880d98f27cd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57f3ae37074152cecd2ad4b6273f09cdba093a18
137e1ee3b23a4079e5919c42ea42c3eea0c29069
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ffd4220993e477a9fc630bfebc781c9
f408535cd0f2cea5899204f98c7b5e9b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1477c6e37ceff13ffd3ac10822e53cc1ac6337b6
5a08f219ef3f743b0862047a6a203610fbc26f8e
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f3dfd339e1e9f4c2036adb915b8bb9f7
79995d67cd36046edfcb9139d9b2345d
Original file line number Diff line number Diff line change
@@ -1 +1 @@
31b89a248bc94e23c6d6758725e655f65b01a37c
98401e6af6769b357c21a838321b6797ee62c7e7
Binary file modified repo/com/peakmain/android.plugin/1.0.0/android.plugin-1.0.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f0af6757e0663a1dfe8c875a649c88d5
23c16c1a1bd5ef8e30fbda3d15775866
Original file line number Diff line number Diff line change
@@ -1 +1 @@
645417602c40838124e6f8126a59c281aa92b5b3
8b3de2a58c940a1bf96b8f9fdc57d189d270f13c
2 changes: 1 addition & 1 deletion repo/com/peakmain/android.plugin/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<versions>
<version>1.0.0</version>
</versions>
<lastUpdated>20220519042926</lastUpdated>
<lastUpdated>20220524013406</lastUpdated>
</versioning>
</metadata>
2 changes: 1 addition & 1 deletion repo/com/peakmain/android.plugin/maven-metadata.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0e65b780ada1c2e13ca62dd46fbebf14
6d9d64fa6fd79490f4dcbef88761e8a5
2 changes: 1 addition & 1 deletion repo/com/peakmain/android.plugin/maven-metadata.xml.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e7324003c7ee47f7203b1b209867228fbe5be483
c39cd021c6cf90315f8cefb0ca2e010e233528e2
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
import android.content.ContentResolver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.peakmain.sdk.constants.SensorsDataConstants;
import com.peakmain.sdk.interfaces.OnReplaceMethodListener;

import java.net.Inet4Address;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -183,4 +182,9 @@ public static String getString(ContentResolver resolver, String name) {
return "";
}

public static List<ScanResult> getScanResults(WifiManager wifiManager) {


return new ArrayList<>();
}
}

0 comments on commit 6231aa7

Please sign in to comment.