1

I have cross-compiled a binary on Linux using the arm toochain. I uploaded the binary to a non-rooted andnroid phone.

What do I need to do in order to run this binary on the non-rooted phone ?

EDIT: I tried to run via terminal emulator, but I get the following error.

$ pwd
/mnt/sdcard/external_sd
$ ls -l hello
-rwxrwxr-x system   sdcard_rw     8420 2013-12-31 22:12 hello
$ ./hello
./hello: permission denied
$
16
  • I suppose you could install a terminal emulator, navigate to the binary, and use ./binary to invoke it. Making sure permissions are properly set, of course.
    – dotVezz
    Commented Dec 31, 2013 at 18:56
  • 1
    I tried this, but the file is not executable on sdcard, i tried chmod +x, but it does nothing. I tried to copy binary to /data folder on phone, but got permission error. How can i run it ?
    – aseaudi
    Commented Dec 31, 2013 at 19:14
  • Can you edit your question and give us the output of ls -l [file]? You won't be able to move anything to /data/ because it's owned by root.
    – dotVezz
    Commented Dec 31, 2013 at 19:23
  • check my edit above
    – aseaudi
    Commented Dec 31, 2013 at 20:19
  • 2
    sdcard is probably (usually) FAT32/exFat, so it doesn't have Linux permission system, which is why you can't execute or chmod anything on it. I would try to find a "rw" partition using mount (e.g. /cache) and trying to execute from there.
    – Chahk
    Commented Dec 31, 2013 at 20:38

2 Answers 2

4

You can download termux, copy your binary to the termux home folder and run it

cp /storage/emulated/0/mybinary .
chmod +x mybinary
./mybinary

I haven't actually managed to run something because I don't have an android binary handy and a quick google doesn't bring up any android hello world binaries, but it should work.

2
1

Removable media, as well as several other (user writable) partitions are mounted NOEXEC, meaning you can't execute binaries on these partitiions. See the output of 'mount' for details. Modern android builds generally prevent you from copying binaries to partitions mounted EXEC as a security precaution.

Short of rooting your device, you can't run this binary.

4
  • This one's correct.
    – iBug
    Commented Feb 28, 2017 at 3:24
  • is it possible to overcome this? for example by requesting a permission to write in a exec zone?
    – Daniel
    Commented May 6, 2020 at 12:42
  • 1
    You need to pack the binary into an app now, and execute it via the app (possibly with NDK?). Or if you're lucky, you can copy it to /data/local/tmp/ then chmod +x it, and execute it from there. Commented Mar 13, 2021 at 21:54
  • mount | grep -v noexec to find which partiotions are not noexec so that's possible to run binary files, or maybe better way mount | grep -v noexec | grep ext4
    – a55
    Commented Mar 12, 2023 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .