I am learning by doing some cracking in files that i made in C. One of this files is this:


#include <stdio.h>
#include <stdlib.h>

int main() {
        char s[15] = "disassemba";
        int x;

        if (x == 2000) {
                printf("You win");
        } else {
                printf("You lose");

So i compile with: gcc file.c -o file

open the file with radare: r2 -w file

The commands i use is the following, in radare2, in order:

s main

in visual mode, i need modify the line of code where sets x=555 to x=2000. So i navigate in visual mode to:

enter image description here

And i hit shift+a, but when i try insert

mov dword [var_4h], 0x7D0

the file is not patched (no changes in asm code).

any hint?

note:Preferably in some easy way where i can write the code in asm and not in machine code.

  • Hi and welcome to RE.SE. This came up recently, I think. There was some flag you needed to activate prior to being able to patch this way. It could be worthwhile checking out recent radare2 questions.
    – 0xC0000022L
    Commented Jan 18, 2022 at 8:01

1 Answer 1


To patch binaries you need to open the file in read-write mode, by default r2 open the files in read-only. So you can:

  • Use r2 -w
  • Reopen the file in read-write inside the r2 shell with the oo+ command

Actually, if you do what you said, it shows an error message saying exactly what i said above to do (-w or oo+). Hope that helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.