Padding and Patching

Ragg2, a tool in the radare2 suite, offers various options for padding and patching the generated bufferoutput. These options allow users to modify or extend the generated code in specific ways.

  • Appending Data:

    • Append hex bytes (-B)
    • Append file contents (-C)
    • Append 32-bit or 64-bit numbers (-n, -N)
    • Append strings (-S)
  • Patching Existing Data:

    • Patch dword or qword at a given offset (-d, -D)
    • Patch hex pairs at a given offset (-w)
  • Adding Padding:

    • Add padding after compilation (-p)
    • Options include NOP, trap instructions, or specific byte sequences

From ragg2 -h:

-B [hexpairs] append some hexpair bytes -C [file] append contents of file -d [off:dword] patch dword (4 bytes) at given offset -D [off:qword] patch qword (8 bytes) at given offset -n [dword] append 32bit number (4 bytes) -N [dword] append 64bit number (8 bytes) -p [padding] add padding after compilation (padding=n10s32) ntas : begin nop, trap, 'a', sequence NTAS : same as above, but at the end -S [string] append a string -w [off:hex] patch hexpairs at given offset