Skip to content

Instantly share code, notes, and snippets.

@dwalters-zz
Created June 19, 2012 23:07
Show Gist options
  • Save dwalters-zz/2957075 to your computer and use it in GitHub Desktop.
Save dwalters-zz/2957075 to your computer and use it in GitHub Desktop.
Extract kernal and root filesystem images from the Linksys EA3500 firmware.
#!/usr/bin/env ruby
#
# Requires Ruby 1.9, and extracts the uImage header, kernel, and jffs root image from a stock
# firmware.
Encoding.default_external = "binary"
FW_FILENAME = "FW_EA3500_1.0.30.126544.SSA"
data = File.read(FW_FILENAME)
fs_offset = data.index("\x00\x00\x85\x19".force_encoding("binary")) + 2
puts "found jffs2 root at offset 0x%x" % [fs_offset]
File.write("uImage.img", data[0, fs_offset])
File.write("jffs2.rootfs.img", data[fs_offset..-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment