HMS Core的安全检测服务应用安全检测能力可以帮助App开发者获取所运行设备上的恶意应用列表。对于携带病毒的应用,检测率高达99%,同时还拥有基于行为检测未知威胁的能力。App可根据检测结果,决定是否限制用户在App内支付等操作。
HMS Core的安全检测服务恶意URL检测能力可以判断用户访问的URL是否为恶意网址,对于恶意网址,选择提示或拦截用户的访问风险。
HMS Core的安全检测服务恶意Wi-Fi检测能力检测尝试连接的Wi-Fi及路由器特征,分析当前尝试访问的网络情况,实时反馈Wi-Fi检测结果,当应用获取尝试连接的Wi-Fi存在ARP攻击、中间人攻击、DNS劫持等攻击时,可以阻断操作或者进一步让用户认证确认,帮助防范来自恶意Wi-Fi的恶意行为攻击。
HMS Core安全检测服务还拥有系统完整性检测、虚假用户检测能力,能够帮助开发者快速提升应用安全性,集成过程简单高效,下面是详细的接入教程。 Demo演示
应用安全检测
恶意URL检测
恶意Wi-Fi检测 开发步骤 1开发准备
详细准备步骤可参考华为开发者联盟官网。 2应用安全检测API 2.1调用AppsCheck API
您可直接调用SafetyDetectClient的getMaliciousAppsList获取恶意应用列表:
private void invokeGetMaliciousApps() {
SafetyDetectClient appsCheckClient = SafetyDetect.getClient(MainActivity.this);
Task task = appsCheckClient.getMaliciousAppsList();
task.addOnSuccessListener(new OnSuccessListener<MaliciousAppsListResp>() {
@Override
public void onSuccess(MaliciousAppsListResp maliciousAppsListResp) {
// Indicates that communication with the service was successful.
// Use resp.getMaliciousApps() to get malicious apps data.
List<MaliciousAppsData> appsDataList = maliciousAppsListResp.getMaliciousAppsList();
// Indicates get malicious apps was successful.
if(maliciousAppsListResp.getRtnCode() == CommonCode.OK) {
if (appsDataList.isEmpty()) {
// Indicates there are no known malicious apps.
Log.i(TAG, "There are no known potentially malicious apps installed.");
} else {
Log.i(TAG, "Potentially malicious apps are installed!");
for (MaliciousAppsData maliciousApp : appsDataList) {
Log.i(TAG, "Information about a malicious app:");
// Use getApkPackageName() to get APK name of malicious app.
Log.i(TAG, "APK: " + maliciousApp.getApkPackageName());
// Use getApkSha256() to get APK sha256 of malicious app.
Log.i(TAG, "SHA-256: " + maliciousApp.getApkSha256());
// Use getApkCategory() to get category of malicious app.
// Categories are defined in AppsCheckConstants
Log.i(TAG, "Category: " + maliciousApp.getApkCategory());
}
}
}else{
Log.e(TAG,"getMaliciousAppsList failed: "+maliciousAppsListResp.getErrorReason());
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
// An error occurred while communicating with the service.
if (e instanceof ApiException) {
// An error with the HMS API contains some
// additional details.
ApiException apiException = (ApiException) e;
// You can retrieve the status code using the apiException.getStatusCode() method.
Log.e(TAG, "Error: " + SafetyDetectStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " + apiException.getStatusMessage());
} else {
// A different, unknown type of error occurred.
Log.e(TAG, "ERROR: " + e.getMessage());
}
}
});
}
3恶意URL检测API 3.1初始化URLCheck API
在使用URLCheck API前,必须调用initUrlCheck方法进行接口初始化,并且需要等待初始化完成后再进行接下来的接口调用,示例代码如下:
public class UrlCheckThreat {
//此类型URL被标记为包含潜在有害应用的页面的URL(篡改首页、网页挂马、恶意应用下载链接等)
public static final int MALWARE = 1;
// 这种类型的URL被标记为钓鱼、欺诈网站
public static final int PHISHING = 3;
}
final EditText testRes = getActivity().findViewById(R.id.fg_call_urlResult);
List<UrlCheckThreat> list = urlCheckResponse.getUrlCheckResponse();
if (list.isEmpty()) {
testRes.setText("ok");
}
else{
for (UrlCheckThreat threat : list) {
int type = threat.getUrlCheckResult();
}
}