DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-12-25 19:19:11

Winmax
New member
Registered: 2010-12-25
Posts: 2

Debian chroot - working with dropbear, rsync and mountet HD_a2

Hi,

i was working hard for a few days to get my CH3WNAS running on chrooted debian, and would like to share my knowlege, maybe some day somebody like me will find this thread helpfull smile


I fix'd the Wiki http://dns323.kood.org/dsmg600/howto:chroot_debian to the correct mirror. they moved it to an archive. I also fixed a little mistake in the instruction where to copy bootstrap too.

- First geht telnet running on your target system (yes, i did it on CH3WNAS)
- follow the steps in the wiki article.

then i made some improvements to get everything working nicely:

i wrote a little bash to mount the HDD to /mnt/hdd/ to see the whole drive. Don't know why, but i must do this every time i boot my DSM-G600/CH3WNAS, so we will put this in our fun_plug later.

i put this in /mnt/mountHDD.sh

Code:

#!/bin/sh
MOUNTED=$(/bin/mount | /bin/fgrep "/mnt/hdd");
if [ -n "$MOUNTED" ]; then
    echo `date` "drive is mounted, going to unmount"
    /bin/umount /mnt/hdd
fi
mount /dev/sda2 /mnt/hdd
echo `date`# "mounted to /mnt/hdd"

and then i edited fun_plug to this

Code:

#!/bin/sh
LOG="/mnt/HD_a2/fun_plug.log"
echo `date` "funplug found. keep fingers crossed" > $LOG
if [ ! -e /mnt/HD_a2/ash ]
then
  ln -s /mnt/HD_a2/busybox /mnt/HD_a2/ash
fi
if [ ! `grep root /etc/shadow` ]
then
  echo kontroll.`grep admin /etc/shadow` >> /etc/shadow
  /mnt/HD_a2/sed -i -e 's/kontroll.admin/root/' /etc/shadow
fi
/mnt/HD_a2/sed -i -e 's/root:.*/root:x:0:0:Linux User,,,:\/:\/mnt\/HD_a2\/ash/' /etc/passwd
cd /dev && /mnt/HD_a2/busybox makedevs ptyp c 2 0 0 9
cd /dev && /mnt/HD_a2/busybox makedevs ttyp c 3 0 0 9

echo "\n" `date` "starting telnet" >> $LOG
/mnt/HD_a2/busybox telnetd &

echo "\n" `date` "starting dropbear" >> $LOG
/mnt/HD_a2/chroot /mnt/HD_a2/debian /usr/sbin/dropbear >> $LOG

echo "\n" `date` "mounting HD_a2 to /mnt/hdd" >> $LOG
/mnt/HD_a2/chroot /mnt/HD_a2/debian /mnt/mountHDD.sh >> $LOG

echo "\n" `date` "done. Have a nice day." >> $LOG

another important thing - i think - is the usage of rsync. i was NOT able to get it running with apt-get install rsync, but with this one http://dns323.kood.org/downloads/rsync-2.6.8.tar.bz2 its good. Just download and extract to your nas and move it

Code:

cp /mnt/hdd/rsync /usr/bin/

otherwise you will get some strange messages like
rsync: pipe failed in do_recv: Address family not supported by protocol (97)
rsync error: error in IPC code (code 14) at main.c(702) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(601) [sender=3.0.7]


this is how i got ssh keypair working:

Code:

on source:
ssh-keygen -t dsa
scp ~/.ssh/id_dsa.pub root@192.168.1.1:/tmp

on target:
cd /root/.ssh/
cat /tmp/id_*.pub >> authorized_keys
chmod 0600 authorized_keys

Greetings
Max

Last edited by Winmax (2010-12-26 01:52:34)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB