Configuration
The simplest way to initialize Malwarelytics for Android is in Application.onCreate() system callback.
The absolute minimum required for integration is to provide apiUsername, apiPassword
and apiSignaturePublicKey in AppProtectionConfig.Builder.
An example of minimum initialization code:
class MyApplication : Application() {
override fun onCreate() {
// Prepare minimum configuration
val config = AppProtectionConfig.Builder(appContext)
.apiUsername(API_USERNAME)
.apiPassword(API_PASSWORD)
.apiSignaturePublicKey(API_SIGNATURE_PUBLIC_KEY)
.clientAppUserId(INTERNAL_CLIENT_USER_ID) // Use if the internal user ID is available at config time
.clientAppDeviceId(INTERNAL_CLIENT_DEVICE_ID) // Use if the internal device ID is available at config time
.antivirusConfig(
AntivirusConfig.Builder()
.build()
)
.raspConfig(
RaspConfig.Builder()
.signatureHash(SIGNATURE_HASH)
.build()
)
.build()
// Initialize AppProtection class
val appProtection = AppProtection.getInstance()
appProtection.initializeAsync(config, object: AppProtection.InitializationObserver {
// App Protection is fully ready to be used now
override fun onInitialized() {
// Setup internal IDs when you are able to obtain them
appProtection.updateClientAppUserId(INTERNAL_CLIENT_USER_ID)
appProtection.updateClientAppDeviceId(INTERNAL_CLIENT_DEVICE_ID)
}
})
// ...
}
}
You can find API_USERNAME, API_PASSWORD and API_SIGNATURE_PUBLIC_KEY values in the Malwarelytics console.
Use some user identifiers you understand for INTERNAL_CLIENT_USER_ID and/or INTERNAL_CLIENT_DEVICE_ID.
To obtain the SIGNATURE_HASH value,
please follow the Repackaging Detection guide.
See RASP feature overview for a detailed documentation of available detections and security features.
Configuration-Reference
Reference list of all configuration options.
AppProtectionConfig Options
Global configuration options for AppProtection.
val config = AppProtectionConfig.Builder(appContext)
// configuration for Antivirus
.antivirusConfig(antivirusConfig)
// configuration for RASP
.raspConfig(raspConfig)
// API username
.apiUsername(username)
// API password
.apiPassword(password)
// API signature public key
.apiSignaturePublicKey(apiSignaturePublicKey)
// change update server and its SSL pinning
.updateServer(ServerConfiguration("https://...", "YT5Qad..."))
// set clientAppUserId
.clientAppUserId("SOME_CLIENT_USER_ID_VALUE")
// set clientAppDeviceId
.clientAppDeviceId("SOME_CLIENT_DEVICE_ID_VALUE")
// configuration of customer grouping and naming in the web application
.customerGroupingConfig(customerGroupingConfig)
.build()
AntivirusConfig Options
Configuration options for Anti-Malware component of AppProtection.
val antivirusConfig = AntivirusConfig.Builder()
// use default built in suggestions
.useDefaultSuggestions(Boolean)
// set factory for foreground service notification
.setForegroundServiceNotificationFactory(notificationFactory)
// set detailed configuration of smart protection
.smartProtectionConfig(smartProtectionConfig)
// change default threat mitigation UI - screen & notification
.setThreatMitigationUIConfig(threatMitigationUIConfig)
.build()
Threat Mitigation UI Config
Configuration options for threat mitigation that is a part of Anti-Malware.
val threatMitigationUIConfig = AntivirusConfig.ThreatMitigationUIConfig.Builder()
.notificationSmallIcon(R.drawable.my_notification_icon)
.notificationChannelId("AV-CHANNEL")
.screenDeleteIcon(R.drawable.custom_delete_icon)
.screenSettingsIcon(R.drawable.custom_settings_icon)
.screenTheme(R.style.CustomThreatScreenTheme)
.customLocalization("cs")
.build()
Smart Protection Config
Configuration options for smart protection that is a part of Anti-Malware.
val smartProtectionConfig = AntivirusConfig.SmartProtectionConfig.Builder()
.smartProtectionEnabled(true)
.silentModeEnabled(true)
.smartProtectionIntervalHours(72)
.performInitialFirstUpdate(true)
.build()
RaspConfig Options
Configuration options for RASP component of AppProtection.
val raspConfig = RaspConfig.Builder()
.checkEmulator(Boolean)
.exitOnEmulator(Boolean)
.checkRoot(Boolean)
.exitOnRoot(Boolean)
.exitOnRootMinConfidence(Float) // value from 0.0 to 1.0
.checkDebugger(Boolean)
.exitOnDebugger(Boolean)
.checkRepackaging(Boolean)
.exitOnRepackaging(Boolean)
.signatureHash(String) // SHA-1 of signing certificate(s)
.checkScreenSharing(Boolean)
.exitOnScreenSharing(Boolean)
.blockScreenshots(Boolean)
.blockScreenReaders(Boolean)
.allowedScreenReaders(Collection<RaspConfig.ApkAllowlist>)
.customProcessName(String) // when set, turns of useStealthyProcessName
.useStealthyProcessName(Boolean)
.blockTapjacking(Boolean)
.blockTapjackingSensitivity(ThreatIndex)
.checkHttpProxy(Boolean)
.exitOnHttpProxy(Boolean)
.build()
Customer Grouping and Naming Options
Configuration options for customer grouping on web console.
val customerGroupingConfig = AppProtectionConfig.CustomerGroupingConfig.Builder()
.sourcePackageName(String) // max len 255 characters
.appPackageName(String) // max len 255 characters
.audienceGroupId(String) // max len 20 characters
.build()