Notes - MCS
Reverse Engineering
Notes - MCS
Reverse Engineering
  • Reverse Engineering
  • Introduction to Reverse Engineering
    • What is Reverse Engineering (RE)
    • RE Concepts
    • When do we have RE activities?
    • Why RE is Relevant and Required
    • Limitations of RE
    • Legal Framework
    • What RE Recovers?
    • Software Reversing
    • Low-level languages
  • Files and Filetypes
    • Files
    • File extensions
    • File Signature
    • Content Type Obfuscation
  • Android – Static Analysis
    • Java Language
    • Application Entry Points
    • Application Structure
    • AndroidManifest.xml
    • Exercise 1
    • Exercise 2
    • Exercise 3
    • Exercise 4
    • Native Applications
    • Java Native Interface
    • Android Native Development Kit (NDK)
    • Android binary libraries
    • JNI Dynamic Linking
    • JNI Static Linking
    • Exercise 5 and 6
    • Web and Hybrid applications
  • Android – Dynamic Analysis
    • Dynamic Analysis
    • Logs
    • Network MiTM
    • Certificate Pinning
    • Dynamic Code Instrumentation
    • Dynamic Binary Instrumentation
    • FRIDA
  • Binary Analysis
    • Binary Objects
    • Executable Symbols
    • What is inside an Object File?
    • ELF Files
    • ELF Program Headers
    • Dynamic Linker
      • Example
    • Binary Analysis Process
    • Function detection
    • Calling Conventions
    • Common Logic Structures
    • C++ code
  • Emulation and Instrumentation
    • Dynamic Binary Analysis
    • Considerations
    • Processes
    • Dynamic Binary Instrumentation (DBI)
    • DBI with Qiling
  • Obfuscation Techniques
    • Obfuscation Techniques
    • Content Type Obfuscation
    • Code Obfuscation
  • Serial Communication
    • Comunicação paralelo
    • Comunicação série
    • Sincronização entre transmissor e recetor
    • Sincronização de relógio
    • Transmissão de dados
    • Topologias de comunicação série
    • Elementos de uma ligação série
  • A interface RS-232C
    • RS-232C
    • Estrutura da trama
    • Camada física
    • Taxa de transmissão (baudrate)
    • Receção de dados
    • Identificar parâmetros de comunicaçãoIdentificar parâmetros de comunicação
    • Encontrar a UART
    • Captura de sinais
  • Norma SPI
    • Introdução
    • Descrição geral
    • Operação
    • Simulação do master SPI
    • Arquiteturas de ligação
    • Tipos de transferências
    • Configuração de um master SPI
    • Procedimento para identificação dos sinais
    • Exemplo
  • Norma I2C
    • Introdução
    • Caraterísticas básicas
    • Exemplo de interligação num barramento I2C
    • Terminologia
    • Masters e Slaves
    • Sinalização
    • Endereçamento
    • Transferência de dados
    • Clock stretching
    • Múltiplos masters
    • Arbitragem
    • Endereços reservados
Powered by GitBook
On this page
  • Smali and Baksmali
  • HelloWorld.smali
  • Hello Android App
  • Obfuscation
  • Objectives
  • How to enable
  1. Android – Static Analysis

Exercise 2

Last updated 1 year ago

Smali and Baksmali

Assembler/disassembler for the DEX format used by Dalvik.

  • smali = "assembly" of the DEX bytecode.

  • backsmaling = decompiling to smali.

Allows converting a DEX blob to something “more human friendly”.

  • Similar to Assembly language in a common CPU.

Why? Isn’t DEX <- -> class possible?

  • With recent compiler optimizations (and Kotlin, and obfuscation) not always.

  • It’s possible to compile DEX (smali) -> class -> Java, but the code may not be correct.

  • Use of smali enables patching DEX bytecode directly (although it’s more complex).

HelloWorld.smali

Hello Android App

Obfuscation

Quite a few DEX “obfuscators” exist, with different approaches:

  • Functionally similar to binutils’ strip, either java (ProGuard) or sDEX.

  • Rename methods, fields and class names.

  • Break down string operations to “chop” hard-coded strings, or encrypt them.

  • Can use dynamic class loading (DexLoader classes) to impede static analysis.

  • Can add dead code and dummy loops (with minor impact on performance).

  • Can also use goto into other instructions (or switches).

Additional advantage: As obfuscators remove dead code, applications become smaller.

In practice, obfuscation is quite limited, due to:

  • Reliance on Android Framework APIs (which remain unobfuscated).

  • JDWP and application debuggability at the Java level.

  • If Dalvik can execute it, so can a proper analysis tool.

  • Popular enough obfuscators have de-obfuscators...

  • Cannot obfuscate Activities.

About 25% of applications have some form of obfuscation.

Objectives

Code shrinking (or tree-shaking): detects and safely removes unused classes, fields, methods, and attributes.

Resource shrinking: removes unused resources from a packaged app, including unused resources in the app’s library dependencies.

Obfuscation: shortens the name of classes and members, which results in reduced DEX file sizes.

Optimization: inspects and rewrites your code to further reduce the size of your app’s DEX files.

  • Unreachable code is removed from the application.

How to enable