#FOLDNAME.TXT = "DAT" = 1 : "SEEN.TXT"9 I; E! W" G* y5 H2 m& r; C
#FOLDNAME.DAT = "DAT" = 0 : "DAT.PAK"* d7 ^" L4 F! `0 F" o6 Q
#FOLDNAME.ANM = "ANM" = 0 : "ANM.PAK"% ~1 C% V4 @) l/ G' l
#FOLDNAME.ARD = "ARD" = 0 : "ARD.PAK"
#FOLDNAME.HIK = "HIK" = 0 : "HIK.PAK"
#FOLDNAME.PDT = "PDT" = 0 : "PDT.PAK"" z' E" A5 |) r; V# U
#FOLDNAME.G00 = "G00" = 0 : "G00.PAK") l; v z8 H, x
#FOLDNAME.M00 = "M00" = 0 : "M00.PAK"! ^+ s- e2 V1 d n
#FOLDNAME.WAV = "WAV" = 0 : "WAV.PAK"
#FOLDNAME.BGM = "BGM" = 0 : "BGM.PAK"
#FOLDNAME.KOE = "KOE" = 1 : ""
#FOLDNAME.MOV = "MOV" = 0 : "MOV.PAK"
#FOLDNAME.GAN = "GAN" = 0 : "GAN.PAK"
def read_unsigned(infile, size = 4, endian = LITTLE_ENDIAN) : R: H$ B' V. x# o8 ]
result = long(0)
for i in xrange(size) :% z& ^. Q$ ?. U5 k5 h/ _
temp = long(ord(infile.read(1)))/ \) t- z2 U( \( x, u
if endian == LITTLE_ENDIAN :; k* I, j) g& e1 }* C
result |= (temp << (8*i))9 t4 X' k D* i, H, `8 z/ X
elif endian == BIG_ENDIAN :
result = (result << 8) | temp
return result
from insani import *
arcfile = open('cg.pd', 'rb')9 ?% l2 m/ R5 P( w
assert_string(arcfile,'PackOnly', ERROR_ABORT)
assert_zeroes(arcfile, 56, ERROR_WARNING)
numfiles = read_unsigned(arcfile, LONG_LENGTH)
print 'Extracting %d files...' % numfiles
print 'Reading archive index...'9 W/ ~$ q& g' N' n7 F
entries = []1 Z' c% g; v. Y9 g( H- h
for i in xrange(numfiles) :
filename = read_string(arcfile)
assert_zeroes(arcfile, 128-len(filename)-1)
position = read_unsigned(arcfile, LONG_LENGTH)
size = read_unsigned(arcfile, LONG_LENGTH)3 o% a+ O. H- ~8 O; H/ M
entries.append( (filename, position, size) )6 P, s! W V. V' `
assert_zeroes(arcfile, 144*(16384-numfiles), ERROR_WARNING)
entries
for (filename, position, size) in entries :* [/ S! q" e+ F! s
print 'Extracting %s (%d bytes) from offset 0x%X' % \
(filename, size, position)
outfile=open(filename,'wb')
assert (arcfile.tell() == position)
outfile.write( arcfile.read(size) )
outfile.close()! m% Q0 c n$ q, k' }
assert (arcfile.read(1) == '')5 i& Y% p4 J" [$ X6 A
arcfile.close()
% python crosschannel-extract1.py
Extracting 545 files...
Reading archive index...0 k7 R1 T1 e$ F* N0 Q; a2 Q
Extracting bgcc0000e.png (8370 bytes) from offset 0x240048, L: P) l. l( X% j
Extracting bgcc0023.png (538382 bytes) from offset 0x2420FA
...8 [# g; E% E7 d3 q, Y1 g
Extracting TCYM0005c.png (156881 bytes) from offset 0x566E1B4
import sys, os! I1 D% l, ^ S/ q
from insani import *( ^8 [6 a+ |2 |9 e/ s! h
% v7 z" t' z6 L) _+ M- ^/ u' i
dirname = sys.argv[1]
rawnames = os.listdir(dirname)
numfiles = 0
position = 144*16384+720 V0 p" x* Q+ v, S/ e. K
entries = []
for filename in rawnames :
fullpath = os.path.join(dirname,filename)
if os.path.isfile(fullpath) : # Skip any subdirectories- {/ L; h4 j) A' x' O: n) \& Q
numfiles += 1$ Z& s2 r9 I1 ~
size = os.stat(fullpath).st_size( m& @( \$ C. E4 Z* o
entries.append( (filename, fullpath, position, size) )6 f: R. [* F: d5 a. G/ D
position += size;
print 'Packing %d files...' % numfiles
arcfile = open(sys.argv[2],'wb')
arcfile.write('PackOnly')
write_zeroes(arcfile,56)( Z) a7 ?* I" M" S( j
write_unsigned(arcfile,numfiles,LONG_LENGTH)0 k9 q( p7 j1 I+ {
print 'Writing archive index...'
for (filename, fullpath, position, size) in entries :' S# B- z1 a/ ^# V# M. w
write_string(arcfile, filename)
write_zeroes(arcfile, 128-len(filename)-1)
write_unsigned(arcfile, position,LONG_LENGTH)
write_unsigned(arcfile, size,LONG_LENGTH)
write_zeroes(arcfile, 144*(16384-numfiles))
for (filename, fullpath, position, size) in entries :
print 'Packing %s (%d bytes) at offset 0x%X' % \
(filename, size, position)
assert (arcfile.tell() == position)( K) j6 L7 j: \2 P
infile = open(fullpath,'rb')
arcfile.write(infile.read(size)). ~+ X0 E0 u! R
infile.close()4 W/ u2 z: t; w9 e. j
arcfile.close()
% python crosschannel-repack1.py temp temp.pd
Packing 545 files...& b5 I6 P, ?" E1 [/ e k
Writing archive index...3 ^0 c% R% [& O8 b" o: m4 n1 E( Z4 J& L3 K
Packing bgcc0000a.png (408458 bytes) at offset 0x240048
Packing bgcc0000b.png (436171 bytes) at offset 0x2A3BD2
...$ i; P8 m9 X+ C: S$ Q
Packing xiconp.png (2399 bytes) at offset 0x5693D26
% diff cg.pd temp.pd- F+ ]$ V3 I/ B
Binary files cg.pd and temp.pd differ
% python crosschannel-extract2.py temp.pd temp2
Extracting 545 files...! X; j/ G% W" M& N( f0 s9 C
...2 Q& c& O- I. y0 I& Q, C: ~
% diff -r temp temp2
% python crosschannel_extract2.py script.pd script2 J2 T1 U* M! O+ S0 O9 j9 u' @
Expected "PackOnly" at position 0x0 but saw "PackPlus".# ~7 s2 b' l& W0 R% r
Aborting!
Traceback (most recent call last):; H* C8 H' o6 `4 q
...
arcfile=open('script.pd', 'rb')
arcfile.seek(0x240076)
data=arcfile.read(16)
outfile=open('bruteforce.dat', 'wb')
for i in xrange(256) :
for temp in data :
outfile.write(chr(ord(temp) ^ i))2 d1 Q# u# l" d
for temp in data :* K( L8 s0 c% N& C& I6 j* O
outfile.write(chr((ord(temp) + i) & 0x00FF))
outfile.close()0 |; _1 i c1 v7 u
arcfile.close()
signature = arcfile.read(8)" f) G" L5 K: L3 q: K6 }
if signature == 'PackOnly' :) }$ p: C1 X2 l. M0 n
xorbyte = 01 Z' V2 W' a' \! ^
elif signature == 'PackPlus' :
xorbyte = 0x00FF
else :
print 'Unknown file signature %s, aborting.' % \
escape_string(signature)
sys.exit(0)
data = array('B',arcfile.read(size))9 e, l2 z# r" o$ l$ u
if xorbyte != 0 :
for i in xrange(len(data)) :
data ^= xorbyte( O+ Z8 @+ v/ m# w: J1 R
outfile.write(data.tostring())
[blockquote]% python crosschannel-extract3.py script.pd script
Extracting 54 files...
Reading archive index...
Extracting adstart.dsf (236 bytes) from offset 0x240048% d3 k- O y- K! V3 A; g/ m
Extracting cca0001.dsf (934 bytes) from offset 0x240134! I; @( l% p: N2 p+ o8 X+ w, _
...
Extracting cca0011c.dsf (6674 bytes) from offset 0x297376[/blockquote]
欢迎光临 冒险解谜游戏中文网 ChinaAVG (https://chinaavg.com/) | Powered by Discuz! X3.2 |