halmartin / meraki-builder

Scripts and tools to assemble firmware images for various Meraki MS switches and MX routers
GNU General Public License v3.0
70 stars 16 forks source link

postmerkOS software upgrade script #21

Open halmartin opened 2 years ago

halmartin commented 2 years ago

Disclaimer: The following proposal is regarding upgrading the alternative firmware on the switch and does not apply to the initial flashing to replace the Meraki firmware. There is currently no known RCE in the Meraki firmware, so a software-only method to initially install the firmware is impossible.


Since constantly having access to a hardware flashing device is annoying, it would be nice to have a method to upgrade the software on the switch without requiring disassembly and external flashing.

I have been experimenting with this over the past few days, and it seems reasonably stable.

cp /bin/busybox /tmp/
cp /usr/sbin/flash_erase /tmp/
killall chrony
killall syslogd
killall klogd
killall uhttpd
cd /tmp/
./flash_erase /dev/mtd3 0 0
./busybox dd if=rootfs.squashfs of=/dev/mtdblock3 bs=65535 conv=fsync
echo b > /proc/sysrq-trigger

I get rootfs.squashfs from buildroot, but of course you can just carve it out of the standard postmerkOS-YYYYMMDD.bin file as follows:

./busybox dd if=postmerkOS-YYYYMMDD.bin bs=1M skip=3 count=8 | ./busybox dd of=/dev/mtdblock3 bs=65535 conv=fsync

Putting these steps into an upgrade script (if it can be made reasonably reliable) would give people an easy route to upgrading the postmerkOS release on their unit.