Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Resolvendo problemas com disassembly no IOS.

Resolvendo problemas com disassembly no IOS.

Resolvendo problemas com disassembly no IOS.

rafabertholdo

March 28, 2017

Transcript

22 slides
  1. • Engenheiro de software @ Ci&T • Guitarra • Aion

    e Dota nas horas vagas • Delphi, C++, Assembly, PHP, Java, C#.net, Ruby, Objective C • github.com/rafabertholdo • [email protected] Rafael Bertholdo
  2. Nem sempre a documentação é suficiente, ou quem fez a

    biblioteca ou executável não quer que você saiba o que a caixa preta faz. Porque
  3. • Linguagens que geram código intermediário ◦ .net -> dotPeek

    (free) ◦ Java -> jD (free) • Linguagens que geram código específico do hardware ◦ OSX ▪ Hopper disassembly (R$326,01) ◦ Windows ▪ PE Explorer ▪ X64dbg ▪ olyDbg ◦ Unix ▪ otool ◦ Cross-platform ▪ IDA + Hex-ray (U$589 ~ U$2350) Como
  4. In C# class instances are created like this: Car myCar

    = new Car(1, 4); Car yourCar = new Car(1, 3); And these statements are roughly the same as these instructions: ldc.i4.1 ldc.i4.4 newobj instance void Car::.ctor(int, int) stloc.0 // myCar = new Car(1, 4); ldc.i4.1 ldc.i4.3 newobj instance void Car::.ctor(int, int) stloc.1 // yourCar = new Car(1, 3); Microsoft Intermediate Language (MSIL)
  5. Com UITextField em modo senha, ao perder o foco e

    voltar, o componente limpa o campo todo. Exemplo
  6. “Method swizzling is the process of changing the implementation of

    an existing selector.” Matt Thompson Extra: Method Swizzling
  7. #import <objc/runtime.h> @implementation UIViewController (Tracking) + (void)load { static dispatch_once_t

    onceToken; dispatch_once(&onceToken, ^{ //Swizzling happens here }); } - (void)xxx_viewWillAppear:(BOOL)animated { [self xxx_viewWillAppear:animated]; NSLog(@"viewWillAppear: %@", self); } @end
  8. Class class = [self class]; SEL originalSelector = @selector(viewWillAppear:); SEL

    swizzledSelector = @selector(xxx_viewWillAppear:); Method originalMethod = class_getInstanceMethod(class, originalSelector); Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); if (didAddMethod) { class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); } else { method_exchangeImplementations(originalMethod, swizzledMethod); }

More Decks by rafabertholdo

Other Decks in Technology