Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def extract():
- print 'Extracting %s...' % sys.argv[2]
- filedata = get_data(sys.argv[2])
- newfiledata = ''
- decomplen = struct.unpack('<I',filedata[:4])[0]
- filedata = filedata[0x4:]
- ringbuff = []
- for i in range(0,0x1000):
- ringbuff.append('\x00')
- ringpos = 0xfee
- i = 0
- control = 0
- while len(newfiledata) < decomplen:
- control >>= 1
- oldcontrol = control
- if (control & 0x100) == 0:
- control = ord(filedata[i]) | 0xFF00
- i += 1
- oldcontrol = control
- ecx = ord(filedata[i])
- if (control & 1) != 0:
- ringbuff[ringpos] = chr(ecx)
- ringpos += 1
- ringpos &= 0xFFF
- newfiledata += chr(ecx)
- i += 1
- else:
- #003E672D - read from ring buff
- edx = ord(filedata[i+1])
- ebx = (edx & 0xF0) << 4
- ecx |= ebx
- edx &= 0xF
- ebx = ecx + edx + 2
- i += 2
- edx = ecx
- while edx <= ebx:
- ecx = edx
- ecx &= 0xFFF
- ecx = ord(ringbuff[ecx])
- ringbuff[ringpos] = chr(ecx)
- ringpos += 1
- ringpos &= 0xFFF
- newfiledata += chr(ecx)
- if len(newfiledata) >= decomplen:
- break;
- edx += 1
- control = oldcontrol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement