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

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

2014-2-19 21:27
33672
【分析作者】  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直播授课

上传的附件:
  • 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
活跃值: (138)
能力值: ( 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                                    https://dexter.bluebox.com   
  android沙盒-2                                    http://anubis.iseclab.org
  android沙盒-3                                    https://fireeye.ijinshan.com/
  android沙盒-4                                    http://www.apk-analyzer.net/  
  android沙盒-5                                    http://mobilesandbox.org/
  android沙盒-6                                    http://sanddroid.xjtu.edu.cn/  
  android沙盒-7                                    http://avcaesar.malware.lu/   
  android沙盒-8                                    http://10.16.45.61:8002/apk/  apk分析平台
  android沙盒-9                                    http://camas.comodo.com/cgi-bin/submit
  android沙盒-10                                  http://www.threatexpert.com
  android沙盒-11                                  http://www.threattracksecurity.com
  android沙盒-12                                  https://www.b-chao.com      
  VT                                                     http://Virustotal.com
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
雪    币: 573
活跃值: (984)
能力值: ( 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
游客
登录 | 注册 方可回帖
返回
//