Refer to github: https://github.com/bonnyfone/adb-arm
The original purpose was to get shell privileges using adb shell after the arm platform compiled, and then avoid the problem that other privileges could not execute su.
At first, I modified the su.c in the android source code, commented out the root and shell permission validation part, compiled it, or not. There will be errors in setgid and setuid. This error tormented me for two days, but I have to find another way.
Suddenly it occurred to me that adb has shell privileges, and can compile adb as a dynamic library by itself and call android application through jni mode, so that it can have root privileges on mobile phones that already have root privileges (without root platform, we need to study how to root again). At present, this method has not been verified.
Provide ADB compilation method (this method is only compiling the executable file adb, can be modified to dynamic library mode on this basis, this way is relatively simple, not explained here):
The compiled version is: android-4.4.4_r2.0.1
The download of the source code needs a ladder...
The script file:
# CONFIG # ------------------------- # Branch to checkout from Android source code repo branch=android-4.4.4_r2.0.1 # Makefile to use (will be automatically copied into system/core/adb) makefile=makefile.sample # DOWNLOAD necessary files # ------------------------- echo "\n>> >>> ADB for ARM <<< \n" echo "\n>> Downloading necessay files ($branch branch)\n" mkdir android-adb cd android-adb mkdir system cd system git clone -b $branch https://android.googlesource.com/platform/system/core git clone -b $branch https://android.googlesource.com/platform/system/extras cd .. mkdir external cd external git clone -b $branch https://android.googlesource.com/platform/external/zlib git clone -b $branch https://android.googlesource.com/platform/external/openssl git clone -b $branch https://android.googlesource.com/platform/external/libselinux cd .. # MAKE # ------------------------- echo "\n>> Copying makefile into system/core/adb...\n" cp ../$makefile system/core/adb/makefile -f cd system/core/adb/ echo "\n>> Make... \n" make clean make echo "\n>> Copying adb back into current dir...\n" cp adb ../../../../ echo "\n>> FINISH!\n"
makefile.example file:
TOOLCHAIN is a local ndk tool chain, extracted from r9.# ADB makefile # ------------ #TODO change TOOLCHAIN variable to your toolchain path #TOOLCHAIN= /opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi- TOOLCHAIN = /home/linux/bin/android-toolchain/bin/arm-linux-androideabi- CC = $(TOOLCHAIN)gcc LD = $(TOOLCHAIN)gcc CXX = $(CC) SRCS += adb.c SRCS += fdevent.c SRCS += adb_client.c SRCS += commandline.c SRCS += console.c SRCS += file_sync_client.c SRCS += get_my_path_linux.c SRCS += services.c SRCS += sockets.c SRCS += transport.c SRCS += transport_local.c SRCS += transport_usb.c SRCS += usb_linux.c SRCS += usb_vendors.c SRCS += adb_auth_host.c VPATH += ../libcutils SRCS += list.c SRCS += socket_inaddr_any_server.c SRCS += socket_local_client.c SRCS += socket_local_server.c SRCS += socket_loopback_client.c SRCS += socket_loopback_server.c SRCS += socket_network_client.c SRCS += load_file.c VPATH += ../libzipfile SRCS += centraldir.c SRCS += zipfile.c VPATH += ../../../external/zlib/src SRCS += adler32.c SRCS += compress.c SRCS += crc32.c SRCS += deflate.c SRCS += infback.c SRCS += inffast.c SRCS += inflate.c SRCS += inftrees.c SRCS += trees.c SRCS += uncompr.c SRCS += zutil.c CPPFLAGS += -DADB_HOST=1 CPPFLAGS += -DHAVE_FORKEXEC=1 CPPFLAGS += -DHAVE_SYMLINKS CPPFLAGS += -DHAVE_TERMIO_H CPPFLAGS += -DHAVE_SYS_SOCKET_H CPPFLAGS += -D_GNU_SOURCE CPPFLAGS += -D_XOPEN_SOURCE CPPFLAGS += -std=c++11 CPPFLAGS += -I. CPPFLAGS += -I../include CPPFLAGS += -I../../../external/zlib CPPFLAGS += -I../../../external/openssl/include CPPFLAGS += -I../base/include CFLAGS += -O2 -g -Wall -Wno-unused-parameter LIBS = -lcrypto -pthread -fPIE -pie #LIBS += -lrt OBJS = $(SRCS:.c=.o) all: adb adb: $(OBJS) $(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) clean: rm -rf $(OBJS)
You can manually download the source code in the script, and then put the makefile directly under ~/system/core/adb/. Executing make can generate the ADB file, verifying that there is no problem. Dynamic libraries haven't been compiled yet.