美文网首页
MonkeyDev逆向之旅(二)

MonkeyDev逆向之旅(二)

作者: 幻想无极 | 来源:发表于2019-06-20 11:43 被阅读0次

    前言

    MonkeyDev逆向之旅(一)

    我们已经初步使用了,但是和页面并没有交互,并不直观,接下啦我们写和UI交互相关的代码

    效果 E549927C167F099E4587C366CE969F8D.jpg

    代码

    #import <UIKit/UIKit.h>
    @interface FindViewController
    
    @property (nonatomic, strong) UIView* view;
    - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion;
    - (void)btnDidClicked;
    @end
    
    %hook FindCell
    - (void)setImageV:(id *)imageV{};
    - (void)setLabel:(id *)label{
        NSLog(@"你是不是傻");
    };
    %end
    
    %hook FindViewController
    - (void)tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 {
    NSLog(@"你是一个傻子");
    }
    
    
    - (void)viewDidLoad {
    %orig;
    
    CGFloat x = 50.0f;
    CGFloat y = 100.0f;
    UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, self.view.frame.size.width-x*2, 50)];
    
    [self.view addSubview:btn];
    
    [btn setTitle:@"back" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor blueColor];
    [btn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnDidClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    
    %new
    - (void)btnDidClicked {
    UIAlertController *alerView = [UIAlertController alertControllerWithTitle:@"提示"
    message:@"已经被HOOK了"
    preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *cancelAction =[UIAlertAction actionWithTitle:@"取消"
    style:UIAlertActionStyleCancel
    handler:nil];
    [alerView addAction:cancelAction];
    [self presentViewController:alerView animated:YES completion:nil];
    }
    %end
    
    

    参考

    https://www.jianshu.com/p/05361df6779f

    相关文章

      网友评论

          本文标题:MonkeyDev逆向之旅(二)

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