Gain a solid understanding of how Linux C and C++ compilers generate binary code. This book explains the reversing and binary analysis of ARM64 architecture now used by major Linux cloud providers and covers topics ranging from writing programs in assembly language, live debugging, and static binary analysis of compiled C and C++ code. It is ideal for those working with embedded devices, including mobile phones and tablets.
Using the latest version of Red Hat, you'll look closely at the foundations of diagnostics of core memory dumps, live and postmortem debugging of Linux applications, services, and systems. You'll also work with the GDB debugger and use it for disassembly and reversing. This book uses practical step-by-step exercises of increasing complexity with explanations and many diagrams, including some necessary background topics. In addition, you will be able to analyze such code confidently, understand stack memory usage, and reconstruct original C/C++ code.
And as you'll see, memory forensics, malware, and vulnerability analysis, require an understanding of ARM64 assembly language and how C and C++ compilers generate code, including memory layout and pointers. This book provides the background knowledge and practical foundations you'll need to understand internal Linux program structure and behavior.
Foundations of ARM64 Linux Debugging, Disassembling, and Reversing is the perfect companion to Foundations of Linux Debugging, Disassembling, and Reversing for readers interested in the cloud or cybersecurity.
What You'll Learn- Review the basics of ARM64 assembly language
- Examine the essential GDB debugger commands for debugging and binary analysis
- Study C and C++ compiler code generation with and without compiler optimizations
- Look at binary code disassembly and reversing patterns
- See how pointers in C and C++ are implemented and used
Who This Book Is ForSoftware support and escalation engineers, cloud security engineers, site reliability engineers, DevSecOps, platform engineers, software testers, Linux C/C++ software engineers and security researchers without ARM64 assembly language background, and beginners learning Linux software reverse engineering techniques.
Chapter 1 - A64.1: Memory, Registers, and Simple Arithmetic.- Chapter 2 - A64.2: Code Optimization.- Chapter 3 - A64.3: Number Representations.- Chapter 4 - A64.4: Pointers.-Chapter 5 - A64.5: Bytes, Half Words, Words, and Double Words.- Chapter 6 - A64.6: Pointers to Memory.- Chapter 7 - A64.7: Logical Instructions and PC.- Chapter 8 - A64.8: Reconstructing a Program with Pointers.- Chapter 9 - A64.9: Memory and Stacks.- Chapter 10 - A64.10: Frame Pointer and Local Variables.- Chapter 11- A64.11: Function Parameters.- Chapter 12 - A64.12: More Instructions.- Chapter 13 - A64.13: Function Pointer Parameters.- Chapter 14 - A64.14: Summary of Code Disassembly Patterns.
Dmitry Vostokov is an internationally recognized expert, speaker, educator, scientist, inventor, and author. He is the founder of the pattern-oriented software diagnostics, forensics, and prognostics discipline (Systematic Software Diagnostics), and Software Diagnostics Institute (DA+TA: DumpAnalysis.org + TraceAnalysis.org). Vostokov has also authored books on software diagnostics, anomaly detection and analysis, software and memory forensics, root cause analysis and problem solving, memory dump analysis, debugging, software trace and log analysis, reverse engineering, and malware analysis. He has over 25 years of experience in software architecture, design, development, and maintenance in various industries, including leadership, technical, and people management roles. In his spare time, he presents various topics on Debugging.TV and explores Software Narratology, its further development as Narratology of Things and Diagnostics of Things (DoT), Software Pathology, and Quantum Software Diagnostics. His current interest areas are theoretical software diagnostics and its mathematical and computer science foundations, application of formal logic, artificial intelligence, machine learning, and data mining to diagnostics and anomaly detection, software diagnostics engineering and diagnostics-driven development, diagnostics workflow, and interaction. Recent interest areas also include cloud native computing, security, automation, functional programming, and applications of category theory to software development and big data. He is based out of Dublin, Ireland.
Inhaltsverzeichnis
Chapter 1 - A64.1: Memory, Registers, and Simple Arithmetic11
Memory and Registers inside an Idealized Computer11
Memory and Registers inside ARM 64-bit Computer12
"Arithmetic" Project: Memory Layout and Registers13
"Arithmetic" Project: A Computer Program14
"Arithmetic" Project: Assigning Numbers to Memory Locations15
Assigning Numbers to Registers18
"Arithmetic" Project: Adding Numbers to Memory Cells19
Incrementing/Decrementing Numbers in Memory and Registers22
Multiplying Numbers25
Chapter 2 - A64.2: Code Optimization29
"Arithmetic" Project: C/C++ Program29
Downloading GDB31
GDB Disassembly Output - No Optimization32
GDB Disassembly Output - Optimization37
Chapter 3 - A64.3: Number Representations39
Numbers and Their Representations39
Decimal Representation (Base Ten)40
Ternary Representation (Base Three)41
Binary Representation (Base Two)42
Hexadecimal Representation (Base Sixteen)43
Why are Hexadecimals Used?44
Chapter 4 - A64.4: Pointers47
A Definition47
"Pointers" Project: Memory Layout and Registers48
"Pointers" Project: Calculations50
Using Pointers to Assign Numbers to Memory Cells51
Adding Numbers Using Pointers58
Incrementing Numbers Using Pointers62
Multiplying Numbers Using Pointers65
Chapter 5 - A64.5: Bytes, Half Words, Words, and Double Words69
Using Hexadecimal Numbers69
Byte Granularity70
Bit Granularity71
Memory Layout72
Chapter 6 - A64.6: Pointers to Memory75
Pointers Revisited75
Addressing Types76
Registers Revisited81
NULL Pointers82
Invalid Pointers83
Variables as Pointers84
Pointer Initialization85
Initialized and Uninitialized Data86
More Pseudo Notation87
"MemoryPointers" Project: Memory Layout88
Chapter 7 - A64.7: Logical Instructions and PC99
Instruction Format99
Logical Shift Instructions100
Logical Operations101
Zeroing Memory or Registers102
Instruction Pointer103
Code Section105
Chapter 8 - A64.8: Reconstructing a Program with Pointers107
Example of Disassembly Output: No Optimization107
Reconstructing C/C++ Code: Part 1110
Reconstructing C/C++ Code: Part 2112
Reconstructing C/C++ Code: Part 3114
Reconstructing C/C++ Code: C/C++ program116
Example of Disassembly Output: Optimized Program117
Chapter 9 - A64.9: Memory and Stacks119
Stack: A Definition119
Stack Implementation in Memory120
Things to Remember122
Stack Push Implementation123
Stack Pop Implementation124
Register Review125
Application Memory Simplified126
Stack Overflow127
Jumps128
Calls130
Call Stack131
Exploring Stack in GDB133
Chapter 10 - A64.10: Frame Pointer and Local Variables137
Stack Usage137
Register Review138
Addressing Array Elements139
Stack Structure (No Function Parameters)140
Function Prolog141
Raw Stack (No Local Variables and Function Parameters)142
Function Epilog144
"Local Variables" Project145
Disassembly of Optimized Executable148
Chapter 11- A64.11: Function Parameters149
"FunctionParameters" Project149
Stack Structure150
Function Prolog and Epilog152
Project Disassembled Code with Comments154
Parameter Mismatch Problem158
Chapter 12 - A64.12: More Instructions159
PSTATE Flags159
Testing for 0160
TST - Logical Compare161
CMP - Compare Two Operands162
TST or CMP?163
Conditional Jumps164
Function Return Value165
Chapter 13 - A64.13: Function Pointer Parameters167
"FunctionPointerParameters" Project167
Commented Disassembly168
Chapter 14 - A64.14: Summary of Code Disassembly Patterns173
Function Prolog / Epilog173
ADR (Address)174
Passing Parameters175
Accessing Saved Parameters and Local Variables176
Explains reversing and binary analysis of ARM64 architecture now used by major Linux cloud providers
Provides pictures and diagrams that illustrate concepts and code
Provides hands-on exercises for assembly programming, compiler code generation, disassembly, and binary reversing