TLDR: How do I get a panel in radare2 to correctly show the output of a radare2 command piped to an external script?
e.g. afvd | python var_displayer.py
- This is my current view. Multiple panels, using radare2's
v
command. Note theafvd
and RegisterRefs (drr
) panels.
- I love RegisterRefs (
drr
) because it shows values at addresses. I loveafvd
because it shows all var values. - Problem:
afvd
only shows var values as decimal. - Sometimes, it makes more sense to see it as hex.
- Sometimes, it makes more sense to see it as ASCII.
- I want to create something like
afvdr
that shows var values in different formats + refstr, likedrr
does for registers. - I want to replace my current
afvd
panel with this new tool.
What do I have so far?
- I know that if I take a var's value (e.g.
var_8h
=4287356032
) and run the r2 command? <expr>
, it will evaluate the expression and show me different representations!
- I developed a python script, called
var_displayer.py
that will read the output fromavfd
and calculate and neatly display thehex
andstring
representations the same as the? <expr>
command would. I run it within r2 usingafvd | python scripts/var_displayer.py
. Here's the output:
- This is awesome! I don't have the dereference functionality (treat var value as an address and show the value underlying), which would be useful like
drr
, but this is great for me! - However, a problem occurs when I try to replace the
afvd
panel withafvd | python scripts/var_displayer.py
.
- Note how the panel only shows the output of
afvd
, and note how the string generated by my python script is awkwardly appended to the entire radare2 panels output in the bottom left. - My python script builds the output string in one variable named
output_string
and then outputs this string with a call tosys.stdout.write(out_string)
. Unfortunately, radare2 doesn't seem to expect this for a panel's display.
THANKS FOR READING SO FAR!!!
My Questions Are:
- Is it possible to configure a radare2 panel to neatly show the output of an external script/program?
- Is there a better way to achieve the evaluate functionality (
? <expr>
) and dereference evaluate functionality (drr
refstr column) for vars that is native to radare2?
I'm falling in love with radare2 for it's customizability and elegance and slick CLI feel, but I'm pretty surprised to find custom script --> panel is not working. I feel like there must be a way to achieve this that I haven't figured out yet.