Created
December 10, 2013 12:04
-
-
Save fffonion/7889604 to your computer and use it in GitHub Desktop.
ComicDown(千寻漫画盒) cdp文件解包器
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
#!/usr/bin/env python2 | |
# coding:utf-8 | |
# Tool for decoding ComidDown site files (.cdp) | |
# Contributor: | |
# fffonion <[email protected]> | |
import json | |
import struct | |
import zlib | |
f=open(r'178.cdp','rb') | |
cnt,sign=struct.unpack('<Ix3s',f.read(8)) | |
print cnt,sign | |
#offset 4 : 'x3s' | |
header=zlib.decompress(f.read(cnt-4),16+zlib.MAX_WBITS)#WTF! | |
j_header=json.loads(header) | |
print header | |
length,pos1,pos2=struct.unpack('<3I',f.read(12)) | |
print length,pos1,pos2 | |
body=list(f.read()) | |
#SwapBytes | |
while length > 0: | |
body[pos1],body[pos2]=body[pos2],body[pos1]; | |
length-=1; | |
pos1+=1; | |
pos2+=1; | |
body=''.join(body) | |
open(r'178.7z','wb').write(body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment