• 【iOS逆向与安全】插件开发之某音App直播间自动发666


    1.目标

    由于看直播的时候主播叫我发 666,支持他,我肯定支持他呀,就一直发,可是后来发现太浪费时间了,能不能做一个直播间自动发 666 呢?于是就花了几分钟做了一个。

    2.操作环境
     3.流程

    下载最新某音App

    既然是发送消息,那关键词 sendmessage 则是我们的切入点

    在终端执行
    1. //模糊匹配sendmessage
    2. frida-trace -U -m "*[* *messag*]" xxxxx音

    执行命令后,获取到信息列表:

    经过一筛查打印以上方法的入参和返回值,输出的日志参数,引起了我们的注意

    关键信息:sendComment
    -[HTSLiveCommentFragment sendComment:0x9e4d4021463d8688 source:0x0 messageSource:0x0 completion:0x0]

    验证我们的猜想

    在终端执行,继续 hook

    frida-trace -UF  -m "-[HTSLiveCommentFragment sendComment:source:messageSource:completion:]"

    获取到信息列表:

     -[HTSLiveCommentFragment sendComment:666666666 source:0x0 messageSource:0x0 completion:0x0]

    其中“6666666” 就我在直播间发送的内容

    那么问题来了,发现这个发送方法是 减号 -[xxxx xxxxxx]

    这样就没法直接调用 HTSLiveCommentFragment

    那就继续 hook  HTSLiveCommentFragment,看看她是在哪里创建的

    在终端执行,继续 hook
    frida-trace -UF -m "-[HTSLiveCommentFragment *]"

    获取到信息列表: 

    1. 3964 ms -[HTSLiveCommentFragment initWithStore:0x2836ef200]
    2. 3964 ms -[HTSLiveCommentFragment initWithStore:0x2836ef200>]

     发现 HTSLiveCommentFragment 是由 initWithStore 创建而来。

    那就直接 hook 创建,在调用sendComment  来实现发送消息。

    3、编写deb插件 logs

    1. NSString *nickname=@"未获取昵称";
    2. HTSLiveCommentFragment *liveComm;//全局 储存创建好的对象 类
    3. %hook HTSLiveCommentFragment
    4. //HTSLiveCommentStore
    5. - (HTSLiveCommentFragment *)initWithStore:(id)arg1{
    6. // id mHTSLiveUser = MSHookIvar(arg1,"_currentUse");//HTSLiveUser
    7. // NSString *name = MSHookIvar(mHTSLiveUser,"nickname");
    8. // nickname =name;
    9. liveComm = %orig;//获取到创建好的对象 类(每切换一次,自动覆盖
    10. return liveComm;
    11. }
    12. %end
     获取直播页面

    HTSLiveAudienceViewController,给他添加一个按钮

     页面添加小圆圆 按钮
    1. BallUIView *upASUserInfo;//移动圆圆
    2. //直播页面 Controller
    3. %hook HTSLiveAudienceViewController
    4. - (void)viewDidLoad{
    5. %orig;// 页面加载完毕
    6. __weak typeof(self) weakSelf = self;
    7. if(upASUserInfo == nil){
    8. //配置
    9. CGRect rect_screen = [[UIScreen mainScreen]bounds];
    10. CGSize size_screen = rect_screen.size;
    11. int height = size_screen.height;
    12. int width = size_screen.width;
    13. // 移动圆圆
    14. upASUserInfo = [[BallUIView alloc] initWithFrame:CGRectMake(width-80, height/2-200, 50, 50)];
    15. upASUserInfo.backgroundColor = [UIColor whiteColor];
    16. upASUserInfo.layer.cornerRadius = 25;
    17. upASUserInfo.layer.masksToBounds = YES;
    18. //小圆球 图标
    19. UIImageView *imgViewM = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AppIcon60x60@2x.png"]];
    20. imgViewM.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    21. imgViewM.frame = CGRectMake(0, 0, 50, 50);
    22. [upASUserInfo insertSubview:imgViewM atIndex:0];
    23. }
    24. [weakSelf.view addSubview:upASUserInfo];
    25. upASUserInfo.btnClick = ^(UIButton *sender) {
    26. UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"当前标识"
    27. message:nickname
    28. preferredStyle:UIAlertControllerStyleAlert];
    29. UIAlertAction *ala1 = [UIAlertAction actionWithTitle:@"666666" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
    30. }];
    31. UIAlertAction *ala2 = [UIAlertAction actionWithTitle:@"发送消息" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
    32. [xddCode userInfoModel:liveComm];//传入获取到的 对象,发送消息
    33. }];
    34. UIAlertAction *ala3 = [UIAlertAction actionWithTitle:@"退出应用" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action){
    35. exit(0);
    36. }];
    37. UIAlertAction *Cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    38. }];
    39. [ac addAction:ala1];
    40. [ac addAction:ala2];
    41. [ac addAction:ala3];
    42. [ac addAction:Cancel];
    43. [weakSelf presentViewController:ac animated:YES completion:nil];
    44. };
    45. }
    46. %end

     

    xddCode.m

    1. #import "xddCode.h"
    2. @implementation xddCode
    3. +(NSString *) userInfoModel:(HTSLiveCommentFragment*)info {
    4. [info sendComment:@"666666666" source:0x0 messageSource:0x0 completion:0x0];
    5. }
    6. @end

    小园球源码

    BallUIView.h

    1. #import
    2. typedef void (^floatBtnClick)(UIButton *sender);
    3. NS_ASSUME_NONNULL_BEGIN
    4. @interface BallUIView : UIView
    5. // 属性 机,记录起点
    6. @property(nonatomic,assign)CGPoint startPoint;
    7. //按钮点击事件
    8. @property (nonatomic, copy)floatBtnClick btnClick;
    9. @end
    10. NS_ASSUME_NONNULL_END

    BallUIView.m

    1. #import "BallUIView.h"
    2. #define screenW [UIScreen mainScreen].bounds.size.width
    3. #define screenH [UIScreen mainScreen].bounds.size.height
    4. @interface BallUIView()
    5. //悬浮的按钮
    6. //@property (nonatomic, strong) MNFloatContentBtn *floatBtn;
    7. @end
    8. @implementation BallUIView{
    9. //拖动按钮的起始坐标点
    10. CGPoint _touchPoint;
    11. //起始按钮的x,y值
    12. CGFloat _touchBtnX;
    13. CGFloat _touchBtnY;
    14. }
    15. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    16. {
    17. // NSLog(@"按下 获取起点1");
    18. //获取 触摸 对象
    19. UITouch *touch = [touches anyObject];
    20. _touchBtnX = self.frame.origin.x;
    21. _touchBtnY = self.frame.origin.y;
    22. //找到点击的起点
    23. self.startPoint = [touch locationInView:self];
    24. }
    25. -(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    26. {
    27. // NSLog(@"移动 让小球的运动起来2");
    28. //先回去 触摸对象
    29. UITouch * touch = [touches anyObject];
    30. //获取移动中的点
    31. CGPoint newPoint = [touch locationInView:self];
    32. //计算x y 坐标分别移动了多少
    33. CGFloat dx = newPoint.x - self.startPoint.x;
    34. CGFloat dy = newPoint.y - self.startPoint.y;
    35. //改变小球的位置
    36. self.center = CGPointMake(self.center.x + dx,
    37. self.center.y + dy);
    38. }
    39. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    40. // NSLog(@"按下 结束3");
    41. CGFloat btnY = self.frame.origin.y;
    42. CGFloat btnX = self.frame.origin.x;
    43. CGFloat minDistance = 3;
    44. //结束move的时候,计算移动的距离是>最低要求,如果没有,就调用按钮点击事件
    45. BOOL isOverX = fabs(btnX - _touchBtnX) > minDistance;
    46. BOOL isOverY = fabs(btnY - _touchBtnY) > minDistance;
    47. if (isOverX || isOverY) {
    48. //超过移动范围就不响应点击 - 只做移动操作
    49. //NSLog(@"move - btn");
    50. //设置移动方法
    51. [self setMovingDirectionWithBtnX:btnX btnY:btnY];
    52. }else{
    53. //NSLog(@"call - btn");
    54. if (self.btnClick) {
    55. self.btnClick(nil);
    56. }else{
    57. //[self changeEnv];
    58. }
    59. }
    60. }
    61. static CGFloat floatBtnW = 50;
    62. static CGFloat floatBtnH = 50;
    63. - (void)setMovingDirectionWithBtnX:(CGFloat)btnX btnY:(CGFloat)btnY{
    64. // switch (_type) {
    65. // case MNAssistiveTypeNone:{
    66. //自动识别贴边
    67. if (self.center.x >= screenW/2) {
    68. [UIView animateWithDuration:0.5 animations:^{
    69. //按钮靠右自动吸边
    70. CGFloat btnX = screenW - floatBtnW;
    71. self.frame = CGRectMake(btnX, btnY, floatBtnW, floatBtnH);
    72. }];
    73. }else{
    74. [UIView animateWithDuration:0.5 animations:^{
    75. //按钮靠左吸边
    76. CGFloat btnX = 0;
    77. self.frame = CGRectMake(btnX, btnY, floatBtnW, floatBtnH);
    78. }];
    79. }
    80. // break;
    81. // }
    82. // case MNAssistiveTypeNearLeft:{
    83. // [UIView animateWithDuration:0.5 animations:^{
    84. // //按钮靠左吸边
    85. // CGFloat btnX = 0;
    86. // self.frame = CGRectMake(btnX, btnY, floatBtnW, floatBtnH);
    87. // }];
    88. // break;
    89. // }
    90. // case MNAssistiveTypeNearRight:{
    91. // [UIView animateWithDuration:0.5 animations:^{
    92. // //按钮靠右自动吸边
    93. // CGFloat btnX = screenW - floatBtnW;
    94. // self.frame = CGRectMake(btnX, btnY, floatBtnW, floatBtnH);
    95. // }];
    96. // }
    97. // }
    98. }
    99. /*
    100. // Only override drawRect: if you perform custom drawing.
    101. // An empty implementation adversely affects performance during animation.
    102. - (void)drawRect:(CGRect)rect {
    103. // Drawing code
    104. }
    105. */
    106. @end
      最后

    就可以愉快的玩耍了,主播以后再也不会说我不支持他了。

  • 相关阅读:
    基于机器视觉的二维码识别检测 - opencv 二维码 识别检测 机器视觉 计算机竞赛
    X86指令基础系列教程
    微信小程序 工具使用(HBuilderX)
    Python学习之CSDN21天学习挑战赛计划之4
    Windows io完成端口
    怎样部署好MiniO分布式文件存储
    开源办公OA平台教程:SmartBI集成版快速部署及使用(O2OA容器化部署)
    972信息检索 | 第二章 信息检索的方法和技术
    范式建模&维度建模 及结合BW的一些理解
    数据库第一、二章作业
  • 原文地址:https://blog.csdn.net/qq_21051503/article/details/133138838