android_adb shell/busybox指令集

adb shell能够做什么

image-20221008180836136

mksh

  • 和指令集不同,shell可以调用不同的指令集
  • 但是shell作为用户命令行解释器,本身又是一个可执行文件
    • 比如bash/zsh/ksh/mksh
  • adb shell所用的shell一般指mksh(android12试验)
1|xaga:/system/xbin $ sh -v
# Copyright (c) 2010, 2012, 2013, 2014
# Thorsten Glaser <tg@mirbsd.org>
# This file is provided under the same terms as mksh.
#-
# Minimal /system/etc/mkshrc for Android
#
# Support: https://launchpad.net/mksh
set +o nohup
if (( USER_ID )); then PS1='$'; else PS1='#'; fi
PS4='[$EPOCHREALTIME] '; PS1='${|
local e=$?
(( e )) && REPLY+="$e|"
return $e
}$HOSTNAME:${PWD:-?} '"$PS1 "

其他shell

  • 在android(ARM)架构,有zsh for arm可以选用,您可以使用magisk刷入

    • localhost# zsh -h
      localhost# zsh -v
      # /etc/zsh/zshenv: system-wide .zshenv file for zsh(1).
      #
      # This file is sourced on all invocations of the shell.
      # If the -f flag is present or if the NO_RCS option is
      # set within this file, all other initialization files
      # are skipped.
      #
      # This file should contain commands to set the command
      # search path, plus other important environment variables.
      # This file should not contain commands that produce
      # output or assume the shell is attached to a tty.
      #
      # Global Order: zshenv, zprofile, zshrc, zlogin
      export USER=$([[ "$(print -P "%#")" == '#' ]] && print 'root' || print 'system')
      export HOME=/data/local/${USER}
      export ANDROID_ROOT=/system

android基础指令集

toybox

  • toybox --help

    xaga:/data/adb/busybox # toybox --help
    Toybox 0.8.4-android multicall binary: https://landley.net/toybox (see toybox --help)
    usage: toybox [--long | --help | --version | [COMMAND] [ARGUMENTS...]]
    With no arguments, "toybox" shows available COMMAND names. Add --long
    to include suggested install path for each command, see
    https://landley.net/toybox/faq.html#install for details.
    First argument is name of a COMMAND to run, followed by any ARGUMENTS
    to that command. Most toybox commands also understand:
    --help Show command help (only)
    --version Show toybox version (only)
    The filename "-" means stdin/stdout, and "--" stops argument parsing.
    Numerical arguments accept a single letter suffix for
    kilo, mega, giga, tera, peta, and exabytes, plus an additional
    "d" to indicate decimal 1000's instead of 1024.
    Durations can be decimal fractions and accept minute ("m"), hour ("h"),
    or day ("d") suffixes (so 0.1m = 6s).
    xaga:/data/adb/busybox #
    130|xaga:/system/bin $ ls -al|nl|tail -n 20
    440 -rwxr-xr-x 1 root shell 33 2009-01-01 08:00 wm
    441 lrwxrwxrwx 1 root root 6 2022-10-08 15:33 xargs -> toybox
    442 -rwxr-xr-x 1 root shell 128 2009-01-01 08:00 xml2abx
    443 lrwxrwxrwx 1 root root 6 2022-10-08 15:33 xxd -> toybox
    444 lrwxrwxrwx 1 root root 6 2022-10-08 15:33 yes -> toybox
    445 lrwxrwxrwx 1 root root 6 2022-10-08 15:33 zcat -> toybox
    446 -rwxr-xr-x 1 root shell 65720 2009-01-01 08:00 zip_utils
    447 lrwxrwxrwx 1 root root 7 2022-10-08 15:33 zipinfo -> ziptool
    448 -rwxr-xr-x 1 root shell 28712 2009-01-01 08:00 ziptool
    • 大概有400+多命令的二进制文件

      • 比如大名鼎鼎的svc,可以用来调试NFC/蓝牙等外围设备

      • xaga:/system/bin $ svc -h
        Available commands:
        help Show information about the subcommands
        power Control the power manager
        usb Control Usb state
        nfc Control NFC functions
        bluetooth Control Bluetooth service
        system-server System server process related command
        xaga:/system/bin $ svc nfc -h
        Control NFC functions
        usage: svc nfc [enable|disable]
        Turn NFC on or off.

busybox_toybox加强指令集

android版
  • 高版本android可以通过magisk 刷入busybox模块(需要一定时间几十秒到1分钟左右甚至更长时间)
  • 查看busybox
    • BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as.
1|xaga:/data/adb/busybox # ls -al /system/xbin/busybox
-rwxrwxrwx 1 root root 2087000 2022-10-08 15:30 /system/xbin/busybox
127|xaga:/data/adb/busybox # busybox --help
BusyBox v1.34.1-osm0sis (2021-10-02 04:33:49 ADT) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
Usage: busybox [function [arguments]...]
or: busybox --list[-full]
or: busybox --show SCRIPT
or: busybox --install [-s] [DIR]
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.
Currently defined functions:
[, [[, acpid, adjtimex, ar, arch, arp, arping, ascii, ash, awk, base32, base64, basename, bbconfig,
beep, blkdiscard, blkid, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chat, chattr, chcon,
chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, comm, conspy, cp, cpio, crc32, crond,
...........................
....................
tc, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute,
traceroute6, true, truncate, ts, tty, ttysize, tunctl, tune2fs, ubiattach, ubidetach, ubimkvol,
ubirename, ubirmvol, ubirsvol, ubiupdatevol, udhcpc, udhcpc6, udhcpd, udpsvd, uevent, umount, uname,
uncompress, unexpand, uniq, unix2dos, unlink, unlzma, unlzop, unshare, unxz, unzip, uptime, usleep,
uudecode, uuencode, vconfig, vi, volname, watch, watchdog, wc, wget, which, whoami, whois, xargs,
xxd, xz, xzcat, yes, zcat, zcip
windows版
  • 可以通过scoop来安装,也可以直接使用官网的二进制文件
PS D:\repos\blogs\neep> busybox.exe
BusyBox v1.36.0-FRP-4621-gf3c5e8bc3 (2022-02-28 07:17:58 GMT)
(mingw64-gcc 11.2.1-3.fc35; mingw64-crt 9.0.0-2.fc35; glob)
BusyBox is copyrighted by many authors between 1998-2022.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
Usage: busybox [function [arguments]...]
or: busybox --list[-full]
or: busybox --install [-s] [-u|DIR]
or: busybox --uninstall [-n] file
or: function [arguments]...

常用指令

set1:
set2

toybox&busybox指令集(二进制程序)所在目录

xaga:/data/adb/busybox # type busybox
busybox is /system/xbin/busybox
xaga:/data/adb/busybox # type toybox
toybox is /system/bin/toybox

设置无操作后息屏时间

  • adb shell settings put system screen_off_timeout 600000
    • 60 ∗ 10 ∗ 1000 m s = 600 s = 10 m i n 60*10*1000ms=600s=10min 60101000ms=600s=10min
    • 有效值应该在5000(ms)以上
    • 否则无效
posted @   xuchaoxin1375  阅读(33)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2023-09-05 CN_@传输层协议@端口
2023-09-05 CN_UDP协议
2023-09-05 输入int a,b;求最简分数,
点击右上角即可分享
微信分享提示