Android APP合规检查工具
2024-1-14 23:25:41 Author: 哆啦安全(查看原文) 阅读量:7 收藏

一个通过拦截Java方法调用用以检测应用是否合规的工具
一、Android Studio中引用插件miit-rule-checker

1.添加mavenCentral

allprojects {    repositories {        google()        jcenter()        mavenCentral()    }}

2.添加Gradle依赖

dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    implementation 'com.android.support:appcompat-v7:27.1.1'    implementation 'com.android.support.constraint:constraint-layout:1.1.2'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'com.android.support.test:runner:1.0.2'    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.alibaba:fastjson:2.0.23' implementation("org.greenrobot:eventbus:3.3.1") implementation 'com.appsflyer:af-android-sdk:6.9.0' implementation "com.android.installreferrer:installreferrer:2.2" implementation("org.greenrobot:eventbus:3.3.1")
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.10' implementation 'io.github.loper7:miit-rule-checker:0.2.0'}

二、使用方法

1.检查APP内是否存在不合规的方法调用

检查MIITRuleChecker内置的不合规的方法

MIITRuleChecker.checkDefaults()
如果内置的方法不满足当前需求,可自定义方法添加到list中进行检查;
比如新增一个 MainActivity 的 onCreate 方法的调用检查;
val list = MIITMethods.getDefaultMethods()list.add(MainActivity::class.java.getDeclaredMethod("onCreate" , Bundle::class.java))MIITRuleChecker.check(list)
如果想检查多个内置方法外的方法,只需要创建一个新的集合,往集合里放你想检查的方法member,然后传入MIITRuleChecker.check()内即可。

2.检查指定方法调用并查看调用栈堆

//查看 WifiInfo class 内 getMacAddress 的调用栈堆MIITRuleChecker.check(MIITMethods.WifiInfo.getMacAddress)
3.检查一定时间内指定方法调用次数统计
 //多个方法统计 (deadline 为从方法调用开始到多少毫秒后截至统计) val list = mutableListOf<Member?>().apply {          add(MIITMethods.LocationManager.getLastKnownLocation)          add(MIITMethods.LocationManager.requestLocationUpdates)          add(MIITMethods.Secure.getString)      }MIITMethodCountChecker.startCount( 20 * 1000,list)
//单个方法统计(deadline 为从方法调用开始到多少毫秒后截至统计)MIITMethodCountChecker.startCount(20 * 1000,MIITMethods.LocationManager.getLastKnownLocation)
特别注意:
检查完成并完成整改后务必移除方法miit-rule-checker库内的所有方法调用,将库一起移除最好
关注"哆啦安全"微信公众号

三、内置方法表

https://github.com/loper7/miit-rule-checker
推荐阅读
APP隐私合规
移动APP安全合规
移动端APP隐私合规检测
移动端漏洞/安全检测与隐私合规解决方案
使用Hook和插桩技术实现快速排查APP隐私合规问题

APP逆向分析/渗透测试/安全检测/隐私合规如何选择手机机型或系统

Gradle Plugin+Transform+ASM Hook并替换隐私方法调用(彻底解决隐私不合规问题)


文章来源: http://mp.weixin.qq.com/s?__biz=Mzg2NzUzNzk1Mw==&mid=2247496668&idx=1&sn=d4e98cd3d25b5ecd3037a59d9170f57d&chksm=cfee847eba00b6787a49279500942f20bce2bfa7b1e116215a170aa215a3e97bd3ac103a0bce&scene=0&xtrack=1#rd
如有侵权请联系:admin#unsafe.sh