二进制数据的未知编码/序列化

问题描述 投票:0回答:1

所以我使用了一个名为“战争委员会”的应用程序,它用于在 ASOIAF 迷你战争游戏中构建陆军列表。它具有列表导出功能,可导出 Base64 编码的二进制 blob,如下所示:

EgVXYXRjaBgFICgoAFoHCIVSELagAVoDCJFSWgMIjFJaAwiRUmCm7gFgse4BYMPtAQ==

然后可以将其重新导入到另一部手机上的另一个应用程序等..

当我解码它并

xxd
时,我看到:

┌──(admuser㉿wkstation5)-[~]
└─$ xxd decoded2.txt 
00000000: 1209 6a6f 6b69 6e20 6361 7618 0620 2828  ..jokin cav.. ((
00000010: 005a 0708 ac51 10c8 9f01 5a07 08ec 5210  .Z...Q....Z...R.
00000020: c99f 015a 0308 f452 5a03 08ee 5260 90ef  ...Z...RZ...R`..
00000030: 0160 94ef 0160 92ef 01                   .`...`...

这是另一张:

Eglqb2tpbiBjYXYYBiAoKABaBwisURDInwFaBwjsUhDJnwFaAwj0UloDCO5SYJDvAWCU7wFgku8B

┌──(admuser㉿wkstation5)-[~]
└─$ xxd decode.txt 
00000000: 1205 5761 7463 6818 0520 2828 005a 0708  ..Watch.. ((.Z..
00000010: 8552 10b6 a001 5a03 0891 525a 0308 8c52  .R....Z...RZ...R
00000020: 5a03 0891 5260 a6ee 0160 b1ee 0160 c3ed  Z...R`...`...`..
00000030: 01                                       .

在上面的观察列表中,应该有一支守夜矛兵部队,其在战争委员会数据中的 ID 为 10513。但似乎无法从数据中得出这一点。如果它实际上是使用 id 来存储单位,我倾向于认为它是。

我做了一些分析,应用程序将所有单位表示为整数。我注意到

Watch
jokin cav
是我给他们的列表的名称。它似乎总是以
12
开头,而
05
09
表示后面字符串的长度。

我还尝试在 dart 和 java 中进行解码,因为这是在 flutter 引擎中制作的,该引擎使用 dart 并在 android 上编译成 java。

import 'dart:convert';

void main() {
    // Your base64 encoded string
    String base64EncodedString = 'EgVXYXRjaBgFICgoAFoHCIVSELagAVoDCJFSWgMIjFJaAwiRUmCm7gFgse4BYMPtAQ==';

    // Decode the base64 string
    String serializedData = utf8.decode(base64.decode(base64EncodedString));

    try {
        // Try to parse the data as JSON
        dynamic deserializedObject = json.decode(serializedData);

        // Check if the deserialized object is a JSON-like map or an array of integers
        if (deserializedObject is Map) {
            print("Deserialized JSON-like object: $deserializedObject");
        } else if (deserializedObject is List) {
        //} else if (deserializedObject is List && deserializedObject.every((element) => element is int)) {
            print("Deserialized array of integers: $deserializedObject");
        } else {
            print("Deserialized data is of unknown type");
        }
    } catch (e) {
        print("Error during deserialization: $e");
    }
}

Java:

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.util.Base64;

public class Base64Decoder {
    public static void main(String[] args) {
        String base64EncodedString = "EgVXYXRjaBgFICgoAFoHCIVSELagAVoDCJFSWgMIjFJaAwiRUmCm7gFgse4BYMPtAQ==";

        try {
            // Decode the base64 string into bytes
            byte[] data = Base64.getDecoder().decode(base64EncodedString);

            // Attempt to deserialize the object
            Object deserializedObject = deserialize(data);
            System.out.println("Deserialized object: " + deserializedObject);
        } catch (IOException | ClassNotFoundException e) {
            System.out.println("Deserialization failed: " + e.getMessage());
        }
    }

    private static Object deserialize(byte[] data) throws IOException, ClassNotFoundException {
        try (ByteArrayInputStream bis = new ByteArrayInputStream(data);
             ObjectInputStream in = new ObjectInputStream(bis)) {
            return in.readObject();
        }
    }
}

但是运气不好,都失败了。

很好奇是否有人知道这是什么类型的编码/序列化以及我如何破译它,以便我可以弄清楚如何以编程方式构建/导入列表到我正在开发的其他产品中。

这是另一个示例:

EglWaWN0YXJpb24YCCAoKABaAwi4VFoHCLdUEMOiAVoDCLFUWgMItFRaAwiyVGDT8AFg1PABYNXwAQ==

└─$ xxd enc.txt 
00000000: 1209 5669 6374 6172 696f 6e18 0820 2828  ..Victarion.. ((
00000010: 005a 0308 b854 5a07 08b7 5410 c3a2 015a  .Z...TZ...T....Z
00000020: 0308 b154 5a03 08b4 545a 0308 b254 60d3  ...TZ...TZ...T`.
00000030: f001 60d4 f001 60d5 f001                 ..`...`...
java flutter dart deserialization decode
1个回答
0
投票

其中任何一个看起来符合您的期望吗

2: {"Watch"}
3: 5
4: 40
5: 0
11: {`083f52103f3f01`}
11: {`083f52`}
11: {`083f52`}
11: {`083f52`}
12: 63
`3f01603f3f01603f3f010d0a`


2: {"jokin cav"}
3: 6
4: 40
5: 0
11: {`083f51103f3f01`}
11: {`083f52103f3f01`}
11: {`083f52`}
11: {`083f52`}
12: 63
`3f01603f3f01603f3f010d0a`



2: {"Victarion"}
3: 8
4: 40
5: 0
11: {
  1: 63
  10:EGROUP
}
11: {`083f54103f3f01`}
11: {
  1: 63
  10:EGROUP
}
11: {
  1: 63
  10:EGROUP
}
11: {
  1: 63
  10:EGROUP
}
12: 63
`3f01603f3f01603f3f010d0a`

这是您解释为协议缓冲区的数据(由谷歌设计,因此对于 dart 应用程序来说可能是合理的?)

我是通过(在 Windows 上)完成此操作的

  1. 将你的base64放入文件中
  2. 运行 CertUtil (
    certutil -decode in.txt out.bin
    )
  3. 运行原镜 (
    cat out.bin|protoscope
    ) Protscope 是一个来自 here
  4. 的 go 程序

这有帮助吗?

© www.soinside.com 2019 - 2024. All rights reserved.