美文网首页
IPhone一起玩越狱 -(十)- 使用dumpdecrypte

IPhone一起玩越狱 -(十)- 使用dumpdecrypte

作者: struggle3g | 来源:发表于2018-06-14 00:42 被阅读61次

    引言

    上篇讲到了静态砸壳的过程,砸壳安装到手机上面的文件直接copy出来,大家都知道appstore下载的ipa包是加密过的,当安装到手机上的时候,iOS手机系统会对这个ipa包进行解密,解密完成以后才能安装到手机上面。

    扩展说明

    动态库的加载?
    dyld去加载,动态库加载的时候肯定要依附到一个进程上面
    so需要将动态库copy到手机中才能正常的加载这个动态库

    PS:在iOS系统中DYLD 中有个环境变量 DYLD_INSERT_LIBRARIES
    是告诉某个应用进程我要加载这个动态库

    DYLD_INSERT_LIBRARIES的使用

    自己创建一个动态库Dumpryptedtest.framework,然后将这个动态库

    /**添加代码**/
    +(void)load{
        NSLog(@"🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜");
    }
    

    copy到手机,用usb访问copy

    $ scp -r -P xxxx/Dumpryptedtest.framework root@localhost:~/
    

    访问手机然后配置DYLD的环境变量 DYLD_INSERT_LIBRARIES,并且找到某个应用进程,可以使用 ps -A来查看

    xxxx-iPhone:~ root# DYLD_INSERT_LIBRARIES=DumpdecryptedTest.framework/DumpdecryptedTest /var/containers/Bundle/Application/84BADE72-308A-4267-B071-BFAFA5DF7AF8/xxx.app/xxx
    2018-06-14 00:01:27.138 Keep[14090:743264] 🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜🥜
    Abort trap: 6
    

    在iOS系统中可以这么加载这个动态库,只不过加载了一个动态库并没有修改应用程序的源代码

    动态库砸壳的原理:
    已经在执行的程序,已经放入到了内存,运行中的程序肯定是解密过的,写一个动态库,依附到这个程序,将这个程序的MachO文件Copy出来

    下载、安装dumpdecrypted 、copy到手机 ~/目录

    首先下载dumpdecrypted
    下载完成进入当前目录直接编译

    dumpdecrypted目录$ make
    

    生成了一个dumpdecrypted.dylib文件

    dumpdecrypted砸壳正题

    xxx-iPhone:~ root# DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib  /var/containers/Bundle/Application/84BADE72-308A-4267-B071-BFAFA5DF7AF8/xxx.app/xxx
    mach-o decryption dumper
    
    DISCLAIMER: This tool is only meant for security research purposes, not for application crackers.
    
    [+] detected 64bit ARM binary in memory.
    [+] offset to cryptid found: @0x100018f78(from 0x100018000) = f78
    [+] Found encrypted data at address 00004000 of length 44007424 bytes - type 1.
    [+] Opening /private/var/containers/Bundle/Application/84BADE72-308A-4267-B071-BFAFA5DF7AF8/xxx.app/xxx for reading.
    [+] Reading header
    [+] Detecting header type
    [+] Executable is a plain MACH-O image
    [+] Opening Keep.decrypted for writing.
    [+] Copying the not encrypted start of the file
    [+] Dumping the decrypted data into the file
    [+] Copying the not encrypted remainder of the file
    [+] Setting the LC_ENCRYPTION_INFO->cryptid to 0 at offset f78
    [+] Closing original file
    [+] Closing dump file
    
    xxx-iPhone:~ root# ls
    Application\ Support/  Containers/  DumpdecryptedTest.framework/  xxx.decrypted  Library/  Media/  dumpdecrypted.dylib*
    

    多了一个xxx.decrypted 这个就是你要的MachO文件解密过的.
    将这个MachO移动到你的mobile用户下的Media文件夹,方便ifunboxCopy到桌面

    xxxx-iPhone:~ root# mv xxx.decrypted /User/Media/
    

    拖到桌面
    当然也可以使用命令copy

    xxx $ scp -P 3456 root@localhost:/User/Media/xxx.decrypted ~/Desktop
    xxx.decrypted 100% 52MB 11.3MB/s 00:04

    检查加密的信息

     xxx $ otool -l xxx.decrypted | grep crypt
    xxx.decrypted:
         cryptoff 16384
        cryptsize 44007424
          cryptid 0
    

    cryptid 0 检查完成已经解密

    遇到的坑

    生成的dumpdecrypted.dylib 动态库不能正常使用
    错误信息

    xxx-iPhone:~ root# DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib  /var/containers/Bundle/Application/84BADE72-308A-4267-B071-BFAFA5DF7AF8/xxx.app/xxx
    /**报错误**/
    dyld: could not load inserted library 'dumpdecrypted.dylib' because no suitable image found.  Did find:
        dumpdecrypted.dylib: required code signature missing for 'dumpdecrypted.dylib'
    
        /private/var/root/dumpdecrypted.dylib: required code signature missing for '/private/var/root/dumpdecrypted.dylib'
    
    
    Abort trap: 6
    

    解决方案
    对这个动态库进行签名

     xxx $ security find-identity -v -p codesigning
    .....
     xxx $ codesign -fs "Phone Developer: edwards wen (LLG76ELTRW)" DumpdecryptedTest.framework
    DumpdecryptedTest.framework: replacing existing signature
    

    有可能大家会疑惑拿到MachO文件了以后没法在IPhone中安装呀?

    $ ps -A  
    /private/var/containers/Bundle/Application/84BADE72-308A-4267-B071-BFAFA5DF7AF8/xxx.app
    

    将这个*.appCopy出来就成上面有打印的信息ok?

    相关文章

      网友评论

          本文标题:IPhone一起玩越狱 -(十)- 使用dumpdecrypte

          本文链接:https://www.haomeiwen.com/subject/jafdeftx.html