rafind2 is the command-line front-end of the radare2 searching library. These commands are equivalent to the / (searching) module. For more information on searching, see the / (searching) module page.
We can search for strings using the -s flag. This will search for a specific string and return the offset from the base address.
rafind2 -s "flag.txt" ./args0x2016Use the -z flag to search for all zero-terminated strings. This will return the address and the string.
rafind2 -z ./args0x00000028 4 \v(0x00000136 td80x00000176 td\b/0x08048194 /lib/ld-linux.so.20x0804829d _IO_stdin_used0x080482ac gets0x080482b1 stdout0x080482b8 __libc_start_main0x080482ca puts0x080482cf system0x080482d6 fflush0x080482dd libc.so.60x080482e7 GLIBC_2.00x080482f1 GLIBC_2.340x080482fc __gmon_start__0x0804a008 You lose!0x0804a012 cat flag.txt0x0804a01f Good luck winning here!0x0804a0db ;*2$"0x00000000 GCC: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.00x00000001 crt1.o0x00000008 __abi_tag0x00000012 crtstuff.c0x0000001d deregister_tm_clones0x00000032 __do_global_dtors_aux0x00000048 completed.00x00000054 __do_global_dtors_aux_fini_array_entry0x0000007b frame_dummy0x00000087 __frame_dummy_init_array_entry0x000000a6 args.c0x000000ad __FRAME_END__0x000000bb _DYNAMIC0x000000c4 __GNU_EH_FRAME_HDR0x000000d7 _GLOBAL_OFFSET_TABLE_0x000000ed __libc_start_main@GLIBC_2.340x0000010a __x86.get_pc_thunk.bx0x00000120 fflush@GLIBC_2.0Use the -e flag to search for a regular expression. This will return the address and the string. Remember that radare2 uses / for edge wildcards and .. for centered wildcards.
rafind2 -e "/flag/" ./args0x2016