radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.75k stars 3.01k forks source link

ADB shell showing weird chars #22752

Open trufae opened 8 months ago

trufae commented 8 months ago

maybe it is unrelated. I tried use my build on emulator and xiaomi android 14 device through adb shell On both appear artifacts around cursor:

image

by @docds

reported https://github.com/radareorg/radare2/issues/22750#issuecomment-2019200923

trufae commented 8 months ago

@docds are you on windows? or which terminal is this that doesnt support ansi?

can you try appluing this patch and see if at least the 2K disappears?

diff --git a/libr/cons/dietline.c b/libr/cons/dietline.c
index 229aaf451d..25a1e6d65d 100644
--- a/libr/cons/dietline.c
+++ b/libr/cons/dietline.c
@@ -1760,7 +1752,7 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) {
                bool o_do_setup_match = I.history.do_setup_match;
                I.history.do_setup_match = true;
                if (I.echo && cons->context->color_mode) {
-                       r_cons_clear_line (0);
+               //      r_cons_clear_line (0);
                }
                (void) r_cons_get_size (&rows);
                switch (*buf) {
docds commented 8 months ago

I make build on Debian 12.5 with default terminal (VirtualBox), but testing from Windows 10 (cmd) I clone master "git clone https://github.com/radareorg/radare2.git" and rebuild project.

image

After start r2 in cmd through "adb shell" terminal looks like that:

./r2 --
←[0m[0x00000000]> ←[0m

Wen I pres first key "d":

./r2 --
←[0m[0x00000000]> ←[0md[0m←[2K

"dc" pressed

./r2 --
←[0m[0x00000000]> ←[0mdc[0m←[2K

"Enter" pressed

./r2 --
[0x00000000]> ←[0mdc←[0m[0m←[2K
ERROR: Cannot continue, run ood?
←[0m[0x00000000]> ←[0m
trufae commented 8 months ago

Ah that makes sense, those escape codes are ANSI and windows terminal doesnt support them, so i would suggest you to do the following thing:

adb shell r2 -e scr.fgets=true --

this will use fgets instead of the dietline input method, which will not have autocompletion or ansi escape codes. but i would suggest you to try another terminal that supports this or just use ssh into the device.

are the colors working? or you need to do -e scr.color=0 too?

docds commented 7 months ago

Thanks. Cmd indeed was culprit. When use -e scr.fgets=true parameter no weird chars appear. Colors works just fine.

image

I found brand new replacement for CMD from Microsoft. Leave it here for feather generations. :-). ANSI Terminal support The ANSI features are designed to be compatible with the xterm-based terminals. For more information, see xterm in Wikipedia. On Windows 10 and higher, the Windows Console Host is xterm compatible. The Windows Terminal application is also xterm compatible.

Start just "r2 --" image image

I will going to get some Raspberry Pi (4/5) device and put there Android and do some experiment. When I run Android arm emulator on x86 platform it work really slow and I don’t wont to root my personal cell phone.

trufae commented 7 months ago

But still. its weird because the colors work in cmd->adb, the issue seems to be only in the repl prompt 🤔