adb交互-干掉难看的默认shell界面

背景

使用adb shell时进入到Android系统的交互终端界面,因为Android只有一种shell解释器/system/bin/sh

那么如果大量时间在adb交互上工作,将会花费大量的时间在处理命令上面,甚至还得复制粘贴命令

Main

现在的类unix系统基本都是以bash解释器为主,同时bash也是一款命令非常丰富的解释器,如果追求工作效率bash的话毫无疑问是首选,网上的bash工具比较难找,这里我提供一个bash链接-> https://www.aliyundrive.com/s/m5JJtN4im2A

首先将bash推送到移动端

$ adb push ./bash /data/local/tmp

然后在移动端需要将bash放入系统工具目录这样就可以方便的使用它

$ adb shell
blueline:/ $ su
blueline:/ # su
blueline:/ # mount -o rw,remount / 
blueline:/ # mount -o rw,remount /system

上面的命令必须要先挂载/为可写然后才是/system

blueline:/system/bin # cd /system/bin
blueline:/system/bin # cp /data/local/tmp/bash ./
使用
$ adb shell
blueline:/ $ su
blueline:/ # bash
/home #

当然linux工具这么强大那就直接把常用工具都应用到Android吧

搭建Linux常用工具

这里使用Termux内嵌的工具集,当然~你也可以使用Bisbox的工具集它同样也是不错的选择

Termux -Demo

下载自己手机对于的cpu架构版本apk -> https://github.com/termux/termux-app/releases/tag/v0.118.0

然后安装到移动端

完成后会在你的数据目录下有一套它的工具集

$ adb shell
blueline:/ $ cd /data/data/c^C
130|blueline:/ $ su
blueline:/ # cd /data/data/com.termux/files/
blueline:/data/data/com.termux/files # ls
home usr

熟悉Linux文件系统的就明白home就是用户的主目录,这里管理着各个用户的环境和文件,usr目录就是就是一套完整的文件系统了如下:

blueline:/data/data/com.termux/files/usr # ls
bin etc include lib libexec opt share tmp var

甚至这个文件系统还有丰富动态库,甚至可以用来编写你的程序(这不是内嵌系统吗!)

来到工具集如下:

