TLDR: How do I get a panel in radare2 to correctly show the output of a radare2 command piped to an external script?
afvd | python var_displayer.py
- This is my current view. Multiple panels, using radare2's
vcommand. Note the
afvdand RegisterRefs (
- I love RegisterRefs (
drr) because it shows values at addresses. I love
afvdbecause it shows all var values.
afvdonly 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
afvdrthat shows var values in different formats + refstr, like
drrdoes for registers.
- I want to replace my current
afvdpanel with this new tool.
What do I have so far?
- I know that if I take a var's value (e.g.
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.pythat will read the output from
avfdand calculate and neatly display the
stringrepresentations the same as the
? <expr>command would. I run it within r2 using
afvd | 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 | 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_stringand then outputs this string with a call to
sys.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 (
drrrefstr 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.