《iOS应用逆向工程》学习笔记(六)使用dumpdecrypted砸壳

2024-05-26 10:38

本文主要是介绍《iOS应用逆向工程》学习笔记(六)使用dumpdecrypted砸壳,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

本来是打算用AppCrackr砸壳的,结果砸壳都是失败的,开始以为是App的加密太厉害了,后来才知道是因为AppCrackr太暴力了,引起公愤,结果被人投诉招致核心功能被迫关闭了。

幸好在RE官网搜到一个用dumpdecrypted砸壳的帖子。下面是我砸壳的经历。


一、造锤

1.下载dumpdecrypted源码

下载地址:https://github.com/stefanesser/dumpdecrypted/archive/master.zip,接着在Mac中解压。


2.确认iOS设备的版本 

iOS 7.1.x,原帖中snakeninny略啰嗦。。。 


3.Makefile 

cd到dumpdecrypted目录,看看Makefile文件的内容:

CC_BIN=`xcrun --sdk iphoneos --find gcc`
GCC_UNIVERSAL=$(GCC_BASE) -arch armv7 -arch armv7s -arch arm64
SDK=`xcrun --sdk iphoneos --show-sdk-path`CFLAGS =
GCC_BASE = $(GCC_BIN) -Os $(CFLAGS) -Wimplicit -isysroot $(SDK) -F$(SDK)/System$all: dumpdecrypted.dylibdumpdecrypted.dylib: dumpdecrypted.o$(GCC_UNIVERSAL) -dynamiclib -o $@ $^%.o: %.c$(GCC_UNIVERSAL) -c -o $@ $<clean:rm -f *.o dumpdecrypted.dylib

大多数看不懂。。。

接下来我们需要确认的是GCC_UNIVERSALSDK这两个变量的值和iOS设备的环境保持一致。


4.确保Makefile的配置和真机环境一致

在Mac中打开终端,输入xcrun --sdk iphoneos --show-sdk-path命令,查看SDK版本:

/Applications/Xcode 5.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk

Xcode的SDK版本是7.1.x,GCC_UNIVERSAL这个变量值可以略过。


5.创建动态库文件

(1)一错

在确保Makefile中对动态库的设置和iOS真机环境一致后,在当前目录下输入:make。

但是失败了,错误信息如下:

`xcrun --sdk iphoneos --find gcc` -Os  -Wimplicit -isysroot `xcrun --sdk iphoneos --show-sdk-path` -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/Frameworks -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/PrivateFrameworks -arch armv7 -arch armv7s -arch arm64 -c -o dumpdecrypted.o dumpdecrypted.c
/bin/sh: /Applications/Xcode: No such file or directory
make: *** [dumpdecrypted.o] Error 127

原因是找不到/Applications/Xcode来执行其中的一些脚本。 好吧,我的Mac中有3个Xcode:/Applications/Xcode 5.0.2, /Applications/Xcode 5.1.1, /Applications/Xcode 6 Beta4,就是没有/Applications/Xcode。 

没事,将Xcode 5.1.1重命名为Xcode就行了:

$ sudo mv Xcode\ 5.1.1.app/ Xcode.app/

(2)再错

再make,还是报错,错误信息和上面一样。

不怕,我们还有xcode-select这个小伙伴,通常Xcode找不到之类的错误都应该找它帮忙:

$ xcode-select -p
/Applications/Xcode 5.1.1.app/Contents/Developer

原来xcrun查找cmd tool时的路径还是Xcode 5.1.1/,当然什么都找不到了。这时候将它重置就行了(默认是/Applications/Xcode.app/):
$ sudo xcode-select -r
$ xcode-select -p 
/Applications/Xcode.app/Contents/Developer

(3)成功

再make,成功,输出如下:

$ make
`xcrun --sdk iphoneos --find gcc` -Os  -Wimplicit -isysroot `xcrun --sdk iphoneos --show-sdk-path` -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/Frameworks -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/PrivateFrameworks -arch armv7 -arch armv7s -arch arm64 -c -o dumpdecrypted.o dumpdecrypted.c
`xcrun --sdk iphoneos --find gcc` -Os  -Wimplicit -isysroot `xcrun --sdk iphoneos --show-sdk-path` -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/Frameworks -F`xcrun --sdk iphoneos --show-sdk-path`/System/Library/PrivateFrameworks -arch armv7 -arch armv7s -arch arm64 -dynamiclib -o dumpdecrypted.dylib dumpdecrypted.o$ ls
Makefile          dumpdecrypted.c          dumpdecrypted.o
README               dumpdecrypted.dylib