blueline:/data/data/com.termux/files/usr/bin # ls
[                   kadmin.local     setterm
addpart             kadmind          settings
am                  kdb5_util        sftp
apt                 kdestroy         sftpa
apt-cache           kill             sh
apt-config          killall          sha1sum
apt-get             kinit            sha224sum
apt-key             klist            sha256sum
apt-mark            kpasswd          sha384sum
arp                 kprop            sha512sum
awk                 kpropd           shred
b2sum               kproplog         shuf
base32              krb5-config      sim_client
base64              krb5-send-pr     sim_server
basename            krb5kdc          slattach
basenc              ksu              sleep
bash                kswitch          sort
blkdiscard          ktutil           source-ssh-agent
blkid               kvno             split
blkzone             ldattach         sserver
blockdev            ldns-config      ssh
bunzip2             less             ssh-add
bzcat               lessecho         ssh-agent
bzcmp               lesskey          ssh-copy-id
bzdiff              libassuan-config ssh-keygen
bzgrep              libgcrypt-config ssh-keyscan
bzip2               link             ssha
bzip2recover        linux32          sshd
bzless              linux64          start-stop-daemon
bzmore              ln               stat
cal                 logcat           stdbuf
captest             logger           stty
cat                 login            su
chcon               logname          sum
chcpu               look             swaplabel
chgrp               losetup          sync
chmod               ls               sysctl
choom               lscpu            tac
chown               lsipc            tail
chroot              lsirq            tar
chrt                lsof             taskset
chsh                lzcat            tee
cksum               lzcmp            telnet
clear               lzdiff           termux-am
cmd                 lzegrep          termux-backup
cmp                 lzfgrep          termux-change-repo
col                 lzgrep           termux-fix-shebang
colcrt              lzless           termux-info
colrm               lzma             termux-open
column              lzmadec          termux-open-url
comm                lzmainfo         termux-reload-settings
compile_et          lzmore           termux-reset
coreutils           mac2unix         termux-restore
cp                  mcookie          termux-setup-storage
csplit              md5sum           termux-wake-lock
ctrlaltdel          mii-tool         termux-wake-unlock
curl                mkdir            test
curl-config         mkfifo           tftp
cut                 mkfs             timeout
dalvikvm            mkfs.bfs         tload
dash                mkfs.cramfs      top
date                mkfs.minix       touch
dd                  mknod            tr
delpart             mkswap           true
df                  mktemp           truncate
dialog              more             tset
diff                mount            tsort
diff3               mpicalc          tty
dir                 mv               uclampset
dircolors           namei            ul
dirname             nameif           umount
dmesg               nano             uname
dnsdomainname       ncursesw6-config uname26
dos2unix            netcap           unbound
dpkg                netstat          unbound-anchor
dpkg-deb            nice             unbound-checkconf
dpkg-divert         nl               unbound-control
dpkg-fsys-usrunmess nohup            unbound-control-setup
dpkg-query          nproc            unbound-host
dpkg-realpath       npth-config      uncompress
dpkg-split          nsenter          unexpand
dpkg-trigger        numfmt           uniq
drill               od               unix2dos
du                  partx            unix2mac
dumpsexp            passwd           unlink
echo                paste            unlzma
ed                  patch            unshare
editor              pathchk          unxz
egrep               pcre-config      unzip
env                 pcre2-config     unzipsfx
expand              peekfd           update-alternatives
expr                pgrep            uptime
factor              pidof            uuclient
fallocate           ping             uuserver
false               ping6            vdir
fgrep               pkg              vi
filecap             pkill            view
fincore             plipconfig       vim
find                pm               vimdiff
findfs              pmap             vimtutor
flock               pr               vmstat
fmt                 printenv         watch
fold                printf           wc
free                prlimit          wdctl
fsck.cramfs         prtstat          whereis
fsck.minix          ps               which
fsfreeze            pscap            whoami
ftp                 pslog            whois
funzip              pstree           wipefs
fuser               ptx              xargs
gawk                pwait            xdg-open
getopt              pwd              xxd
getprop             pwdx             xxh128sum
gpg-error           pwlogin          xxh32sum
gpg-error-config    rarp             xxh64sum
gpgrt-config        readlink         xxhsum
gpgv                readprofile      xz
grep                realpath         xzcat
groups              red              xzcmp
gss-client          rename           xzdec
gss-server          renice           xzdiff
gunzip              reset            xzegrep
gzexe               resizepart       xzfgrep
gzip                rev              xzgrep
hardlink            rm               xzless
head                rmdir            xzmore
hexdump             route            yat2m
hmac256             rtcwake          yes
hostname            run-parts        zcat
hwclock             runcon           zcmp
id                  savelog          zdiff
idn2                sclient          zegrep
ifconfig            scp              zfgrep
install             scpa             zforce
ionice              script           zgrep
ipmaddr             scriptlive       zipgrep
iptunnel            scriptreplay     zipinfo
irqtop              sdiff            zless
ischroot            sed              zmore
isosize             seq              znew
join                setarch          zramctl
k5srvutil           setpriv
kadmin              setsid

可以看到上面我通过包管理器pkg install vim在线安装了一个vim到现在为止我在工作中使用它没有任何问题。

那么如果想使用它的工具就只需要将这个目录添加进入Android系统的环境变量中,命令如下:

blueline:/ $ su
blueline:/ # echo "export PATH=\$PATH:/data/data/com.termux/files/usr/bin/" >> /data/data/com.termux/files/usr/etc/bash.bashrc

为了方便日常使用,可以将工作目录添加符号链接到初始目录下面,如下:

/home # ln -s /data/local/tmp ./tmp
/home # ls -l tmp
lrwxrwxrwx 1 root root 18 2022-07-21 17:22 tmp -> /data/local/tmp/
/home # ls tmp
ffmpeg       libByteVC1_dec.so oat        prepare_to_yuv.log
ffmpeg_g     libheif.so        patch_init pwn.sh
frida-server libttheif_dec.so  perf       re.frida.server
gdbserver    load_frida.sh     png_to_yuv
/home # ls /data/local/tmp/
ffmpeg       libByteVC1_dec.so oat        prepare_to_yuv.log
ffmpeg_g     libheif.so        patch_init pwn.sh
frida-server libttheif_dec.so  perf       re.frida.server
gdbserver    load_frida.sh     png_to_yuv

这样就可以非常方便的到达工作目录

最终效果

每次只需执行bash命令即可进入到一个多工具的终端中

$ adb shell
blueline:/ $ su
blueline:/ # bash
/home # vim
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值