首页
社区
课程
招聘
[原创]分析了一款android短信木马
发表于: 2014-2-19 21:27 33885

[原创]分析了一款android短信木马

2014-2-19 21:27
33885
【分析作者】  bincker
【联系方式】  0day#tongji.edu.cn
【作者主页】  6ebK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4c8Q4x3X3g2I4M7g2)9J5k6h3y4G2L8g2)9J5c8X3u0A6L8X3y4C8k6i4u0Q4x3V1j5`.
【分析工具】  IDA6.1,JD-GUI,Dex2Jar,smali,AndroidSDKV4.0,DrozerV2.3
【分析声明】  纯技术分析,分析不够全面,望请多多请教,大牛绕过,新手可以进一步研究研究还是蛮有收获的。
【软件名称】  com.example.text.apk 恶意软件样本
【下载地址】  616K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4m8S2L8W2)9J5k6h3u0S2K9h3c8#2i4K6u0W2j5$3!0E0i4K6u0r3M7#2)9J5c8U0q4A6x3%4W2K6N6@1b7K6
【加壳信息】  无
【软件简介】  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直播授课

上传的附件:
  • 1.jpg (34.41kb,2091次下载)
  • 2.jpg (14.25kb,2083次下载)
  • 3.jpg (81.02kb,2094次下载)
  • 4.jpg (50.55kb,2082次下载)
  • 5.jpg (72.66kb,2077次下载)
  • 6.jpg (25.24kb,2079次下载)
  • 7.jpg (42.96kb,2082次下载)
  • 8.jpg (50.04kb,2078次下载)
  • 9.jpg (75.74kb,2072次下载)
  • 10.jpg (82.62kb,2074次下载)
  • 11.jpg (94.55kb,2075次下载)
收藏
免费 0
支持
分享
最新回复 (19)
雪    币: 341
活跃值: (153)
能力值: ( LV7,RANK:110 )
在线值:
发帖
回帖
粉丝
2
我是来站楼道的
2014-2-19 22:03
0
雪    币: 49
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
楼主看来是安卓高手啊,我等只能膜拜!
2014-2-19 22:26
0
雪    币: 1413
活跃值: (401)
能力值: (RANK:270 )
在线值:
发帖
回帖
粉丝
4
有两个地方没看明白:

1. “使用的权限具体路径位置”这个是内部工具生成的?

2. 动态分析使用的Anubis在线服务?

对SMS短信窃取工具,最重要的其实是找出它拦截短信的筛选条件,从而知道其主要目的,这一点主要通过静态分析得到。
2014-2-20 03:45
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
wk. 这么晚还不睡。
2014-2-20 09:10
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
DNS 和与google服务器的通讯不是应用干的。。。那是系统自己干的~~~
2014-2-20 09:12
0
雪    币: 40
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
本地整合了一些分析工具整合了,大部分是androguard,一些manifest分析和droidbox。
诸葛建伟他们参与的核高基项目中貌似用到intent fuzz,mercury整合。
使用的权限具体路径位置是行为特征或者用到函数的静态分析

我平常用到的一些沙盒或者分析平台供参考:

  android沙盒-1                                    12eK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6V1k6i4S2@1k6i4u0Q4x3X3g2T1L8s2g2W2j5X3!0^5i4K6u0W2j5$3!0E0i4K6t1$3L8X3u0K6M7q4)9K6b7R3`.`.  
  android沙盒-2                                    d54K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3q4F1N6h3u0A6M7#2)9J5k6h3W2K6k6h3y4D9j5h3u0Q4x3X3g2G2M7X3M7`.
  android沙盒-3                                    0ffK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6X3K9i4u0W2k6i4W2W2i4K6u0W2K9h3A6A6L8Y4y4Z5j5h3&6Q4x3X3g2U0L8$3#2Q4x3V1j5`.
  android沙盒-4                                    d06K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6h3q4H3K9#2)9J5k6r3q4F1j5h3I4&6P5X3g2J5i4K6u0W2L8X3g2@1i4K6u0r3i4K6t1$3L8X3u0K6M7q4)9K6b7W2)9J5y4X3&6T1M7%4m8Q4x3@1t1`.
  android沙盒-5                                    4b6K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3#2G2j5X3W2D9k6i4y4S2L8X3c8T1L8%4S2Q4x3X3g2G2M7X3N6Q4x3V1j5`.
  android沙盒-6                                    81aK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4S2L8X3c8V1M7X3!0A6k6q4)9J5k6i4S2B7N6s2g2Q4x3X3g2W2k6s2g2Q4x3X3g2U0L8W2)9J5c8W2)9J5y4X3&6T1M7%4m8Q4x3@1u0Q4x3U0k6F1j5Y4y4H3i4K6y4n7
  android沙盒-7                                    3d6K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3q4$3j5$3q4W2M7$3q4J5i4K6u0W2L8h3q4D9N6$3q4J5k6g2)9J5k6h3I4#2i4K6u0r3i4K6t1$3L8X3u0K6M7q4)9K6b7R3`.`.  
  android沙盒-8                                    b45K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8U0p5H3i4K6u0W2x3e0k6Q4x3X3f1@1y4g2)9J5k6e0j5I4i4K6y4m8z5o6l9H3x3W2)9J5c8X3q4H3K9#2)9J5c8W2)9J5y4X3&6T1M7%4m8Q4x3@1u0Q4x3U0k6F1j5Y4y4H3i4K6y4n7j5i4m8C8i4@1f1#2i4K6R3^5i4K6R3$3i4@1f1$3i4K6W2q4i4K6V1H3i4@1f1#2i4@1t1&6i4@1t1K6i4@1f1#2i4K6S2r3i4@1t1H3
  android沙盒-9                                    abfK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3y4S2L8h3q4K6i4K6u0W2j5$3!0E0L8$3c8G2i4K6u0W2j5$3!0E0i4K6u0r3j5$3N6A6i4K6u0V1j5X3W2F1i4K6u0r3M7%4g2T1L8h3W2@1
  android沙盒-10                                  180K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6i4c8Z5M7X3g2S2N6r3g2^5M7r3g2J5N6q4)9J5k6h3y4G2L8b7`.`.
  android沙盒-11                                  c21K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6i4c8Z5M7X3g2S2N6s2c8J5j5h3y4C8M7$3g2U0N6i4u0A6N6s2W2Q4x3X3g2U0L8$3@1`.
  android沙盒-12                                  357K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6%4N6%4N6Q4x3X3g2T1i4K6u0V1j5$3S2S2L8#2)9J5k6h3y4G2L8g2)9J5y4X3&6T1M7%4m8Q4x3@1t1`.     
  VT                                                     8f3K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8W2k6A6M7Y4g2K6N6r3!0@1j5h3I4Q4x3X3g2U0L8$3@1`.
2014-2-20 09:56
0
雪    币: 101
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
v587
2014-2-20 10:03
0
雪    币: 3
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
来晚了,网盘的apk取消了……楼主的apk样本还在么?
2014-4-10 13:32
0
雪    币: 147
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
10
目测这个木马只能在3.0以前可以用,3.0以后的机制保证了这种程序运行不起来 只要不命令行启动 程序一直处于“死状态”  不会激活开机启动
2014-4-23 11:10
0
雪    币: 9
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
11
不错 受教了!!
2014-4-23 11:15
0
雪    币: 14
活跃值: (41)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
12
分析得很详细。
这是自己写的app吧?
2014-4-26 17:03
0
雪    币: 29
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
进来学习了!
2014-4-28 01:51
0
雪    币: 586
活跃值: (1339)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
14
样本连接报销了,求新地址
2014-4-30 15:54
0
雪    币: 4
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
15
楼主~求样本呀~
分析的这么详细,要好好看看
2014-5-6 15:52
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
16
谢楼主分析。求样本!
2014-5-18 09:51
0
雪    币: 680
活跃值: (68)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
17
nice 膜拜
2014-5-18 10:09
0
雪    币: 30
活跃值: (34)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
楼主牛人,感谢分享!
2014-5-18 10:23
0
雪    币: 1
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
19
感谢楼主分享 就是 楼主的apk样本还在么?麻烦再分享下吧
2014-5-19 19:38
0
雪    币: 7
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
20
我用广播的方式做了开机自启功能,可是开机后,死活不启动,不知为什么?求教。
2016-9-9 21:29
0
游客
登录 | 注册 方可回帖
返回