可以看到目录中多了两个文件,其中dylib后缀的就是我们要创建的动态库文件,也就是用来砸壳的锤子。


二、砸壳

1.将“锤子”放入设备中

查看iOS设备的IP地址,然后在Mac上使用scp命令将dumpdecrypted.dylib文件放到iOS设备中:

$ scp dumpdecrypted.dylib root@192.168.xxx.xxx:/var/tmp
root@192.168.xxx.xxx's password:
dumpdecrypted.dylib                           100%   81KB  81.0KB/s   00:00

2.砸

选定一个让你觉得非常不爽或非常感兴趣的app,我就随便选了一个HBGC。在iOS设备上打开iFile,查到它的可执行文件的路径为:/var/mobile/Applications/EBBD26E9-DDBA-481E-9403-84D159436889/HBGC.app/HBGC


然后用SSH连到iOS设备上,cd到刚刚动态库的路径:/var/tmp。

$ ssh root@192.168.xxx.xxx
root@192.168.xxx.xxx's password:
root# cd /var/tmp/
root# ls
FlipswitchCache/                              com.apple.audio.hogmode.plist
L65ancd.sock=                                 com.apple.tccd/
L65d.sock=                                    com.apple.timed.plist
MediaCache/                                   cydia.log
RestoreFromBackupLock*                        dumpdecrypted.dylib*
SpringBoard_reboot_flag                       launchd/
com.apple.assistant.bundleservicecache.plist  mobile_assertion_agent.log

砸壳(久等了):

root# DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib /var/mobile/Applications/EBBD26E9-DDBA-481E-9403-84D159436889/HBGC.app/HBGC
mach-o decryption dumperDISCLAIMER: This tool is only meant for security research purposes, not for application crackers.[+] detected 32bit ARM binary in memory.
[+] offset to cryptid found: @0xd5a90(from 0xd5000) = a90
[+] Found encrypted data at address 00004000 of length 3047424 bytes - type 1.
[+] Opening /private/var/mobile/Applications/EBBD26E9-DDBA-481E-9403-84D159436889/HBGC.app/HBGC for reading.
[+] Reading header
[+] Detecting header type
[+] Executable is a FAT image - searching for right architecture
[+] Correct arch is at offset 16384 in the file
[+] Opening HBGC.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 4a90
[+] Closing original file
[+] Closing dump file

成果:
root# ls
FlipswitchCache/                              com.apple.audio.hogmode.plist
HBGC.decrypted                                com.apple.tccd/
L65ancd.sock=                                 com.apple.timed.plist
L65d.sock=                                    cydia.log
MediaCache/                                   dumpdecrypted.dylib*
RestoreFromBackupLock*                        launchd/
SpringBoard_reboot_flag                       mobile_assertion_agent.log
com.apple.assistant.bundleservicecache.plist
其中的HBGC.decrypted就是目标产物,接下来IDA各种斧头水果刀上吧。

三、附录

1.xcrun

首先简单看看xcrun的帮助信息:

$ xcrun -h
Usage: xcrun [options] <tool name> ... arguments ...Find and execute the named command line tool from the active developer
directory.The active developer directory can be set using `xcode-select`, or via the
DEVELOPER_DIR environment variable. See the xcrun and xcode-select manual
pages for more information.Options:-h, --help                  show this help message and exit--version                   show the xcrun version-v, --verbose               show verbose logging output--sdk <sdk name>            find the tool for the given SDK name--toolchain <name>          find the tool for the given toolchain-l, --log                   show commands to be executed (with --run)-f, --find                  only find and print the tool path-r, --run                   find and execute the tool (the default behavior)-n, --no-cache              do not use the lookup cache-k, --kill-cache            invalidate all existing cache entries--show-sdk-path             show selected SDK install path--show-sdk-version          show selected SDK version--show-sdk-platform-path    show selected SDK platform path--show-sdk-platform-version show selected SDK platform version

xcrun的作用在于从一个激活的开发者目录(active developer directory)中查找一个command line tool,并执行这个工具。 

例如上面的Makefile中: GCC_BIN=`xcrun --sdk iphoneos --find gcc` 

分解来看: 

(1)xcrun --find gcc

$ xcrun --find gcc
/Applications/Xcode 5.1.1.app/Contents/Developer/usr/bin/gcc
这一步获取了gcc这个tool的路径,设为cmd_tool_path。 

(2)xcrun --sdk iphoneos cmd_tool_path 

这一步通过路径名获取到了具体的工具程序,这个工具对应iphoneos的SDK,并执行该工具。 

