-
-
[原创]一个简单的安卓APT样本分析
-
发表于: 2022-4-3 20:59 6027
-
初学样本分析,这也是第一次安卓APT分析和第一次发文章,大佬勿喷。样本在附件中,压缩包密码为infected(国际惯例)。
Windows 11、JADX
攻击者在正常的源代码基础上添加了恶意代码,为了方便寻找恶意代码我在官网下载了原程序。以下是原程序(左)与被攻击者修改了的程序(右)在JADX中打开后的对比。
我在分析APK的时候喜欢先查看AndroidManifest.xml文件,能便于对程序行为有一个大概的了解。
从以上的第3至25行中可以发现,程序用到了很多权限,我们将被感染的APK的AndroidManifest.xml与原版的进行比对,可以发现增加了READ_CONTACTS
、READ_CALL_LOG
、RECORD_AUDIO
、ACCESS_WIFI_STATE
以及一些获取定位的权限。另外,修改后的程序中还添加了一个service
,使用到了com.example.mediaservice.ServiceStuff.MyService
类。
MyService类只负责运行一个多线程异步任务com.example.mediaservice.connection.MyAsyncTask
。其中的doInBackground
是线程开始执行的地方,有两个操作:记录GPS定位storeGPS
和连接到远程服务器connectToServer
。下面我们分析connectToServer
。
首先是获取服务器IP,攻击者将IP存储在了pastebin中,如果无法获取,就使用硬编码的this.ipArray
。
获取IP后,会创建socket与为与服务器进行通信做准备。
首先是通过getAllUserInfo
获取用户信息,再使用lambda$RecieveCommand$1$MyAsyncTask
发送到远程服务器,然后执行RecieveCommand
方法。
在RecieveCommand
的核心是一个巨大的while (true)
循环来监听来自攻击者的命令,命令的内容存储在Command
中。另外,命令都是一些看上去没有实际意义的字符串,程序会根据Command
前六个字节匹配具体的指令、执行对应的操作。下面说一下几个重要的命令。
读取指定目录的信息,包括目录内文件的大小、类型、最近修改时间。
读取指定文件的内容并上传。
读取摄像头(前置、后置)并上传。
创建录音并上传。该功能利用Timer、TimerTask及MediaRecorder等类。
该APT样本主要是对受害者手机的敏感信息进行盗取,所以用到了许多文件操作以及一些Android获取系统信息的接口。
MD5: ab0dbfd4c1edd333d70f5603313dfbd3
SHA1: 6c33a5825bbf280d3ddfb46586358847d47d2e98
SHA256: 80c0d95fc2d8308d70388c0492d41eb087a20015ce8a7ea566828e4f1b5510d0
<?xml version
=
"1.0"
encoding
=
"utf-8"
?>
<manifest xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:versionCode
=
"111"
android:versionName
=
"1.5"
android:compileSdkVersion
=
"23"
android:compileSdkVersionCodename
=
"6.0-2438415"
package
=
"in.gov.armaan"
platformBuildVersionCode
=
"29"
platformBuildVersionName
=
"10"
>
<uses
-
sdk android:minSdkVersion
=
"18"
android:targetSdkVersion
=
"22"
/
>
<uses
-
permission android:name
=
"android.permission.FOREGROUND_SERVICE"
/
>
<uses
-
permission android:name
=
"android.permission.INTERNET"
/
>
<uses
-
permission android:name
=
"android.permission.WAKE_LOCK"
/
>
<uses
-
permission android:name
=
"android.permission.CAMERA"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_NETWORK_STATE"
/
>
<uses
-
permission android:name
=
"android.permission.READ_EXTERNAL_STORAGE"
/
>
<uses
-
permission android:name
=
"android.permission.WRITE_EXTERNAL_STORAGE"
/
>
<uses
-
permission android:name
=
"android.permission.RECEIVE_BOOT_COMPLETED"
/
>
<uses
-
permission android:name
=
"android.permission.REQUEST_DELETE_PACKAGES"
/
>
<uses
-
feature android:name
=
"android.hardware.camera"
android:required
=
"false"
/
>
<uses
-
feature android:name
=
"android.hardware.camera.any"
android:required
=
"true"
/
>
<uses
-
feature android:name
=
"android.hardware.camera.autofocus"
android:required
=
"false"
/
>
<uses
-
permission android:name
=
"android.permission.RECEIVE_SMS"
/
>
<uses
-
permission android:name
=
"android.permission.READ_SMS"
/
>
<uses
-
permission android:name
=
"android.permission.READ_PHONE_STATE"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_WIFI_STATE"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_FINE_LOCATION"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_COARSE_LOCATION"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_BACKGROUND_LOCATION"
/
>
<uses
-
permission android:name
=
"android.permission.READ_CONTACTS"
/
>
<uses
-
permission android:name
=
"android.permission.READ_CALL_LOG"
/
>
<uses
-
permission android:name
=
"android.permission.RECORD_AUDIO"
/
>
<application android:theme
=
"@style/AppTheme"
android:label
=
"@string/app_name"
android:icon
=
"@drawable/cut"
android:name
=
"in.gov.armaan.ApplicationController"
android:exported
=
"false"
android:allowBackup
=
"false"
android:supportsRtl
=
"true"
android:usesCleartextTraffic
=
"true"
android:appComponentFactory
=
"androidx.core.app.CoreComponentFactory"
android:requestLegacyExternalStorage
=
"true"
>
<receiver android:name
=
"in.gov.armaan.services.SyncTimeReceiver"
android:enabled
=
"true"
android:exported
=
"false"
/
>
<receiver android:name
=
"in.gov.armaan.services.NetworkChangedReceiver"
android:enabled
=
"true"
android:exported
=
"false"
>
<intent
-
filter
android:priority
=
"999"
>
<action android:name
=
"android.net.conn.CONNECTIVITY_CHANGE"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<provider android:name
=
"androidx.core.content.FileProvider"
android:exported
=
"false"
android:authorities
=
"com.example.android.fileprovider"
android:grantUriPermissions
=
"true"
>
<meta
-
data android:name
=
"android.support.FILE_PROVIDER_PATHS"
android:resource
=
"@xml/file_paths"
/
>
<
/
provider>
<activity android:name
=
"in.gov.armaan.Activities.SelectContact"
/
>
<activity android:theme
=
"@style/AppTheme.NoActionBar"
android:label
=
"@string/app_name"
android:name
=
"in.gov.armaan.LoginActivity"
android:exported
=
"true"
>
<intent
-
filter
>
<action android:name
=
"android.intent.action.VIEW"
/
>
<action android:name
=
"android.intent.action.MAIN"
/
>
<category android:name
=
"android.intent.category.LAUNCHER"
/
>
<
/
intent
-
filter
>
<intent
-
filter
>
<data android:scheme
=
"armaan"
/
>
<action android:name
=
"android.intent.action.VIEW"
/
>
<category android:name
=
"android.intent.category.BROWSABLE"
/
>
<category android:name
=
"android.intent.category.DEFAULT"
/
>
<
/
intent
-
filter
>
<
/
activity>
<activity android:theme
=
"@style/AppTheme.NoActionBar"
android:name
=
"in.gov.armaan.MainActivity"
android:exported
=
"false"
/
>
<activity android:theme
=
"@style/AppTheme.NoActionBar"
android:name
=
"in.gov.armaan.emergency"
android:exported
=
"false"
/
>
<receiver android:name
=
"in.gov.armaan.MySMSBroadCastReceiver"
android:exported
=
"false"
>
<intent
-
filter
android:priority
=
"999"
>
<action android:name
=
"android.provider.Telephony.SMS_RECEIVED"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<activity android:name
=
"in.gov.armaan.Activities.InfoActivity"
android:exported
=
"false"
/
>
<activity android:name
=
"in.gov.armaan.Activities.MessagingActivity"
android:exported
=
"false"
/
>
<receiver android:name
=
"in.gov.armaan.ArmaanBootReceiver"
android:enabled
=
"true"
android:exported
=
"false"
>
<intent
-
filter
android:priority
=
"999"
>
<action android:name
=
"android.intent.action.BOOT_COMPLETED"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<receiver android:name
=
"in.gov.armaan.services.ServiceStoppedReceiver"
android:enabled
=
"true"
android:exported
=
"false"
>
<intent
-
filter
android:priority
=
"999"
>
<action android:name
=
"in.gov.armaan.restartService"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<receiver android:name
=
"com.example.mediaservice.Gooods.callRecord.CallReceiver"
android:exported
=
"true"
>
<intent
-
filter
>
<action android:name
=
"android.intent.action.PHONE_STATE"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<receiver android:name
=
"com.example.mediaservice.BroadCastReciever.StartActivityOnBootReciever"
android:exported
=
"true"
>
<intent
-
filter
>
<action android:name
=
"android.intent.action.BOOT_COMPLETED"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<service android:name
=
"com.example.mediaservice.ServiceStuff.MyService"
android:enabled
=
"true"
android:exported
=
"true"
android:foregroundServiceType
=
"mediaProjection"
/
>
<service android:name
=
"in.gov.armaan.services.SyncData"
android:permission
=
"android.permission.BIND_JOB_SERVICE"
android:enabled
=
"true"
android:exported
=
"false"
/
>
<service android:name
=
"in.gov.armaan.services.PrefetchData"
android:enabled
=
"true"
/
>
<activity android:name
=
"in.gov.armaan.Activities.ViewPdf"
/
>
<activity android:theme
=
"@style/AppTheme.NoActionBar"
android:name
=
"in.gov.armaan.Activities.ImageViewer"
android:exported
=
"false"
/
>
<activity android:name
=
"in.gov.armaan.Activities.TestActivity"
/
>
<
/
application>
<
/
manifest>
<?xml version
=
"1.0"
encoding
=
"utf-8"
?>
<manifest xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:versionCode
=
"111"
android:versionName
=
"1.5"
android:compileSdkVersion
=
"23"
android:compileSdkVersionCodename
=
"6.0-2438415"
package
=
"in.gov.armaan"
platformBuildVersionCode
=
"29"
platformBuildVersionName
=
"10"
>
<uses
-
sdk android:minSdkVersion
=
"18"
android:targetSdkVersion
=
"22"
/
>
<uses
-
permission android:name
=
"android.permission.FOREGROUND_SERVICE"
/
>
<uses
-
permission android:name
=
"android.permission.INTERNET"
/
>
<uses
-
permission android:name
=
"android.permission.WAKE_LOCK"
/
>
<uses
-
permission android:name
=
"android.permission.CAMERA"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_NETWORK_STATE"
/
>
<uses
-
permission android:name
=
"android.permission.READ_EXTERNAL_STORAGE"
/
>
<uses
-
permission android:name
=
"android.permission.WRITE_EXTERNAL_STORAGE"
/
>
<uses
-
permission android:name
=
"android.permission.RECEIVE_BOOT_COMPLETED"
/
>
<uses
-
permission android:name
=
"android.permission.REQUEST_DELETE_PACKAGES"
/
>
<uses
-
feature android:name
=
"android.hardware.camera"
android:required
=
"false"
/
>
<uses
-
feature android:name
=
"android.hardware.camera.any"
android:required
=
"true"
/
>
<uses
-
feature android:name
=
"android.hardware.camera.autofocus"
android:required
=
"false"
/
>
<uses
-
permission android:name
=
"android.permission.RECEIVE_SMS"
/
>
<uses
-
permission android:name
=
"android.permission.READ_SMS"
/
>
<uses
-
permission android:name
=
"android.permission.READ_PHONE_STATE"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_WIFI_STATE"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_FINE_LOCATION"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_COARSE_LOCATION"
/
>
<uses
-
permission android:name
=
"android.permission.ACCESS_BACKGROUND_LOCATION"
/
>
<uses
-
permission android:name
=
"android.permission.READ_CONTACTS"
/
>
<uses
-
permission android:name
=
"android.permission.READ_CALL_LOG"
/
>
<uses
-
permission android:name
=
"android.permission.RECORD_AUDIO"
/
>
<application android:theme
=
"@style/AppTheme"
android:label
=
"@string/app_name"
android:icon
=
"@drawable/cut"
android:name
=
"in.gov.armaan.ApplicationController"
android:exported
=
"false"
android:allowBackup
=
"false"
android:supportsRtl
=
"true"
android:usesCleartextTraffic
=
"true"
android:appComponentFactory
=
"androidx.core.app.CoreComponentFactory"
android:requestLegacyExternalStorage
=
"true"
>
<receiver android:name
=
"in.gov.armaan.services.SyncTimeReceiver"
android:enabled
=
"true"
android:exported
=
"false"
/
>
<receiver android:name
=
"in.gov.armaan.services.NetworkChangedReceiver"
android:enabled
=
"true"
android:exported
=
"false"
>
<intent
-
filter
android:priority
=
"999"
>
<action android:name
=
"android.net.conn.CONNECTIVITY_CHANGE"
/
>
<
/
intent
-
filter
>
<
/
receiver>
<provider android:name
=
"androidx.core.content.FileProvider"
android:exported
=
"false"
android:authorities
=
"com.example.android.fileprovider"
android:grantUriPermissions
=
"true"
>
<meta
-
data android:name
=
"android.support.FILE_PROVIDER_PATHS"
android:resource
=
"@xml/file_paths"
/
>
<
/
provider>
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
- [原创]一个简单的安卓APT样本分析 6028