![]() |
NAS200.Telnet HistoryHide minor edits - Show changes to markup April 02, 2008, at 12:54 PM
by -- Added update with link to Jac0 firmware
Added lines 1-3:
UPDATE: See this thread on linksysinfo.org for information about a modified firmware by the same author which supports not only telnet, but also dropbear (ssh secure shell and file transfer), ext2 filesystems, custom startup scripts and more. March 02, 2008, at 06:53 PM
by -- Attempt at improving layout
Changed lines 58-59 from:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10:39.000000000 -0700 +++ source/Makefile 2008-01-22 12:55:46.000000000 -0700 to:
--- org/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10:39.000000000 -0700 +++ new/NAS200_V34R62_GPL/source/Makefile 2008-01-22 12:55:46.000000000 -0700 Changed lines 120-121 from:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/busybox-1.00-rc2/.config 2007-05-23 19:02:28.000000000 -0700 +++ source/busybox-1.00-rc2/.config 2008-01-20 13:42:08.000000000 -0700 to:
--- org/NAS200_V34R62_GPL/source/busybox-1.00-rc2/.config 2007-05-23 19:02:28.000000000 -0700 +++ new/NAS200_V34R62_GPL/source/busybox-1.00-rc2/.config 2008-01-20 13:42:08.000000000 -0700 Changed lines 145-146 from:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/busybox-1.00-rc2/networking/telnetd.c 2006-07-31 19:04:04.000000000 -0700 +++ source/busybox-1.00-rc2/networking/telnetd.c 2008-01-19 23:44:19.000000000 -0700 to:
--- org/NAS200_V34R62_GPL/source/busybox-1.00-rc2/networking/telnetd.c 2006-07-31 19:04:04.000000000 -0700 +++ new/NAS200_V34R62_GPL/source/busybox-1.00-rc2/networking/telnetd.c 2008-01-19 23:44:19.000000000 -0700 Changed lines 168-169 from:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/mipsel/target/etc.default/rc.d/rc.1 2007-04-05 01:15:52.000000000 -0700 +++ source/mipsel/target/etc.default/rc.d/rc.1 2008-01-20 11:21:51.000000000 -0700 to:
March 02, 2008, at 06:47 PM
by -- Fix text in Unpacking section
Changed lines 33-36 from:
This will create a directory NAS200_V34R62_GPL. You should be able to simply cd to that directory, use su to become root and type: If you want, you can build the firmware now and download it to your NAS200. A
make takes about 20 minutes on my 2.8GHz Pentium4 without hyperthreading. The resulting firmware works virtually flawlessly on my system, except for a problem with the Twonky database which seems to get garbled by the self-compiled firmware. The media server is not critical to my use so I will research this later.
to:
This will create a directory NAS200_V34R62_GPL. If you want, you can cd to that directory, use A
make takes about 20 minutes on my 2.8GHz Pentium4 without hyperthreading. The resulting firmware works virtually flawlessly on my system, except for a problem with the Twonky database which seems to get garbled by the self-compiled firmware. The media server is not critical to my use so I will research this later.
March 02, 2008, at 06:19 PM
by -- Oops that line DID need to be there, sorry
Added line 95:
for i in ${SUBDIRS} ; do make -C $$i clean || exit 1 ; done
February 08, 2008, at 10:00 PM
by -- Fixed repeated line in previously pasted code
Deleted line 94:
for i in ${SUBDIRS} ; do make -C $$i clean || exit 1 ; done
February 08, 2008, at 08:55 PM
by -- Add tip about multiple sessions
Changed lines 104-105 from:
to:
Note: The above will only allow one terminal to be open, i.e. only one Telnet daemon can run. If you want to allow multiple simultaneous Telnet sessions, add more device nodes in the dev/pts directory, e.g. for x in 0 1 2 3 4 5 6 7;do mknod $x c 136 $x;done . January 26, 2008, at 12:36 AM
by -- Add link
Added lines 3-4:
You can download the sources from the author's website: http://www.goudsm.it/nas200_telnetd_source.tgz md5sum 000170bf83b4faff522475b7a2ccc128. That tarball includes a script to download and unpack the Linksys sources if you don't already have them, and to unpack the necessary files into the source tree. January 22, 2008, at 08:12 PM
by -- Modify remarks about conditional telnetd (and fix command line there)
Changed lines 180-181 from:
You can modify the script line to "install" telnetd conditionally if you are concerned about security. For example you could do: to:
You can modify the script line to "install" telnetd conditionally if you are concerned about security. For example you could do:
# Conditional code for rc.1 if [ -f /harddisk/volume_1/data/telnetd_enable.txt ] then echo "telnet stream tcp nowait root /usr/sbin/telnetd -l /bin/sh" >>/etc/inetd.conf fi Then, whenever the box boots up it will check if a file January 22, 2008, at 08:01 PM
by -- Fix mangled diff output (oops sorry, I wish Preview would work in this wiki)
Changed lines 56-57 from:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10 :39.000000000 -0700 to:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10:39.000000000 -0700 Changed lines 59-62 from:
echo "-----------------------------------------------------------------" ; make -C $$i || exit 1 ; \ to:
echo "-----------------------------------------------------------------"; make -C $$i || exit 1 ; \ Changed lines 72-77 from:
@for i in ${SUBLIBS} ; do
echo "-----------------------------------------------------------------"
; echo -e "\033[;35m $$i \033[;0m" ; \ to:
@for i in ${SUBLIBS} ; do echo "-----------------------------------------------------------------"; echo -e "\033[;35m $$i \033[;0m"; \
Changed line 83 from:
- ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no- ragments -lzma to:
- ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no-fragments -lzma Changed line 86 from:
+ ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no- ragments -lzma -noappend to:
+ ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no-fragments -lzma -noappend January 22, 2008, at 07:59 PM
by -- Added change to chown command in source/Makefile
Added line 46:
Changed lines 56-57 from:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10:39.000000000 -0700 +++ source/Makefile 2008-01-20 13:13:14.000000000 -0700 to:
--- ../../nas_pristine/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10 :39.000000000 -0700 +++ source/Makefile 2008-01-22 12:55:46.000000000 -0700 Changed lines 60-61 from:
echo "-----------------------------------------------------------------"; make -C $$i || exit 1 ; \ to:
echo "-----------------------------------------------------------------" ; make -C $$i || exit 1 ; \ Changed lines 75-79 from:
@for i in ${SUBLIBS} ; do echo "-----------------------------------------------------------------"; echo -e "\033[;35m $$i \033[;0m";
to:
@for i in ${SUBLIBS} ; do
echo "-----------------------------------------------------------------"
; echo -e "\033[;35m $$i \033[;0m"
; cp -f $(LINUXDIR)/fs/nls/nls_cp932.ko $(PLATFORMDIR)/target/lib/
cp -f $(LINUXDIR)/fs/nls/nls_cp949.ko $(PLATFORMDIR)/target/lib/
cp -f $(LINUXDIR)/fs/nls/nls_cp950.ko $(PLATFORMDIR)/target/lib/
- chown root.root $(PLATFORMDIR)/target -R + chown root.root $(PLATFORMDIR)/target -Rh Changed line 89 from:
- ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no-fragments -lzma to:
- ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no- ragments -lzma Changed line 92 from:
+ ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no-fragments -lzma -noappend to:
+ ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no- ragments -lzma -noappend January 22, 2008, at 06:56 PM
by -- fixed false wikilink
Changed lines 8-9 from:
At the time of this writing, there is no known way to get shell access if your NAS runs unmodified (V34R62?) firmware. to:
At the time of this writing, there is no known way to get shell access if your NAS runs unmodified (V34R62) firmware. January 20, 2008, at 11:40 PM
by -- Initial (finished for now)
Changed lines 1-2 from:
This page describes how to get a Telnet daemon (telnetd) running on a NAS200. You won't need the serial port so you won't need to void the warranty by breaking the seal. However, you do this procedure at your own risk and I won't pay for your repairs. If you do something wrong and brick your box, you're on your own; there are currently (as of January 20th, 2008) no easy ways to unbrick the NAS200. to:
This page describes how to get a Telnet daemon (telnetd) running on a NAS200. You won't need the serial port so this won't void the warranty. However, you do this procedure at your own risk and I won't pay for your repairs. If you do something wrong and brick your box, you're on your own; there are currently (as of January 20th, 2008) no known easy ways to unbrick a NAS200. Changed lines 12-13 from:
A quick perusal of the firware sources reveals that there simply is no Telnet daemon on the box. Nor is there a dropbear or any other way of remote shell access. So, short of opening the box (which voids the warranty because you have to break a seal to do it) and using the serial port, the only way to get shell access is to build a modified firmware that runs a Telnet daemon. to:
A quick perusal of the firware sources reveals that there simply is no telnet daemon on the box. Nor is there a dropbear or any other program that allows shell access. And as far as I could tell, there is no way to make the NAS200 execute scripts or programs on the harddisk. So, short of opening the box and using the serial port (which voids the warranty because you have to break a seal), the only way to get shell access is to build a modified firmware that runs a Telnet daemon (telnetd). Changed lines 15-25 from:
To do this, you will need a PC running Linux to which you have root access; it needs to have the usual programming tools such as Gnu Make to be able to build the firmware. I use a Gentoo-based system updated to a recent Portage tree; on this 2.8GHz Pentium 4 (no hyperthreading), the build of the entire firmware tree takes around 20 minutes. Unpack firmware source packageto:
To do this, you will need a PC running Linux to which you have root access. You will need some programming tools such as Gnu Make to be able to build the firmware, but if you're here, you probably already have those or you know how to get them. If not, you're probably not qualified to do this, so get some help. Unpack the firmware sourceChanged lines 29-30 from:
tar xfvz NAS200_V34R62.tgz
to:
tar xfvz NAS200_V34R62.tgz
Changed lines 33-41 from:
make This will create the image file images/NAS200_V34R62.bin, which includes the kernel and the root file system. The boot loader is created with a different make command but we're not going to bother with it here (breaking the boot loader is the easiest way to brick a device with embedded software so it's good that we don't need to build it). The process takes about 20 minutes on my Pentium4 at 2.8GHz (no hyperthreading). If you succeeded in building the firmware, you are well on your way (if not, you will have to get the appropriate tools such as GNU make and start over). If you want, you can download the self-compiled firmware to your NAS200 by going to the firmware download page, and you can verify how it works. It seems to work perfectly fine on my system, although apparently there is a problem with the Twonky database which seems to get garbled by the self-compiled firmware. The media server is not critical to my use so I will research this later. to:
If you want, you can build the firmware now and download it to your NAS200. A make takes about 20 minutes on my 2.8GHz Pentium4 without hyperthreading. The resulting firmware works virtually flawlessly on my system, except for a problem with the Twonky database which seems to get garbled by the self-compiled firmware. The media server is not critical to my use so I will research this later.
Modify Makefile and scriptsThe We will want to make a few modifications to the target file system, so we're going to modify the
Change source/Makefile as follows:
Here's a
--- ../../nas_pristine/NAS200_V34R62_GPL/source/Makefile 2007-06-21 20:10:39.000000000 -0700
+++ source/Makefile 2008-01-20 13:13:14.000000000 -0700
@@ -49,7 +49,7 @@
echo "-----------------------------------------------------------------"; \
make -C $$i || exit 1 ; \
done
-install:
+cleantarget:
rm -rf $(PLATFORMDIR)/target/
ifneq ($(MEDIA_SERVER), __YES__)
ifeq ($(SLIM_SERVER), __YES__)
@@ -60,6 +60,7 @@
else
tar -xvzf $(PLATFORMDIR)/target-default-media.tgz -C $(PLATFORMDIR)/
endif
+install:
@for i in ${SUBLIBS} ; do \
echo "-----------------------------------------------------------------"; \
echo -e "\033[;35m $$i \033[;0m"; \
@@ -78,13 +79,12 @@
chown root.root $(PLATFORMDIR)/target -R
rm -f $(PLATFORMDIR)/romdisk
$(STRIP) $(PLATFORMDIR)/target/lib/*.0.0
- ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no-fragments -lzma
- rm -rf $(PLATFORMDIR)/target
image:
+ ./mksquashfs $(PLATFORMDIR)/target $(PLATFORMDIR)/romdisk -le -noI -no-fragments -lzma -noappend
cp -f $(LINUXDIR)/arch/i386/boot/bzImage ../images
cp $(PLATFORMDIR)/romdisk ../images -f
-clean:
+clean: cleantarget
for i in ${SUBLIBS} ; do make -C $$i clean || exit 1 ; done
for i in ${SUBDIRS} ; do make -C $$i clean || exit 1 ; done
Add device nodes and softlinksThe telnetd program uses the PTS terminals which are compiled into the kernel (in the Busybox config,
I will explain below that apparently the system expects telnetd to be in the
Changed lines 101-116 from:
Modify build scriptsLet's change a couple of scripts that aren't part of the actual firmware, so that it'll be easier for us to make changes. source/MakefileFirst of all, Modify Busybox configurationFix Busybox bugsModify inetd configurationAdd device nodesBuildto:
Modify Busybox configurationThe Busybox version that's in the NAS200 tree is quite old (1.00-rc2), but it works fine. Linksys included a .config file but on my system, To do this, edit the
Again, here's a --- ../../nas_pristine/NAS200_V34R62_GPL/source/busybox-1.00-rc2/.config 2007-05-23 19:02:28.000000000 -0700 +++ source/busybox-1.00-rc2/.config 2008-01-20 13:42:08.000000000 -0700 @@ -321,7 +321,8 @@ CONFIG_TELNET=y CONFIG_FEATURE_TELNET_TTYPE=y CONFIG_FEATURE_TELNET_AUTOLOGIN=y -# CONFIG_TELNETD is not set +CONFIG_TELNETD=y +CONFIG_FEATURE_TELNETD_INETD=y # CONFIG_TFTP is not set # CONFIG_TRACEROUTE is not set # CONFIG_VCONFIG is not set CONFIG_TELNETD=y Fix Busybox bugThe telnetd code of the Busybox code that's part of the NAS200 source tree causes a segmentation fault when it tries to copy a NULL pointer that is returned by the ptsname(3) system function. The ptsname(3) function determines what the slave device is that belongs to a terminal device, but it's not thread-safe. In the kernel that's part of the NAS200 source package, ptsname() fails, but its thread-safe equivalent ptsname_r(3) works. We'll have to change the program so that it uses the ptsname_r(3) instead of ptsname(3):
Here's a
--- ../../nas_pristine/NAS200_V34R62_GPL/source/busybox-1.00-rc2/networking/telnetd.c 2006-07-31 19:04:04.000000000 -0700
+++ source/busybox-1.00-rc2/networking/telnetd.c 2008-01-19 23:44:19.000000000 -0700
@@ -197,7 +197,7 @@
if (p > 0) {
grantpt(p);
unlockpt(p);
- strcpy(line, ptsname(p));
+ ptsname_r(p, line, 32);
return(p);
}
#else
Hardcoding the value 32 is slighlty nasty but is a quick solution which is relatively safe because the function is static and only gets called from one place. It's no less unsafe that using strcpy. Modify inetd configurationOne of the first programs that gets executed as part of the boot process, is a (closed-source) program called
--- ../../nas_pristine/NAS200_V34R62_GPL/source/mipsel/target/etc.default/rc.d/rc.1 2007-04-05 01:15:52.000000000 -0700 +++ source/mipsel/target/etc.default/rc.d/rc.1 2008-01-20 11:21:51.000000000 -0700 @@ -10,6 +10,7 @@ mkdir -p /mnt/backup 2>/dev/null mkdir -p /mnt/queue 2>/dev/null /bin/echo "Starting Set CGI_ds.conf:"; /usr/sbin/rc.bootbin +echo "telnet stream tcp nowait root /usr/sbin/telnetd -l /bin/sh" >>/etc/inetd.conf /bin/echo "Restore time and timezone:"; /etc/rc.d/rc.rstimezone /bin/echo "Restore usrgrpshares:"; /usr/sbin/reset_ugs /bin/echo "Starting WEB Server:"; /etc/rc.d/rc.thttpd ATTENTION
The line that gets added to the inetd configuration runs telnetd with You can modify the script line to "install" telnetd conditionally if you are concerned about security. For example you could do: Build everything and download itNow you are ready to build your firmware image:
Unless you did something stupid that keeps the box from booting, you can always return to the original firmware. January 20, 2008, at 05:58 AM
by -- Initial (under construction)
Added lines 1-57:
This page describes how to get a Telnet daemon (telnetd) running on a NAS200. You won't need the serial port so you won't need to void the warranty by breaking the seal. However, you do this procedure at your own risk and I won't pay for your repairs. If you do something wrong and brick your box, you're on your own; there are currently (as of January 20th, 2008) no easy ways to unbrick the NAS200. What we will accomplish here, and howIf you're on this website, you're probably interested in making the NAS200 do more than what it was designed to do. One of the first things you probably want is to get shell access to the device. At the time of this writing, there is no known way to get shell access if your NAS runs unmodified (V34R62?) firmware. The good news is that Linksys not only made the GPL source code available (as they should), but they went one step further and generously put the entire ROM file system into the package, including the Twonkymedia server, a correctly configured GCC compiler and the shell scripts to build a valid boot image that you can download into the box without even walking away from your Linux-based PC. A quick perusal of the firware sources reveals that there simply is no Telnet daemon on the box. Nor is there a dropbear or any other way of remote shell access. So, short of opening the box (which voids the warranty because you have to break a seal to do it) and using the serial port, the only way to get shell access is to build a modified firmware that runs a Telnet daemon. To accomplish this, we'll need to do the following:
To do this, you will need a PC running Linux to which you have root access; it needs to have the usual programming tools such as Gnu Make to be able to build the firmware. I use a Gentoo-based system updated to a recent Portage tree; on this 2.8GHz Pentium 4 (no hyperthreading), the build of the entire firmware tree takes around 20 minutes. Unpack firmware source packageYou can download the NAS200 (version 34R62) firmware source code from the linksys FTP server. You should unpack the file in the usual way: tar xfvz NAS200_V34R62.tgz
This will create a directory NAS200_V34R62_GPL. You should be able to simply cd to that directory, use su to become root and type: make This will create the image file images/NAS200_V34R62.bin, which includes the kernel and the root file system. The boot loader is created with a different make command but we're not going to bother with it here (breaking the boot loader is the easiest way to brick a device with embedded software so it's good that we don't need to build it). The process takes about 20 minutes on my Pentium4 at 2.8GHz (no hyperthreading). If you succeeded in building the firmware, you are well on your way (if not, you will have to get the appropriate tools such as GNU make and start over). If you want, you can download the self-compiled firmware to your NAS200 by going to the firmware download page, and you can verify how it works. It seems to work perfectly fine on my system, although apparently there is a problem with the Twonky database which seems to get garbled by the self-compiled firmware. The media server is not critical to my use so I will research this later. Modify build scriptsLet's change a couple of scripts that aren't part of the actual firmware, so that it'll be easier for us to make changes. source/MakefileFirst of all, Modify Busybox configurationFix Busybox bugsModify inetd configurationAdd device nodesBuild
view ·
edit ·
print ·
history ·
Last edited by Jac Goudsmit.
Based on work by Jac Goudsmit and fcarolo. Originally by Jac Goudsmit. Page last modified on April 02, 2008, at 12:54 PM
|