radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.66k stars 3k forks source link

Can't create sections in a project #10033

Closed DieHertz closed 6 years ago

DieHertz commented 6 years ago

I could create sections when working on a QEMUd binary, but I cannot do the same when working on my own or when directly loading them. Here's what I do:

$ r2 -p test
[0x00000000]> o ROM0.bin 0xe0000000 rx
[0x00000000]> o
 3 - r-x 0x02000000 ROM0.bin
[0x00000000]> S 0 0 0x40000000 ram0 rw
[0x00000000]> S
[0x00000000]> 

What am I doing wrong? If I don't use a project, it seems to work:

$ r2 --
 -- Use 'rabin2 -ris' to get the import/export symbols of any binary.
[0x00000000]> o ROM0.bin 0xe0000000 rx
3
Empty file with fd -1?
[0x00000000]> o
 3 * r-x 0x02000000 ROM0.bin
[0x00000000]> S 0 0 0x40000000 ram0 rw
[0x00000000]> S
[-1:00] * pa=0x00000000 rw- va=0x00000000 sz=0x40000000 vsz=0x40000000 ram0

It also seems to affect the file map even though address doesn't fall into the address range where the file is mapped?

[0x00000000]> om
 2 fd: 3 +0x00000000 0x00000000 - 0x3fffffff r-- fmap.ram0
 1 fd: 3 +0x00000000 0xe0000000 - 0xe1ffffff r-x 

It all looks like magic for now as I don't understand what's going on, and radare2 book references on commands are quite terse on details.

I have tried both today's master@HEAD and tag 2.5.0:

$ r2 -v
radare2 2.5.0 18107 @ darwin-x86-64 git.2.5.0
commit: c2b7d11ca74cd98eba8912d94ec0973cf2965697 build: 2018-05-07__10:48:58
radare commented 6 years ago

Use om instead of S, S must die

DieHertz commented 6 years ago

Thanks, got an answer via Telegram.

Maijin commented 6 years ago

(needed to add m flag in rw so it's rwm)

DieHertz commented 6 years ago

It could be beneficial to alter this function or rename it somehow then, as it's not really self-documenting, no word about m and what it means.

// Returns the permissions as in integer given an input in the form of rwx, rx,
// etc.
R_API int r_str_rwx(const char *str)
radare commented 6 years ago

? This was deprecated by ret2libc 2 releases ago

On 7 May 2018, at 15:46, Maijin notifications@github.com wrote:

(needed to add m flag in rw so it's rwm)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.