Avoid being locked out of your ZSUN wifi reader

I was one of the guys that got the Zsun fever 🙂

I’m not going to get into details. For those you can check the Warsaw Hackerspace’s website. Those guys did an awesome job compiling information related to this tiny yet powerful device.

Originally it comes with a custom firmware that provides you with an access point that can be used to share files ( it has a microsd slot ). By flashing OpenWRT it allows you to unleash all it power and use it to several different things (access point, range extender, file server using different protocols, IoT, Tor server,  you name it), but since you can only access it via wifi ( there’s a physical ethernet port that you can use if you don’t mind tearing apart the case and solder an ethernet jack)  it can be very easy to lose access to the devices.

I’ve seen some people talking about a trick using the sd card slot during boot to force a software reset but it didn’t work for me, so I just decided to do something different.

 

The approach is easy. Create a script  that is loaded on boot and checks for a file on the memory card. If it’s there, then it issues a firstboot command to reset everything. This is similar to the update process of several gadgets and it’s easy to implement.

 

1º Flash the OpenWRT firmware ( check the hackerspace link )

2º Open the web interface. Enable the SD card automount feature and mount it on /mnt/sda1 (this should be the default). Enable enable SSH.

3º Log on using SSH. Create a file called restore inside /etc/init.d/ and dump the following contents there:

 

#!/bin/sh /etc/rc.common
# Copyright (C) 2009-2012 OpenWrt.org
 
START=50
 
start() {
  if [ -f "/mnt/sda1/restore" ]
  then
    echo "y" | /sbin/firstboot
    rm /mnt/sda1/restore
    /sbin/reboot
    echo "Rebooting to apply changes"
  fi
}
 
stop() {
  echo "Stop action not used."
}
 
reload() {
  echo "Reload action not used."
}
 
shutdown() {
  echo "Shutdown action not used."
}

 

4º Save the file and change the permissions to 755 ( chmod 0755 /etc/init.d/restore )

5º Enable the script on boot. To do so execute the following command: /etc/init.d/restore enable

And that’s it. If for any reason you mess up the wireless interface and lose access to the device, all you have to do is create a blank file inside the SD card called restore and the next time you boot the device it will detect this and force the reset.

Warsaw Hackerspace: https://wiki.hackerspace.pl/projects:zsun-wifi-card-reader

 

6 comments

  1. hi,

    The “firstboot” command need y or N input so I change the line to:

    echo “y” | /sbin/firstboot

    Hope this helps.

    Bench

  2. Excellent !
    Nice trick ! thank you !
    I would add that it’s better to change mount SD identification to label and not UUID

  3. How To reset OpenWRT for Zsun :

    Remove the SD card while power’s off.
    Power on and repeatedly insert/remove the SD card until the LED blinks FASTER than normal bootup.
    Connect to the newly reset OpenWRT network and quickly set a password and adjust the Wifi network settings.

    It works as I tried it (but not easy to repeatedly insert/remove the mSD, had to use a tiny knife)

Leave a Reply

Your email address will not be published.