(3)GCC_BIN是一条shell命令,对应的就是这个查找和执行工具的过程。 


再如: xcrun --sdk iphoneos --show-sdk-path 

它的作用就是查找对应于iphoneos SDK的SDK并执行。

$ xcrun --show-sdk-path
/Applications/Xcode 5.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk $ xcrun --sdk iphoneos --show-sdk-path
/Applications/Xcode 5.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk

2.xcode-select

首先看看简单的帮助信息:

$ xcode-select -h
Usage: xcode-select [options]Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).Options:-h, --help                  print this help message and exit-p, --print-path            print the path of the active developer directory-s <path>, --switch <path>  set the path for the active developer directory-v, --version               print the xcode-select version-r, --reset                 reset to the default command line tools path

它的作用在于打印或改变active developer directory,而xcrun就是从这个directory中查找对应的工具。 通常它的值为:
/Applications/Xcode 5.1.1.app/Contents/Developer

例如,在/Applications/Xcode 5.1.1.app/Contents/Developer/usr/bin中,可以看到一些上文需要的gcc:
$ ls
BuildStrings          gcc               ndisasm
CpMac               gcov-4.2          opendiff
DeRez               git               projectInfo
GetFileInfo          git-cvsserver          resolveLinks
ImageUnitAnalyzer     git-receive-pack     scntool
MergePef          git-shell          sdef
MvMac               git-upload-archive     sdp
ResMerger          git-upload-pack          svn
Rez               gnumake               svnadmin
RezDet               hdxml2manxml          svndumpfilter
RezWack               headerdoc2html          svnlook
SetFile               ibtool               svnrdump
SplitForks          ibtool3               svnserve
TextureAtlas          ibtoold               svnsync
UnRezWack          ictool               svnversion
actool               instruments          symbols
agvtool               iprofiler          xcodebuild
amlint               ld               xcrun
以上只是部分输出。


注:以上是我个人在自己的机子上的砸壳经历,大家要根据自己的实际情况进行,详细请参考:用dumpdecrypted砸壳



这篇关于《iOS应用逆向工程》学习笔记(六)使用dumpdecrypted砸壳的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1004234

相关文章

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

中文分词jieba库的使用与实景应用(一)

知识星球:https://articles.zsxq.com/id_fxvgc803qmr2.html 目录 一.定义: 精确模式(默认模式): 全模式: 搜索引擎模式: paddle 模式(基于深度学习的分词模式): 二 自定义词典 三.文本解析   调整词出现的频率 四. 关键词提取 A. 基于TF-IDF算法的关键词提取 B. 基于TextRank算法的关键词提取

水位雨量在线监测系统概述及应用介绍

在当今社会,随着科技的飞速发展,各种智能监测系统已成为保障公共安全、促进资源管理和环境保护的重要工具。其中,水位雨量在线监测系统作为自然灾害预警、水资源管理及水利工程运行的关键技术,其重要性不言而喻。 一、水位雨量在线监测系统的基本原理 水位雨量在线监测系统主要由数据采集单元、数据传输网络、数据处理中心及用户终端四大部分构成,形成了一个完整的闭环系统。 数据采集单元:这是系统的“眼睛”,

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

Hadoop数据压缩使用介绍

一、压缩原则 (1)运算密集型的Job,少用压缩 (2)IO密集型的Job,多用压缩 二、压缩算法比较 三、压缩位置选择 四、压缩参数配置 1)为了支持多种压缩/解压缩算法,Hadoop引入了编码/解码器 2)要在Hadoop中启用压缩,可以配置如下参数

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

Makefile简明使用教程

文章目录 规则makefile文件的基本语法:加在命令前的特殊符号:.PHONY伪目标: Makefilev1 直观写法v2 加上中间过程v3 伪目标v4 变量 make 选项-f-n-C Make 是一种流行的构建工具,常用于将源代码转换成可执行文件或者其他形式的输出文件(如库文件、文档等)。Make 可以自动化地执行编译、链接等一系列操作。 规则 makefile文件

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

使用opencv优化图片(画面变清晰)

文章目录 需求影响照片清晰度的因素 实现降噪测试代码 锐化空间锐化Unsharp Masking频率域锐化对比测试 对比度增强常用算法对比测试 需求 对图像进行优化,使其看起来更清晰,同时保持尺寸不变,通常涉及到图像处理技术如锐化、降噪、对比度增强等 影响照片清晰度的因素 影响照片清晰度的因素有很多,主要可以从以下几个方面来分析 1. 拍摄设备 相机传感器:相机传