Skip to content

Instantly share code, notes, and snippets.

@fffonion
Created December 10, 2013 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fffonion/7889604 to your computer and use it in GitHub Desktop.
Save fffonion/7889604 to your computer and use it in GitHub Desktop.
ComicDown(千寻漫画盒) cdp文件解包器
#!/usr/bin/env python2
# coding:utf-8
# Tool for decoding ComidDown site files (.cdp)
# Contributor:
# fffonion <fffonion@gmail.com>
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