Android APP合规检查工具

admin 2024年1月15日09:57:54评论29 views字数 2036阅读6分47秒阅读模式
一个通过拦截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()内即可。
Android APP合规检查工具

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

//查看 WifiInfo class 内 getMacAddress 的调用栈堆MIITRuleChecker.check(MIITMethods.WifiInfo.getMacAddress)
Android APP合规检查工具
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)
Android APP合规检查工具
特别注意:
检查完成并完成整改后务必移除方法miit-rule-checker库内的所有方法调用,将库一起移除最好

三、内置方法表

Android APP合规检查工具

Android APP合规检查工具

https://github.com/loper7/miit-rule-checker

原文始发于微信公众号(哆啦安全):Android APP合规检查工具

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年1月15日09:57:54
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Android APP合规检查工具https://cn-sec.com/archives/2393697.html

发表评论

匿名网友 填写信息