Last active
          December 30, 2016 19:59 
        
      - 
      
- 
        Save hdo/47f64a943b41334a291d to your computer and use it in GitHub Desktop. 
    Extract Dahua uImage squashfs files
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | #!/usr/bin/env python | |
| import os | |
| import sys | |
| def main(argv): | |
| fname = "" | |
| if len(argv) > 0: | |
| fname = argv[0] | |
| if not os.path.exists(fname) and not os.path.isfile(fname): | |
| print "expecting file!" | |
| return | |
| if not fname.endswith('.img'): | |
| print "expection img file" | |
| return | |
| raw_name = fname + ".raw" | |
| extract_name = fname + ".dir" | |
| strip_cmd = 'dd if="%s" bs=1 skip=64 of="%s"' % (fname, raw_name) | |
| print strip_cmd | |
| os.system(strip_cmd) | |
| extract_cmd = 'unsquashfs -d "%s" "%s"' % (extract_name, raw_name) | |
| print extract_cmd | |
| os.system(extract_cmd) | |
| print "done" | |
| if __name__ == "__main__": | |
| main(sys.argv[1:]) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment