从 PC 游戏中解压 .apk 文件(与 Android 无关)

逆向工程 开箱 十六进制
2021-07-11 12:28:51

我有一款名为 Air Strike 3D II 的旧 PC 游戏。我想提取音乐文件,但我不知道如何解压 .apk 文件(不是 Android 包)。7-zip 打不开。当我用 IDA 打开 .apk 文件时,它说(Unknown COFF machine)并且它无法反汇编它所以它不是一个汇编文件。

标题总是以0000803F 99990000. 有一个命名的文件夹sounds,它包含.wav文件sounds/biglaser.wavsounds/laser.wav等等......用WinHex中恢复文件,因为它被打包和压缩于事无补。

我找到了一个日志文件,上面写着

---- Initializing file system ----

pak1.apk - 733 files
pak2.apk - 45 files
pak4.apk - 1 files
F_Init: 
3 data files found.

我试图用 IDA 反汇编 .exe 文件,但没有任何用处,因为它被加密或混淆了。

Google 没有给我解决方案,因为它返回与 Android 相关的结果。我希望它可以显示 2008 年及更早的结果。

如果您想查看以下文件:https : //drive.google.com/open?id=0B_6TXpxCnMc7TGVfOWlYWjVYXzQ

1个回答

更新:我在这里写了整个文件格式:http : //www.tkte.ch/2017/02/27/air-strike-3d.html

这些文件没有被压缩,所以不用担心。由于您要做的就是提取这些波,我们可以作弊(很多)而忽略其他所有内容。让我们做一个简单的检查:

> strings -n 4 pak2.apk | grep RIFF -c
40

> strings -n 4 pak2.apk | grep WAVEfmt -c
40

嗯,这是有希望的。看起来我们有一堆由RIFF封装的WAV,这很常见。

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import struct

RIFF_MAGIC = b'RIFF'
RIFF_LENGTH = struct.Struct('<I')


def main():
    in_file = sys.argv[1]

    # Since the files are tiny lets cheat again and just read the entire thing.
    with open(in_file, 'rb') as fin:
        in_file = fin.read()

    offset = 0
    count = 0

    # We're going to skim through the file looking for the start of a RIFF file.
    while True:
        start = in_file.find(RIFF_MAGIC, offset)
        if start == -1:
            # None left, so we're done with this .apk.
            print('Extracted {0} files.'.format(count))
            return

        # Found one, so lets read the next 4 bytes which are the length of the RIFF file.
        length = RIFF_LENGTH.unpack_from(in_file, start + 4)[0]
        # The 8 comes from the 4 bytes for RIFF and the 4 bytes for the length
        # itself, which aren't included in the length.
        offset = start + 8 + length

        # annnnd save it.
        with open('wav_{0}.wav'.format(count), 'wb') as fout:
            fout.write(in_file[start:offset])

        count += 1

if __name__ == '__main__':
    sys.exit(main())

试一试...

> python extract.py pak2.apk
Extracted 40 files.

在 VLC 和 woohoo 中打开 WAV 之一,声音。