Last active
          March 24, 2018 08:54 
        
      - 
      
- 
        Save NWPlayer123/870f1d27a9be84e6259050d417cb7c25 to your computer and use it in GitHub Desktop. 
    faster, checks for magic bytes
  
        
  
    
      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
    
  
  
    
  | from zlib import decompress | |
| from io import BytesIO | |
| import sys | |
| data = open(sys.argv[1], "rb").read() | |
| #use this without making giant range() array | |
| size = len(data) - 1 | |
| #better than a string ? | |
| output = BytesIO() | |
| #get byte 0 for the loop | |
| char = data[0] | |
| #cuz size counts down | |
| pos = 0 | |
| num_chunks = 0 | |
| while size: | |
| if char == "\x78": | |
| if data[pos+1] in ["\x01", "\x9C", "\xDA"]: | |
| try: | |
| test = decompress(data[pos:]) | |
| output.write(test) | |
| num_chunks += 1 | |
| except: | |
| pass | |
| pos += 1 | |
| char = data[pos] | |
| size -= 1 | |
| output.seek(0) | |
| print("num_chunks: %d" % num_chunks) | |
| name = sys.argv[1].split(".") | |
| name = name[:-1] + ["d"] + [name[-1]] | |
| with open(".".join(name), "wb") as o: | |
| o.write(output.read()) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment