Created
June 14, 2014 05:34
-
-
Save ariscop/55f954e27ba04af0ed46 to your computer and use it in GitHub Desktop.
Quick script for extracting the firmware of an Hi351C based ip camera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
import binascii | |
with open("firmware_HI3518C-V5-ONVIF-V2.5.0.6_20140126124709.bin", "rb") as f: | |
print(" Magic:", f.read(8)) | |
print(" Unknown:", binascii.hexlify(f.read(4))) | |
length = struct.unpack("<L", f.read(4))[0] | |
print(" Length:", length) | |
print(" Flags?:", struct.unpack("<L", f.read(4))[0]) | |
hdr_len = struct.unpack("<L", f.read(4))[0] | |
print("header len:", hdr_len) | |
linux_len = struct.unpack("<L", f.read(4))[0] | |
print(" Linux len:", linux_len) | |
print(" Checksum?:", binascii.hexlify(f.read(4))) | |
f.seek(0) | |
print("Dumping header image") | |
hdr_img = f.read(hdr_len) | |
with open("header.img", "wb") as out: | |
out.write(hdr_img) | |
print("Dumping uboot image") | |
linux_img = f.read(linux_len) | |
with open("linux.img", "wb") as out: | |
out.write(linux_img) | |
print("cramfs hdr:", binascii.hexlify(f.read(4))) | |
cramfs_len = struct.unpack("<L", f.read(4))[0] | |
print("cramfs len:", cramfs_len) | |
f.seek(-8, 1) | |
print("Dumping cramfs image") | |
cramfs_img = f.read(cramfs_len) | |
with open("root.cramfs", "wb") as out: | |
out.write(cramfs_img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment