貳:+自动登录文件系统
$cat /mnt/squashfs-root/txt
#!/usr/bin/expect
sleep 5
set timeout 5
spawn "/bin/login"
expect "(none) login: " { send "root\n" }
expect "Password: " { send "ecoo1234\n" }
interact
$
chmod +x /mnt/squashfs-root/txt
$ cat /etc/profile
...
ip link set eth0 up(启动网卡)
sleep 5(等待启动完成)
route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0(一级路由器IP地址) && ifconfig eth0 192.168.1.10/24(本机IP地址) && ip route add default via 192.168.1.1(二级路由器IP地址) && rm -r /etc/resolv.conf; echo "nameserver 114.114.114.114(远程域名解析服务)\nnameserver 192.168.1.1(本地域名解析服务,即路由器DNS)" > /etc/resolv.conf(注:网关gateway已弃用)
cd /mnt/squashfs-root; mount -t devtmpfs none dev; mount -t sysfs none sys; mount -t devpts -o gid=5,mode=620 more dev/pts; mount -t proc proc proc; mount -t tmpfs none tmp; chroot ./ /txt
#must execute by bash here, not dash.
a=(` mount `)
str=/mnt/squashfs-root/
for word in ${a[*]}; do
if [[ $word == *$str* ]]; then
echo $word | awk -v m=$str '{gsub(m, ""); print}' |
tee umount
fi
done
poweroff
$
注:后来发现,应用下载的busybox static binary去mount --bind这些特殊分区,否则我这里会出现问题。