Here are two linux x64 ELF GCC binary files analysed by Ghidra: original: [code]…
- User
Here are two linux x64 ELF GCC binary files analysed by Ghidra:
original:
008f92b1 c6 05 48 MOV byte ptr [DAT_010d8400],0x0 f1 7d 00 00 008f92b8 c6 05 31 MOV byte ptr [DAT_010d83f0],0xff f1 7d 00 ff 008f92bf 74 05 JZ LAB_008f92c6 008f92c1 80 3f 00 CMP byte ptr [RDI],0x0 008f92c4 75 3a JNZ LAB_008f9300 LAB_008f92c6 XREF[1]: 008f92bf(j) 008f92c6 31 d2 XOR EDX,EDX 008f92c8 be 94 99 MOV ESI,s_reg_00c1998e+6 = "reg" c1 00 008f92cd bf 9f 5e MOV EDI,s_No_key_filename_00cd5e9f = "No key filename" cd 00 008f92d2 e8 29 df CALL FUN_00777200 undefined FUN_00777200() e7 ff LAB_008f92d7 XREF[8]: 008f9438(j), 008f9454(j), 008f9473(j), 008f9487(j), 008f94b1(j), 008f94d1(j), 008f956a(j), 008f9580(j) LAB_008f92d7 XREF[8]: 008f9438(j), 008f9454(j), 008f9473(j), 008f9487(j), 008f94b1(j), 008f94d1(j), 008f956a(j), 008f9580(j) 008f92d7 48 8b 8c MOV RCX,qword ptr [RSP + local_20] 24 48 02 00 00patched:
008f92b1 c6 05 38 MOV byte ptr [DAT_010d83f0],0x1 f1 7d 00 01 008f92b8 c7 05 3e MOV dword ptr [DAT_010d8400],0x4f462d58 f1 7d 00 58 2d 46 4f 008f92c2 c7 05 38 MOV dword ptr [DAT_010d8404],0x454352 f1 7d 00 52 43 45 00 008f92cc 90 NOP 008f92cd 90 NOP 008f92ce 90 NOP 008f92cf 90 NOP 008f92d0 90 NOP 008f92d1 90 NOP 008f92d2 90 NOP 008f92d3 90 NOP 008f92d4 90 NOP 008f92d5 90 NOP 008f92d6 90 NOP 008f92d7 48 8b 8c MOV RCX,qword ptr [RSP + local_20] 24 48 02 00 00Can you explain what the patch does address by address and how it differs to the original byte code?
- Assistant
Let's compare the original and the patched programs address by address and analyze the changes:
Address
008f92b1ChangesOriginal:
008f92b1 c6 05 48 f1 7d 00 00 MOV byte ptr [DAT_010d8400],0x0- Sets the byte at memory address
[DAT_010d8400]to0x0.
Patched:
008f92b1 c6 05 38 f1 7d 00 01 MOV byte ptr [DAT_010d83f0],0x1- Sets the byte at memory address
[DAT_010d83f0]to0x1.
Difference:
- The target memory address and the byte being set are both changed. Possibly changing a flag's value.
Address
008f92b8ChangesOriginal:
008f92b8 c6 05 31 f1 7d 00 ff MOV byte ptr [DAT_010d83f0],0xff- Sets the byte at memory address
[DAT_010d83f0]to0xff.
Patched:
008f92b8 c7 05 3e f1 7d 00 58 2d 46 4f MOV dword ptr [DAT_010d8400],0x4f462d58- Sets the dword (4 bytes) at memory address
[DAT_010d8400]to0x4f462d58.
Difference:
- Instead of setting a byte, it sets a dword.
- The value and the type of the data written being are changed: from a byte value
0xffto a dword0x4f462d58.
Addresses
008f92bfto008f92d7ChangesOriginal:
008f92bf 74 05 JZ LAB_008f92c6 008f92c1 80 3f 00 CMP byte ptr [RDI],0x0 008f92c4 75 3a JNZ LAB_008f9300 008f92c6 31 d2 XOR EDX,EDX 008f92c8 be 94 99 MOV ESI,s_reg_00c1998e+6 = "reg" c1 00 008f92cd bf 9f 5e MOV EDI,s_No_key_filename_00cd5e9f = "No key filename" cd 00 008f92d2 e8 29 df CALL FUN_00777200 undefined FUN_00777200() e7 ff 008f92d7 48 8b 8c MOV RCX,qword ptr [RSP + local_20] 24 48 02 00 00Patched:
008f92cc 90 NOP 008f92cd 90 NOP 008f92ce 90 NOP 008f92cf 90 NOP 008f92d0 90 NOP 008f92d1 90 NOP 008f92d2 90 NOP 008f92d3 90 NOP 008f92d4 90 NOP 008f92d5 90 NOP 008f92d6 90 NOP 008f92d7 48 8b 8c MOV RCX,qword ptr [RSP + local_20] 24 48 02 00 00Difference:
- All the instructions including a jump, two compares, and moving strings to registers followed by a function call are replaced with
NOPoperations (no-operation). This essentially disables the previous functionality, rendering the code block ineffective in terms of its original purpose. - All logic between the changed memory settings and the final
MOVinstruction toRCXis effectively erased.
Overall, the patch modifies two specific memory flags differently from the original code, removes the conditional checks and related operations (like string management and a function call), and makes the block largely non-operational apart from setting those flags and later moving a value into
RCX. This likely changes the flow and behavior of the execution, potentially disabling some security checks or altering the configuration dynamically. - Sets the byte at memory address