Assembly Language Basic
Bit - This is the smallest piece of data. It can be a 0 or 1 or Off or ON.
Byte - a byte is 8 bits. It has a range of equivalent decimal values of 0 to 255
Word - a word is two bytes together or 16 bits
Double Word - a double word is tow words or 32 bits
Kilobyte - a kilobyte is 1024 (32 * 32) bytes
Megabyte - a megabyte is is 1,048,578 bytes (1024 x 1024).
Regsitry:
These registers are;
EAX - Extended Accumulator Register
EBX - Extended Base Register
ECX - Extended Counter Register
EDX - Extended Data Register
ESI - Extended Source Index
EDI - Extended Destination Index
EBP - Extended Base Pointer
ESP - Extended Stack Pointer
EIP - Extended Instruction Pointer
Flags
Flags are a single bit that indicates status of a register. The flag register on modern 32 bit CPU's is 32 bits long. There are 32 flags. In our studies here, we will only need three of them; (1) the Z flag, the O flag and the C flag.
A flag can only be SET or NOT SET
Z-Flag
The Z-flag (zero flag) is the most useful flag for cracking. It is used in about 90% of all cases. It can be set or cleared by several opcodes when the last instruction that was performed has 0 as a result
O-Flag
The O-flag (overflow flag) is used in about 4% of all cracking attempts. It is set when the last operation changed the highest bit of the register that gets the result of an operation.
C-Flag
The C-Flag (carry Flag) is used in about 1% of all cracking attempts. It is set, if you add a value to a register, so that it gets bigger than FFFFFFFF or is you subtract a value, so that the register value is less than zero.
Windows Memory Map:
Memory Layout
- Stack - region of memory is added or removed using "last-in-first-out" (LIFO) procedure
- Heap - region for dynamic memory allocation
- Program Image - The PE executable code placed into memory
- DLLs - Loaded DLL images that are referenced by the PE
- TEB - Thread Environment Block stores information about the current running thread(s)
- PEB - Process Environment Block stores information about loaded modules and processes.
Opcodes and Instructions
Each Instruction represents opcodes (hex code) that tell the machine what to do next.
Three categories of instructions:
- Data Movement/Access
- Arithmetic / Logic
- Control-Flow
Common Instructions
- mov, lea (data movement, data access)
- add, sub (arithmetic)
- or, and, xor (Logic)
- shr, shl (Logic)
- ror, rol (Logic)
- jmp, jne, jnz, jnb (Control Flow)
- push, pop, call, leave, enter, ret (Control Flow)
Example below is moving value at 0xaaaaaaaa into ecx.
|
|
Registers
General-Purpose Registers [1]
Register | Description |
EAX | Accumulator Register |
EBX | Base Register |
ECX | Counter Register |
EDX | Data Register |
ESI | Source Index |
EDI | Destination Index |
EBP | Base Pointer |
ESP | Stack Pointer |
Instruction Pointer
The EIP register contains the address of the next instruction to be executed.
Segment Registers
Register | Description |
SS | Stack Segment, Pointer to the stack |
CS | Code Segment, Pointer to the code |
DS | Data Segment, Pointer to the data |
ES | Extra Segment, Pointer to extra data |
FS | F Segment, Pointer to more extra data |
GS | G Segment, Pointer to still more extra data |
EFLAGS Registers
ID | Name | Description |
CF | Carry Flag | Set if the last arithmetic operation carried (addition) or borrowed (subtraction) a bit beyond the size of the register. This is then checked when the operation is followed with an add-with-carry or subtract-with-borrow to deal with values too large for just one register to contain |
PF | Parity Flag | Set if the number of set bits in the least significant byte is a multiple of 2 |
AF | Adjust Flag | Carry of Binary Code Decimal (BCD) numbers arithmetic operations |
ZF | Zero Flag | Set if the result of an operation is Zero (0) |
SF | Sign Flag | Set if the result of an operation is negative |
TF | Trap Flag | Set if step by step debugging |
IF | Interruption Flag | Set if interrupts are enabled |
DF | Direction Flag | Stream direction. If set, string operations will decrement their pointer rather than incrementing it, reading memory backwards |
OF | Overflow Flag | Set if signed arithmetic operations result in a value too large for the register to contain |
IOPL | I/O Privilege Level field (2 bits) | I/O Privilege Level of the current process |
NT | Nested Task flag | Controls chaining of interrupts. Set if the current process is linked to the next process |
RF | Resume Flag | Response to debug exceptions |
VM | Virtual-8086 Mode | Set if in 8086 compatibility mode |
AC | Alignment Check | Set if alignment checking of memory references is done |
VIF | Virtual Interrupt Flag | Virtual image of IF |
VIP | Virtual Interrupt Pending flag | Set if an interrupt is pending |
ID | Identification Flag | Support for CPUID instruction if can be set |
Comments
Post a Comment