reverse engineering basics
play

Reverse engineering basics @KirilsSolovjovs on twitter Mg.sc.comp. - PowerPoint PPT Presentation

Reverse engineering basics @KirilsSolovjovs on twitter Mg.sc.comp. Kirils Solovjovs http://kirils.org for more Possible Security Reverse engineering? www.indiamart.com Contents Hardware architecture Processors and machine language


  1. Reverse engineering basics @KirilsSolovjovs on twitter Mg.sc.comp. Kirils Solovjovs http://kirils.org for more Possible Security

  2. Reverse engineering? www.indiamart.com

  3. Contents ● Hardware architecture ● Processors and machine language ● Engineering: Creating a program binary ● Reverse engeineering: – Static analysis – Binary debugging Kirils Solovjovs, 10/07/2018 Reverse engineering basics 3/25 possiblesecurity.com

  4. Hardware architecture Kirils Solovjovs, 10/07/2018 Reverse engineering basics 4/25 possiblesecurity.com

  5. Theory. Turing machine Kirils Solovjovs, 10/07/2018 Reverse engineering basics 5/25 possiblesecurity.com

  6. ENIAC, 1945 ● Turing complete ● General purpose ● “Reprogrammable” – Physical rewiring required – Takes weeks Kirils Solovjovs, 10/07/2018 Reverse engineering basics 6/25 possiblesecurity.com

  7. The two common hardware architectures Kirils Solovjovs, 10/07/2018 Reverse engineering basics 7/25 possiblesecurity.com

  8. Von Neumann arch ● “Stored program” concept ● CPU = CU + ALU ● Joint MU ● I/O ● Most modern systems Kirils Solovjovs, 10/07/2018 Reverse engineering basics 8/25 possiblesecurity.com

  9. Harvard arch ● Separate CU and ALU ● Separate memories ALU Data – Instructions – Instruction Data Control ● Allows memories to have memory memory unit different attributes ● Improved speed I/O ● DSPs, some microcontrollers Kirils Solovjovs, 10/07/2018 Reverse engineering basics 9/25 possiblesecurity.com

  10. Machine code ● A list of machine language instructions to be directly executed by a CPU. ● Each instruction is a small specifjc task: – Data operations – Arithmetic and logic operations – Control fmow operations ● Different ISAs (Instruction set architectures): – 8086, ARM, MIPS, VAX, ... Kirils Solovjovs, 10/07/2018 Reverse engineering basics 10/25 possiblesecurity.com

  11. Instruction MIPS32 Add Immediate Instruction 001000 00001 00010 0000000101011110 OP Code Addr 1 Addr 2 Immediate value addi $r1 , $r2 , 350 Equivalent mnemonic: Kirils Solovjovs, 10/07/2018 Reverse engineering basics 11/25 possiblesecurity.com

  12. x86 opcodes Kirils Solovjovs, 10/07/2018 Reverse engineering basics 12/25 possiblesecurity.com

  13. Note: virtual address space Virtual address space Physical address space ● Each 32bit program “sees” 0x00000000 0x00010000 4GiB of virtual address text 0x00000000 space available to them. 0x10000000 ● Virtual addresses are the data same for every instance of a process * before ASLR 0x00ffffff stack page belonging to process 0x7fffffff page not belonging to process Kirils Solovjovs, 10/07/2018 Reverse engineering basics 13/25 possiblesecurity.com

  14. Stack and heap ● Where are variables stored then? – Stack and heap ● Heap: for dynamic allocation, random access ● Stack: for static memory allocation Kirils Solovjovs, 10/07/2018 Reverse engineering basics 14/25 possiblesecurity.com

  15. Creating a program binary Kirils Solovjovs, 10/07/2018 Reverse engineering basics 15/25 possiblesecurity.com

  16. Overview: gcc example ● .c, .h – human readable C ● .s – human readable assembly ● .o – binary object code (relocatable object code) ● a.out – directly executable machine code Kirils Solovjovs, 10/07/2018 Reverse engineering basics 16/25 possiblesecurity.com

  17. DEMO: gcc example ● Compile: gcc -S fjle.c -o fjle.s – ● Assemble (&optimize): gcc -c fjle.s -o fjle.o – ● Link: gcc fjle.o -o fjle – Kirils Solovjovs, 10/07/2018 Reverse engineering basics 17/25 possiblesecurity.com

  18. Reverse engineering Kirils Solovjovs, 10/07/2018 Reverse engineering basics 18/25 possiblesecurity.com

  19. Full cycle Kirils Solovjovs, 10/07/2018 Reverse engineering basics 19/25 possiblesecurity.com

  20. DEMO: Static analysis of password ● strings r2 ● r2 password – pdf @ main Kirils Solovjovs, 10/07/2018 Reverse engineering basics 20/25 possiblesecurity.com

  21. DEMO: Static analysis of Android APK ● binwalk ● dex2jar + jd-gui Kirils Solovjovs, 10/07/2018 Reverse engineering basics 21/25 possiblesecurity.com

  22. DEMO: Binary debugging of test42 ● gdb test42 – info fjles – b *main if not stripped ● – start – info registers – x/i $pc Kirils Solovjovs, 10/07/2018 Reverse engineering basics 22/25 possiblesecurity.com

  23. DEMO: Firmware reverse engineering ● Real life example – mt Kirils Solovjovs, 10/07/2018 Reverse engineering basics 23/25 possiblesecurity.com

  24. Overview of tools ● gdb ● otool ● Capstone ● PE Explorer ● radare2 ● binwalk ● IDA-Pro & Hex-Rays ● dex2jar & JD-GUI ● Binary Ninja ● Resource Hacker ● OllyDbg Kirils Solovjovs, 10/07/2018 Reverse engineering basics 24/25 possiblesecurity.com

  25. Thanks! Slides are available on http://kirils.org Find me on twitter: @KirilsSolovjovs Kirils Solovjovs, 10/07/2018 Reverse engineering basics 25/25 possiblesecurity.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend