-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] ArchLinux ARM Android chroot

, 24 2017 . 14:59 +
Linux Android , , . ArchLinux ArchLinux ARM . chroot, .


  • Android
  • Root
  • Busybox
  • ADB( )

.



  • Android 4.2 512 , Linux 3.4.5 armv7l
  • ConnectBot
  • SuperSU
  • BusyBox v1.20.0

1:


1. ArchLinux ARM :

wget http://mirror.yandex.ru/archlinux-arm/os/ArchLinuxARM-armv7-latest.tar.gz
mv ArchLinuxARM-armv7-latest.tar.gz ArchLinuxARM.tar.gz
adb push ArchLinuxARM.tar.gz /sdcard/

Android

2. make_ext4fs.

. 16 SD FAT .

/sdcard , .

cd sdcard
make_ext4fs -l 3221225472 arch.img

3221225472 1024*1024*1024*3, 3. . FAT32 4

3. ArchLinux ARM

mount -o rw,remount /
mkdir /arch
busybox mount /sdcard/arch.img /arch
tar -xvf ArchLinuxARM.tar.gz -C /arch/

4. , chroot, chroot . , .

busybox mount -t proc none /arch/proc
busybox mount -o rbind /dev /arch/dev
busybox mount -t tmpfs none /arch/tmp
busybox mount -o size=10%,mode=0755 -t tmpfs none /arch/run
chroot /arch /bin/bash

2:


1: ping


ping

ping 8.8.8.8
socket: Permission denied

, Android . . . .

Android id:

uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)



groupadd -g 3003 inet
usermod -a -G inet root

, chroot group. :

su root

:

ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=89.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=59 time=88.6 ms

2: DNS


systemd DNS:

rm /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf

PATH


, ls,cat,su ( ) , : /system/bin/ls, /system/bin/cat, /system/xbin/su.
.


pacman -S gcc htop iotop sudo openssh

gcc


cd /root
nano main.cpp

#include 
int main() {
std::cout << "Hello World!\n";
return 0;
}


g++ main.cpp
./a.out

3: chroot


, ArchLinux chroot , ArchLinux .

, , Android :

ls /etc/ > /sdcard/ls.txt
ls /arch/etc/ > /sdcard/ls2.txt
busybox grep -F -f /sdcard/ls.txt /sdcard/ls2.txt

. :

dhcpcd.conf
hosts
security

/etc/ /arch/etc/ Android:

cp -Ra /etc/* /arch/etc/
cp -a /sbin/adbd /arch/usr/bin/

-a , -R .

Root.


Android , su .

passwd
mv /usr/bin/su /usr/bin/su.r

4: !


mount --bind , .

mkdir /lib
mkdir /bin
mkdir /xbin
mkdir /opt
mkdir /usr
mkdir /home
mkdir /run
mkdir /srv
mkdir /tmp
mkdir /var
busybox mount --bind /arch/etc /etc
busybox mount --bind /arch/opt /opt
busybox mount --bind /arch/home /home
busybox mount -o size=10%,mode=0755 -t tmpfs none /run
busybox mount --bind /arch/srv /srv
busybox mount -t tmpfs none /tmp
busybox mount --bind /arch/sbin /sbin
busybox mount --bind /arch/usr/ /usr
busybox mount --bind /arch/var/ /var
busybox mount --bind /arch/lib/ /lib
busybox mount --bind /arch/usr/bin/ /bin
/bin/bash

- , . . ArchLinux , .


ArchLinux systemd .

http, php, mysql. 512 .

X Android . xterm .

(, , ) Linux .
Java ARM Java .


systemd PID 1. , PID 1 init exec . init shell , init . , switch_root . systemd .

16, . .
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/331546/

:  

: [1] []
 

:
: 

: ( )

:

  URL