【分析作者】 bincker
【联系方式】 0day#tongji.edu.cn
【作者主页】 http://t.qq.com/bincker/
【分析工具】 IDA6.1,JD-GUI,Dex2Jar,smali,AndroidSDKV4.0,DrozerV2.3
【分析声明】 纯技术分析,分析不够全面,望请多多请教,大牛绕过,新手可以进一步研究研究还是蛮有收获的。
【软件名称】 com.example.text.apk 恶意软件样本
【下载地址】 http://pan.baidu.com/s/1i3yswD3
【加壳信息】 无
【软件简介】 android恶意软件样本,无界面,无快捷方式,隐蔽性较强
功能说明:
* 一款专门偷取系统短信的恶意apk文件,com.example.text.apk
* 开机自身启动,监听系统短信服务,如果在短信箱有短信的话发送到指定的手机号当中
• 一.包基本情况
Filename: maleware.apk
MD5: 05b009f8e6c30a1bc0a0f793049960bc
SHA-1: 1fbd1c8aa4b33c281c4fec3cf69b672b0968531a
File Size: 242867 Bytes
SDKVer:4
TargetSDKVer:17
API Level: 4
Application Label: Android review
Process Name: com.example.text //app进程名称
Version: 1.0 //app版本
Data Directory: /data/data/com.example.text //apk安装路径
APK Path: /data/app/com.example.text-1.apk //安装时用的apk路径
UID: 10035 //app运行时系统UID
GID: None
Shared Libraries: null
Shared User ID: null
android.hardware.telephony //使用电话父类功能
android.hardware.touchscreen //使用触屏父类功能
Permissions:
android.permission.RECEIVE_SMS //收取短信权限
android.permission.READ_SMS //读取短信权限
android.permission.SEND_SMS //发送短信权限
android.permission.RECEIVE_BOOT_COMPLETED //开机启动权限
四大组件情况:
Activity: com.example.text //app使用的Activity
com.example.text.MainActivity
Broadcast Receiver: com.example.text //app使用的Broadcast Receiver
com.example.text.SMS
com.example.text.StartBroadcastReceiver
Service: com.example.text //app使用的Service
com.example.text.TService
• 二.分析过程
该app被安装后没有logo。所有无法使用触屏方式打开。
使用adb shell 下面命令方式打开 adb shell
#am start -a com.example.text com.example.text.MainActivity
运行app时首先oncreate 这个activity: com.example.text.MainActivity
但是该activity打开后闪退了。 也就是说没有给用户提供一个界面服务。更加怀疑这app了。
接下来使用静态和动态搭配分析该app的内容吧。
首先IDA PRO 6.1 载入下dex文件,定位到mainactivity 。
之后再startbroadcastreceiver.smali中发现有手机开机启动服务。
验证下重启了手机:
启动后果然自动启了:
启动后开启TService 服务,以下是通过android系统日志logcat中抓取
I/ActivityManager( 77): Start proc com.example.text for broadcast com.example.text/.StartBroadcastReceiver: pid=416 uid=10035 gids={}
D/ExchangeService( 398): !!! EAS ExchangeService, onStartCommand, startingUp = false, running = false
D/TService( 416): ============> TService.onCreate
I/TService( 416): ============> TService.onStart
D/dalvikvm( 381): GC_CONCURRENT freed 219K, 4% free 10082K/10439K, paused 4ms+3ms
D/Eas Debug( 398): Logging:
I//system/bin/fsck_msdos( 31): Attempting to allocate 1022 KB for FAT
D/GpsLocationProvider( 77): NTP server returned: 1392806007205 (Wed Feb 19 10:33:27 GMT+00:00 2014) reference: 36472 certainty: 27 system time offset: 407
D/dalvikvm( 183): GC_CONCURRENT freed 644K, 8% free 10866K/11719K, paused 3ms+5ms
D/ExchangeService( 398): Received deviceId from Email app: androidc259148960
D/ExchangeService( 398): Reconciling accounts...
D/ExchangeService( 398): !!! EAS ExchangeService, onStartCommand, startingUp = true, running = false
使用的权限具体路径位置
• android.permission.SEND_SMS //发送短信权限使用地方
method call: "Lcom/example/text/SMS/onReceive(Landroid/content/Context; Landroid/content/Intent;)V" calls "Landroid/telephony/gsm/SmsManager/getDefault()Landroid/telephony/gsm/SmsManager;"
method call: "Lcom/example/text/SMS/onReceive(Landroid/content/Context; Landroid/content/Intent;)V" calls "Landroid/telephony/gsm/SmsManager/sendTextMessage(Ljava/lang/String; Ljava/lang/String; Ljava/lang/String; Landroid/app/PendingIntent; Landroid/app/PendingIntent;)V"
method call: "Lcom/example/text/TService/sendMsg()V" calls "Landroid/telephony/gsm/SmsManager/getDefault()Landroid/telephony/gsm/SmsManager;"
method call: "Lcom/example/text/TService/sendMsg()V" calls "Landroid/telephony/gsm/SmsManager/sendTextMessage(Ljava/lang/String; Ljava/lang/String; Ljava/lang/String; Landroid/app/PendingIntent; Landroid/app/PendingIntent;)V"
• android.permission.ACCESS_NETWORK_STATE //访问网络权限使用地方
method call: "Landroid/support/v4/net/ConnectivityManagerCompat$BaseConnectivityManagerCompatImpl/isActiveNetworkMetered(Landroid/net/ConnectivityManager;)Z" calls "Landroid/net/ConnectivityManager/getActiveNetworkInfo()Landroid/net/NetworkInfo;"
method call: "Landroid/support/v4/net/ConnectivityManagerCompat/getNetworkInfoFromBroadcast(Landroid/net/ConnectivityManager; Landroid/content/Intent;)Landroid/net/NetworkInfo;" calls "Landroid/net/ConnectivityManager/getNetworkInfo(I)Landroid/net/NetworkInfo;"
method call: "Landroid/support/v4/net/ConnectivityManagerCompatGingerbread/isActiveNetworkMetered(Landroid/net/ConnectivityManager;)Z" calls "Landroid/net/ConnectivityManager/getActiveNetworkInfo()Landroid/net/NetworkInfo;"
method call: "Landroid/support/v4/net/ConnectivityManagerCompatHoneycombMR2/isActiveNetworkMetered(Landroid/net/ConnectivityManager;)Z" calls "Landroid/net/ConnectivityManager/getActiveNetworkInfo()Landroid/net/NetworkInfo;"
• android.permission.VIBRATE //震动事件的控制(这块)
method call: "Landroid/support/v4/app/NotificationCompat$Builder/setDefaults(I)Landroid/support/v4/app/NotificationCompat$Builder;" calls "Landroid/app/Notification/Idefaults"
method call: "Landroid/support/v4/app/NotificationCompatHoneycomb/add(Landroid/content/Context; Landroid/app/Notification; Ljava/lang/CharSequence; Ljava/lang/CharSequence; Ljava/lang/CharSequence; Landroid/widget/RemoteViews; I Landroid/app/PendingIntent; Landroid/app/PendingIntent; Landroid/graphics/Bitmap;)Landroid/app/Notification;" calls "Landroid/app/Notification/Idefaults"
method call: "Landroid/support/v4/app/NotificationCompatIceCreamSandwich/add(Landroid/content/Context; Landroid/app/Notification; Ljava/lang/CharSequence; Ljava/lang/CharSequence; Ljava/lang/CharSequence; Landroid/widget/RemoteViews; I Landroid/app/PendingIntent; Landroid/app/PendingIntent; Landroid/graphics/Bitmap; I I Z)Landroid/app/Notification;" calls "Landroid/app/Notification/Idefaults"
method call: "Landroid/support/v4/app/NotificationCompatJellybean/<init>(Landroid/content/Context; Landroid/app/Notification; Ljava/lang/CharSequence; Ljava/lang/CharSequence; Ljava/lang/CharSequence; Landroid/widget/RemoteViews; I Landroid/app/PendingIntent; Landroid/app/PendingIntent; Landroid/graphics/Bitmap; I I Z Z I Ljava/lang/CharSequence;)V" calls "Landroid/app/Notification/Idefaults"
运行当中执行的服务及附带系统执行的服务:
com.android.vending.util.WorkService
com.android.vending.util.WorkService
com.android.email.service.EmailBroadcastProcessorService
com.android.email.service.EmailBroadcastProcessorService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.checkin.CheckinService
com.android.exchange.SyncManager
com.google.android.gsf.update.SystemUpdateService
com.google.android.gsf.update.SystemUpdateService
com.google.android.partnersetup.AppHiderService
com.google.android.partnersetup.AppHiderService
com.android.providers.downloads.DownloadService
com.android.providers.downloads.DownloadService
com.android.mms.transaction.SmsReceiverService
com.android.mms.transaction.SmsReceiverService
com.android.providers.media.MediaScannerService
com.android.providers.media.MediaScannerService
com.android.vending.util.AlarmService
com.android.vending.util.AlarmService
com.android.providers.calendar.EmptyService
com.android.bluetooth.opp.BluetoothOppService
com.android.bluetooth.opp.BluetoothOppService
com.google.android.gm.MailIntentService
com.google.android.gm.MailIntentService
com.google.android.gm.downloadprovider.DownloadService
com.google.android.gm.downloadprovider.DownloadService
com.example.text.TService
com.example.text.TService
com.example.text.TService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.update.SystemUpdateService
com.google.android.gsf.update.SystemUpdateService
com.google.android.partnersetup.AppHiderService
com.google.android.partnersetup.AppHiderService
com.android.providers.calendar.EmptyService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.checkin.EventLogService
com.google.android.gsf.checkin.EventLogService
com.google.android.gsf.checkin.EventLogService
com.google.android.gsf.checkin.EventLogService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.checkin.CheckinService
com.google.android.gsf.update.SystemUpdateService
com.google.android.gsf.update.SystemUpdateService
com.google.android.partnersetup.AppHiderService
com.google.android.partnersetup.AppHiderService
恶意程序向指定手机号发送了一条短信:
15602113821 内容 Hello World!
代码位置处在 SMS.smali文件下静态声明短信接收手机号码,
定位指定手机号码发送二进制代码处
使用IDA中的行为:
如果获取到的短信等于0的话终止
其中最重要一部分是Tservice部分。 让我们分析下这个Tservice.smali 吧
首先定义了 intCounter的变量,初始化值为0 检查服务的打点记录。
程序在logcat 下不断的进行打点。
I/HIPPO ( 416): Counter:1211
I/HIPPO ( 416): Counter:1212
I/HIPPO ( 416): Counter:1213
I/HIPPO ( 416): Counter:1214
I/HIPPO ( 416): Counter:1215
I/HIPPO ( 416): Counter:1216
I/HIPPO ( 416): Counter:1217
I/HIPPO ( 416): Counter:1218
I/HIPPO ( 416): Counter:1219
I/HIPPO ( 416): Counter:1220
I/HIPPO ( 416): Counter:1221
定位的二进制代码出:
除此之外与google服务器 通讯了几次,其中有DNS解析和POST数据到google服务器。但仍然不确定作者的意图,
From ANUBIS:47476 to 173.194.116.160:80 - [android.clients.google.com]
Request: POST /checkin
Response: 200 "OK"
DNS解析:
向Google服务器POST数据
总结下:
1.该app开机自身启动,并默认开启Tservice服务,之后获取系统的短信接收权限,( android.provider.Telephony.SMS_RECEIVED) 并开始使用intCounter进行控制线程数量 mTasks.
2.Tservice 有 事件通知 管理功能 NotificationManager ,接下来检查短信箱是否空,如果是空的话终止发信,否将发送到 15602113821 手机号码。
3.Ibinder进行绑定服务,进行准备接受系统短信服务的通知,这时候使用SmsObserver 来进行监听短信信息。如果短信回话列表content://sms 是true的话 遍历系统已接受到的短信android.provider.Telephony.SMS_RECEIVED列表。
4.之后使用 TService.this.sendMsg(); 执行 第3行 行为
5.最后定义为:一款专门偷取系统短信的恶意apk文件,无界面,无桌面快捷方式,隐蔽性强,开机自身启动,监听系统短信服务,如果在短信箱有短信的话发送到指定的手机号当中。
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课