firmflaws icon indicating copy to clipboard operation
firmflaws copied to clipboard

Use r2.cmdj and json !

Open Maijin opened this issue 9 years ago • 0 comments

Stop using that kind of syntax😧:

imports = "\n".join([_ for _ in r2.cmd("ii").split("\n") if "name=" in _])

or

def is_elf(file):
    with open(file.filepath, "rb") as fd:
        head = fd.read(4)
    return (b"\x7FELF" == head)

This is useless iIj will return information in json, just scrap "bintype".

Every command in r2 world can be expressed in json by appending j it's one of the fundamental of @radare. Use r2.cmdj to retrieve the result.

Maijin avatar Jul 26 '16 19:07 Maijin