221页的demo iOSRETargetApp安装报错

我按照《iOS应用逆向工程(第2版)》221页的demo新建iOSRETargetApp,在终端运行““make package install”之后,终端报了几十个错误:

错误提示:
XXRootViewController.m:4:15: error: expected ‘;’ after top level declarator
Class CPPClass {
^
;
XXRootViewController.m:8:6: error: variable has incomplete type ‘void’
void CPPClass::CPPFunction(const char *arg0) {
^
XXRootViewController.m:8:14: error: expected ‘;’ after top level declarator
void CPPClass::CPPFunction(const char *arg0) {
^
;
XXRootViewController.m:8:15: error: expected identifier or ‘(’
void CPPClass::CPPFunction(const char *arg0) {
^
XXRootViewController.m:37:65: error: expected identifier or ‘(’
globallyUniqueString, processName]; NSStr…
^
XXRootViewController.m:38:13: error: expected identifier or ‘(’
for (int j = 0; j < pid; j++) {
^
XXRootViewController.m:41:19: error: expected parameter declarator
NSLog(@“iOSRE: CFunction: %s”, arg0);
^
XXRootViewController.m:41:19: error: expected ‘)’
XXRootViewController.m:41:18: note: to match this ‘(’
NSLog(@“iOSRE: CFunction: %s”, arg0);
^
XXRootViewController.m:41:13: error: type specifier missing, defaults to ‘int’
[-Werror,-Wimplicit-int]
NSLog(@“iOSRE: CFunction: %s”, arg0);
^
XXRootViewController.m:41:13: error: conflicting types for ‘NSLog’
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:519:24: note:
previous declaration is here
FOUNDATION_EXPORT void NSLog(NSString *format, …) NS_FORMAT_FUNCTION(1…
^
XXRootViewController.m:42:9: error: extraneous closing brace (‘}’)
}
^
XXRootViewController.m:43:16: error: expected identifier or ‘(’
extern “C” void ShortCFunction(const char *arg0) // ShortCFuncti…
^
XXRootViewController.m:53:21: error: expected ‘;’ after expression
CPPClass cppClass;
^
;
XXRootViewController.m:53:22: error: use of undeclared identifier ‘cppClass’
CPPClass cppClass;
^
XXRootViewController.m:54:13: error: use of undeclared identifier ‘cppClass’
cppClass.CPPFunction(“This is a C++ function!”); CFunction(“…
^
XXRootViewController.m:54:62: error: implicit declaration of function
‘CFunction’ is invalid in C99 [-Werror,-Wimplicit-function-declaration]
cppClass.CPPFunction(“This is a C++ function!”); CFunction(”…
^
XXRootViewController.m:54:98: error: implicit declaration of function
‘ShortCFunction’ is invalid in C99
[-Werror,-Wimplicit-function-declaration]
…is a C++ function!"); CFunction(“This is a C function!”); ShortCFunction…
^
XXRootViewController.m:53:13: error: expression result unused
[-Werror,-Wunused-value]
CPPClass cppClass;
^~~~~~~~
18 errors generated.
make[3]: *** [/Users/wangxiushuai/Desktop/221页demo/iosretargetapp/.theos/obj/debug/armv7/XXRootViewController.m.b40f1e1f.o] Error 1
make[2]: *** [/Users/wangxiushuai/Desktop/221页demo/iosretargetapp/.theos/obj/debug/armv7/iOSRETargetApp.app/iOSRETargetApp] Error 2
make[1]: *** [internal-application-all_] Error 2
make: *** [iOSRETargetApp.all.application.variables] Error 2

是XXRootViewController.m文件里面的代码就是复制的书上的啊

XXRootViewController.m代码:
#import “XXRootViewController.h”
Class CPPClass
{
public:
void CPPFunction(const char *);
};
void CPPClass::CPPFunction(const char *arg0)
{
for (int i = 0; i < 66; i++) // This for loop makes this function long enough to validate MSHookFunction
{
u_int32_t randomNumber;
if (i % 3 == 0) randomNumber = arc4random_uniform(i);
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSString *hostName = processInfo.hostName; int pid = processInfo.processIdentifier; NSString *globallyUniqueString =
processInfo.globallyUniqueString; NSString *processName =
processInfo.processName;
NSArray *junks = @[hostName,
globallyUniqueString, processName]; NSString *junk = @“”;
for (int j = 0; j < pid; j++) {
if (pid % 6 == 0) junk = junks[j % 3]; if (i % 68 == 1) NSLog(@“Junk: %@”, junk);
}
NSLog(@“iOSRE: CPPFunction: %s”, arg0);
}
extern “C” void CFunction(const char *arg0) {
for (int i = 0; i < 66; i++) // This for loop makes this function long enough to validate MSHookFunction
{
u_int32_t randomNumber;
if (i % 3 == 0) randomNumber = arc4random_uniform(i);
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSString *hostName = processInfo.hostName; int pid = processInfo.processIdentifier; NSString *globallyUniqueString =
processInfo.globallyUniqueString; NSString *processName =
processInfo.processName;
NSArray *junks = @[hostName,
}
globallyUniqueString, processName]; NSString *junk = @“”;
for (int j = 0; j < pid; j++) {
if (pid % 6 == 0) junk = junks[j % 3]; if (i % 68 == 1) NSLog(@“Junk: %@”, junk);
}
NSLog(@“iOSRE: CFunction: %s”, arg0);
}
extern “C” void ShortCFunction(const char *arg0) // ShortCFunction is too short to be hooked
{
CPPClass cppClass; cppClass.CPPFunction(arg0);
}
@implementation XXRootViewController - (void)loadView {
self.view = [[[UIView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]] autorelease];
self.view.backgroundColor = [UIColor redColor];
}
- (void)viewDidLoad {
[super viewDidLoad];
CPPClass cppClass;
cppClass.CPPFunction(“This is a C++ function!”); CFunction(“This is a C function!”); ShortCFunction(“This is a short C function!”);
} @end

来个大神指导我一下吧,谢谢

文件后缀改成mm

谢谢大神,后缀改了之后果然可以了

大神,我能问个很弱智的问题嘛

class CPPClass
{
public:
void CPPFunction(const char *);
};
void CPPClass::CPPFunction(const char *arg0)
{
}
extern “C” void CFunction(const char *arg0)
{
}
extern “C” void ShortCFunction(const char *arg0)
{
CPPClass cppClass; cppClass.CPPFunction(arg0);
}

这是声明了几个方法名吧,为什么格式和平时用的OC不太一体呢?您知道有介绍这方面的资料吗?或者说我想学一下我应该百度什么关键词?CPPFunction和后面的两个方法声明的时候不太一样,调用的时候格式也不太一样,是不是和这也有关系?

这是C++

:joy:这就尴尬了哈

大神,再问你个问题,书上说把Demo iOSRETargetApp的二进制文件丢进IDA里,这个二进制是怎么得到的?

不知道, 没看过

你make package install之后用scp或者ifunbox从你手机拷出来不完事

您能把scp的命令粘贴出来吗?我用ifunbox的时候,一打开我demo的路径ifunbox就闪退

scp /Applications/iOSTargetApp/Contents/MacOS/iOSTargetApp 电脑用户@电脑IP:~
路径不确定,自己grep看看

好的,谢谢您我试试