notes/Working with Firmware BIN files wifi pineapple example-AVZfGSrx.sh
wget "http://wifipineapple.com/index.php?downloads&downloadUpgrade=2.8.0" -O upgrade.bin
binwalk upgrade.bin
example output:
DECIMAL HEX DESCRIPTION
-------------------------------------------------------------------------------------------------------
0 0x0 Squashfs filesystem, little endian, version 4.0, compression: size: 5197504 bytes, 1579 inodes, blocksize: 262144 bytes, created: Sun Mar 3 08:24:39 2013
6291456 0x600000 uImage header, header size: 64 bytes, header CRC: 0xD22A6633, created: Sun Mar 3 08:24:44 2013, image size: 913361 bytes, Data Address: 0x80060000, Entry Point: 0x80060000, data CRC: 0x3085D0DC, OS: Linux, CPU: MIPS, image type: OS Kernel Image, compression type: lzma, image name: "MIPS OpenWrt Linux-3.7.9"
6291520 0x600040 LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 2808940 bytes
we want the first partition in this case, so we will extract it using ‘dd’
dd if=upgrade.bin of=pineapple.img bs=1 count=5197504 #the 5197504 is from the binwalk output.
unsquashfs pineapple.img #creates and extracts to folder ‘squashfs-root’
If you want to put the extracted files into an img file:
du squashfs-root #find out how big the squashfs-root dir is (Just over 20M in this case)
dd bs=512 count=50000 if=/dev/zero of=openwrt.img #creates a empty IMG file that is about 26M
mkdir op
sudo mount -o loop openwrt.img op
sudo cp -pfr squashfs-root/* op/ #copies with permissions intact
sudo umount op