Seeking: The s Module
Seeking is the process of moving around the file. radare2
maintains a seek address to determine where we are in the binary. This is shown on the command line:
In this case, 0x0804923c
is our seek address.
Seeking to an Address
We can use the s
command to change the seek address:
You can seek to an expression such as an address, offset, or register.
Seek History
We use s
to print the seeking history. This takes several secondary parameters of how the data should be printed. Scroll through the following to see the various types:
If we want to undo the seek, we can use s-
to go back to the previous seek address:
We can then redo this seek using s+
:
We can clear the seek history using s-*
:
Relative Seeking
We can use s+ <bytes>
to move <bytes>
forward.
We can use s- <bytes>
to move <bytes>
backward.
We can use s++ <blocks>
to move <blocks>
forward.
We can use s-- <blocks>
to move <blocks>
backward.
How Many Bytes in a Block?
This depends on your configuration. Use b
to get the current block size. b <num>
is used to set the current block size.
Seeking to Special Locations
Radare2 allows us to seek to various special locations in the binary. This is a good way to find the start of functions, strings, and comments without bloating the output.
Seeking to Functions
The sf
command lets us seek to the start of the next function.
We can use sf.
to seek to the beginning of the current function.
pd 1
is used to print one line of disassembly at the current seek address. We use this to show that we're at the top of the main
function.
You can use sf <function>
to seek to a specific function. However, since s <function>
also takes us to a function, this function is not very useful.
Seeking to Strings
We use s/ <string>
to seek to the next occurrence of <string>
.
Search Bounds
Radare2 defaults to searching the current memory block for the string. We can change this setting by modifying the e search.in
setting.
Changing this will cause s/
to search the entire binary for the string.
We can also search for bytes by using s/x
and specifying the hex value.
Using Functions at Other Addresses
When using various modules within radare2
, the program defaults to our seek address when an address is requested. For example, if we use the pdf
command, it will print the disassembly of the function at the seek address:
However, we can use the @
symbol to specify a different address:
Last updated