ios逆向

iOS逆向工具之class-dump(MacOS)介绍

2019-12-30  本文已影响0人  木子心语

class-dump

class-dump官网 github地址

以上是两种下载方式,可以通过官网下载安装,也可以通过github下载后使用.

class-dump dmg

1 可以看到class-dump 可执行文件
2 class-dump的版本已经更新到了3.5版本
3 src文件:class-dump的编译源码
4 github下载同样是class-dump编译源码

小伙伴有可能能遇到下面这个问题

cp: /usr/bin/class-dump: Operation not permitted

因为你选了路径是usr/bin ,如果遇到这个问题,我们可以换成路径为usr/local/bin中

我们需要把class-dump可执行文件拷贝到/usr/local/bin文件中.

class-dump

注意
1 可以看到红框是配合class-dump 具体使用的参数
2 如果你在执行class-dump的时候,提示权限不够
3 你可以进行加权限: sudo chmod 777 /usr/local/bin/class-dump

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic,strong)UIButton *revealBtn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.view addSubview:self.revealBtn];
}

-(UIButton*)revealBtn{
    if (!_revealBtn) {
        _revealBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _revealBtn.frame = CGRectMake(100,100, 100,40);
        _revealBtn.backgroundColor = [UIColor redColor];
        [_revealBtn setTitle:@"测试" forState:UIControlStateNormal];
        [_revealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    return _revealBtn;
}

@end

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@end

class-dump -s -S -H /Users/用户名/Desktop/TEST -o /Users/用户名/Desktop/TestHeader

这个命令的意思是把可执行文件TEST中头文件dump后保存到TestHeader中

执行完成
我们看到执行成功了 TestHeader

我们可以看到,AppDelegate.h,ViewController.h等头文件.

AppDelegate.h

#import "UIResponder.h"

#import "UIApplicationDelegate.h"

@class NSString, UIWindow;

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
    UIWindow *_window;
}

- (void).cxx_destruct;
- (_Bool)application:(id)arg1 didFinishLaunchingWithOptions:(id)arg2;
- (void)applicationDidBecomeActive:(id)arg1;
- (void)applicationDidEnterBackground:(id)arg1;
- (void)applicationWillEnterForeground:(id)arg1;
- (void)applicationWillResignActive:(id)arg1;
- (void)applicationWillTerminate:(id)arg1;
@property(retain, nonatomic) UIWindow *window; // @synthesize window=_window;

// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;

@end

ViewController.h

#import "UIViewController.h"

@class UIButton;

@interface ViewController : UIViewController
{
    UIButton *_revealBtn;
}

- (void).cxx_destruct;
@property(retain, nonatomic) UIButton *revealBtn; // @synthesize revealBtn=_revealBtn;
- (void)viewDidLoad;

@end

注意
有没有发现,我们很容易的获取到了TEST项目中的头文件.
这里总结一下
1 我们项目创建的简单,导出的类也就清晰明了
2 我们拿到可执行文件,我们通过自己打包的项目,我们可不是在AppStore下载的应用,你有可能忽略这一点,我们才dump很轻松.
3 如果我们从AppStore下载的应用,我们应该通过砸壳后,才能使用可执行文件,然后接着class-dump可执行文件.
4 我们下一篇文章要介绍砸壳工具的使用.
5 如果没有执行成功,你需要配置一下class-dump环境.

总结

上一篇下一篇

猜你喜欢

热点阅读