10 de jul. de 2017

Exploring the Buffer

0 comentários
* Warning: My english sux. 
"Computers, in a slightly schizoid fashion, work in base 2 and base 16 - all the same time." - Jeff Duntemann
The natural way to find any program vulnerability is disassembling it so we need to know this weird base 16 number system also some assembly. If you don't have any knowledge about it you can keep reading otherwise just skip this intro. 

Basic of Hexadecimal:
Base 16 or Hexadecimal number system has 16 digits so 6 additional digits are added in the form of A-F. This makes hex extremely useful for representing binary data. One digit of hex is equal to one nibble or 4 bits of data. Two hex digits are equal to a byte or 8 bits. Four hex digits are equal to a 32 bit word. Eight hex digits are equal to a 64 bit word. You can see from the following chart of counting with hexadecimal(HEX) decimal(DEC) and binary(BINARY) values what is going on:

HEX   DEC   BINARY       HEX   DEC   BINARY       HEX  DEC   BINARY
----  ----  ----------   ----  ----  ----------   ---- ----  ----------
0x00  (00)  (00000000)   0x10  (16)  (00010000)   0x20 (32)  (00100000)
0x01  (01)  (00000001)   0x11  (17)  (00010001)   0x21 (33)  (00100001)
0x02  (02)  (00000010)   0x12  (18)  (00010010)   0x22 (34)  (00100010)
0x03  (03)  (00000011)   0x13  (19)  (00010011)   0x23 (35)  (00100011)
0x04  (04)  (00000100)   0x14  (20)  (00010100)   0x24 (36)  (00100100)
0x05  (05)  (00000101)   0x15  (21)  (00010101)   0x25 (37)  (00100101)
0x06  (06)  (00000110)   0x16  (22)  (00010110)   0x26 (38)  (00100110)
0x07  (07)  (00000111)   0x17  (23)  (00010111)   0x27 (39)  (00100111)
0x08  (08)  (00001000)   0x18  (24)  (00011000)   0x28 (40)  (00101000)
0x09  (09)  (00001001)   0x19  (25)  (00011001)   0x29 (41)  (00101001)
0x0A  (10)  (00001010)   0x1A  (26)  (00011010)   0x2A (42)  (00101010)
0x0B  (11)  (00001011)   0x1B  (27)  (00011011)   0x2B (43)  (00101011)
0x0C  (12)  (00001100)   0x1C  (28)  (00011100)   0x2C (44)  (00101100)
0x0D  (13)  (00001101)   0x1D  (29)  (00011101)   0x2D (45)  (00101101)
0x0E  (14)  (00001110)   0x1E  (30)  (00011110)   0x2E (46)  (00101110)
0x0F  (15)  (00001111)   0x1F  (31)  (00011111)   0x2F (47)  (00101111)

For a byte this chart would continue until it reached 0xFF  (255) (1111 1111) 255 is the largest number that can be represented with a byte.