うちで眠ってる無線 LAN アクセスポイントであるところの corega AP-11 が Linux で動いてることを思い出し,Linux 箱として遊べるんじゃないかと気づく。
早速ファームウェアを解析してみると,LILO ごと入っている。
しかもこのマシン語はなんとなく読めるぞ……。
APRS-11
と同じ x86 アーキテクチャか?
ひとまずファームウェア内のディスクイメージと思しき部分を Linux で mount して中を見る。
initrd.img が出てきたので,さらに mount して中を見る。
% cat etc/rc3.d/50release
#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin
if [ -f /etc/ap.conf ]; then
. /etc/ap.conf
fi
# stop ^S
echo /bin/stty -ixon > /.profile
# Is Release Version?
if [ "$ISRELEASE" ]; then
echo exec /usr/bin/serconfig >>/.profile
else
inetd
fi
exit 0
シリアルポートから root でログインすると,シェルのプロンプトは見えず環境設定用のメニューが表示されるのだが,それは ISRELEASE が定義されているためのようだ。
% grep ISRELEASE etc/ap.conf
ISRELEASE='yes'
確かに定義されている。
こいつを無効にすれば,inetd が動くということになる。
ところで inetd が動くと何が出来るのか。
% cat etc/inetd.conf
time stream tcp nowait root internal
time dgram udp wait root internal
#
login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind
#ftp stream tcp nowait root /usr/sbin/tcpd wu.ftpd -l -i
# End of inetd.conf.
なんとネットワーク経由でリモートログインができるらしい。
シリアルポートからログインしなくても良くなる。
ap.conf は initrd.img の外にあって圧縮されてないので,ファームウェアのイメージファイルを直接いじるだけでハックできる。
そこで,バイナリエディタで ISRELEASE='yes' の行の先頭 1 文字を # に書き換え,ファームウェアを更新してみた。
% rsh -l root ayaya
Password:
#
いとも簡単にログインできてしまった……。
# ls
lost+found bin boot dev etc lib
mnt proc sbin tmp usr var
# mount
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/ram 4027 3366 457 88% /
#
普通に Linux である。
# uname -a
Linux ayaya 2.2.17brfw #1 Tue Apr 23 17:19:22 JST 2002 i486 unknown
# cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 4
model : 10
model name : 02/0a
stepping : 4
fdiv_bug : no
hlt_bug : no
sep_bug : no
f00f_bug : no
coma_bug : no
fpu : no
fpu_exception : no
cpuid level : 1
wp : yes
flags :
bogomips : 33.18
# free
total used free shared buffers
Mem: 14992 9588 5404 3908 4112
Swap: 0 0 0
Total: 14992 9588 5404
i486 用のカーネルが動いている。
# ps
PID Uid Gid State Command
1 root root S init
2 root root S [kflushd]
3 root root S [kupdate]
4 root root S [kpiod]
5 root root S [kswapd]
106 root root S cron
111 root root S syslogd
123 root root S /sbin/cardmgr
141 root root S cw10d --maf_file /etc/maf.dat -n lo
167 root root S inetd
182 root root S /sbin/mgetty -r -x0 -s 9600 -i /etc/issue ttyS0 -p @
183 root root S /usr/sbin/mathopd
308 root root S in.rlogind
309 root root S -sh
350 root root R ps
# cardctl ident
Socket 0:
product info: "corega K.K.", "Wireless LAN PCC-11", "Ver. 1.01", ""
manfid: 0xc00f, 0x0000
function: 6 (network)
Socket 1:
no product info available
プロセスも普通に活動しとる。
PCMCIA カードスロット用に cardmgr が律儀に動いてるだけでなく,シリアルポートからのログインも mgetty が律儀に受け付けてくれてるもよう。
あと,ftp コマンドも発見。
どうぞ遊んでくださいと言わんばかり。
おまけに lilo コマンドもある。
# PS1="$(hostname)# "
ayaya# grep '^#' /etc/lilo.conf
#serial=0,9600n8
#delay=2
ayaya# echo "prompt" > /tmp/x
ayaya# echo "timeout=50" >> /tmp/x
ayaya# sed -e 's/^#s/s/' /etc/lilo.conf >> /tmp/x
ayaya# cat /tmp/x > /etc/lilo.conf
ayaya# mount /dev/flash1 /mnt
ayaya# lilo -v
LILO version 21, Copyright 1992-1998 Werner Almesberger
Reading boot sector from /dev/flash
Merging with /mnt/boot/boot.b
Boot image: /mnt/boot/zImage
Mapping RAM disk /mnt/boot/initrd.img
Added Linux *
/dev/null exists - no backup copy made.
Writing boot sector.
ayaya# umount /mnt
ayaya# reboot
これでシリアルポートから LILO を制御することは成功したが,カーネルに console=ttyS0,9600n8 オプションを渡しても,シリアルポートはコンソールとして機能しなかった。
残念。