知道如何解码这个二进制数据吗?

逆向工程 开箱 文件格式
2021-06-25 10:52:49

我有表示表的二进制数据。

这是我使用 Python 的repr()打印时的数据\xff\xff\x05\x04test\x02A\x05test1@\x04\x03@@\x04\x05@0\x00\x00@\x05\x05test2\x03\x05\x05test1\x06@0\x00\x01@\x00

这是该表在专有软件中的样子。

        test1        
        test1test1
test          test1
test1                
test1test2        
                        
                        
test1                
test1                
test1                
        test1        
        test1        
                        
                        
test1                
test1                

我猜到了其中的一些:

  • 它是逐列然后逐个单元格,从左上角的单元格开始。
  • \x04\x04test似乎是以下单词的长度(以字节我猜)。
  • @ 意思是最后一个值

任何人都知道数据是否遵循标准或有任何如何解码的提示?

谢谢!

这是一个 python 示例:

from struct import unpack


def DecodeData(position):
    print "position", position
    firstChar = data[position:][:1]
    size_in_bytes = unpack('B', firstChar)[0]
    print "firstChar: {0}. size_in_bytes: {1}".format(repr(firstChar), size_in_bytes)
    return size_in_bytes


def ReadWord(position, size_in_bytes):
    word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
    print "word:", word

data = "\xff\xff\x05\x04test\x02A\x05test1@\x04\x03@@\x04\x05@0\x00\x00@\x05\x05test2\x03\x05\x05test1\x06@0\x00\x01@\x00"

position = 0

print ""
position += 1
DecodeData(position)
print "\\xff - ?"

print ""
position += 1
DecodeData(position)
print "\\x05 - ?"

print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
ReadWord(position, size_in_bytes)


print ""
position += size_in_bytes
DecodeData(position)
position += 1
DecodeData(position)
print """'2A' : could be to say that "test" has 2 empty cells before it"""

print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word

position += size_in_bytes

DecodeData(position)
print """@: mean that there's another "test1" cell"""

print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x04\\x03 - Could be that the next value is 3 cells down"

print ""
position += 1
DecodeData(position)
print ""
position += 1
print "@@ - Seems to mean 3 repetitions"

print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x04\\x05 - Could be that the next value is 5 cells down"

print ""
position += 1
DecodeData(position)
print "@ - repetition"

print ""
position += 1
DecodeData(position)

print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x00\\x00 - That could mean to move to the first cell on the next column"

print ""
position += 1
DecodeData(position)
print "@ - repetition"

print ""
position += 1
DecodeData(position)
print "\\x05 - ?"

print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word
position += size_in_bytes

print ""
DecodeData(position)
print "\\x03 - Could be to tell that the pervious word 'test2' is 3 cells down"

print ""
position += 1
DecodeData(position)
print "\\x05 - ?"

print ""
position += 1
size_in_bytes = DecodeData(position)
position += 1
word = unpack('%ds' % size_in_bytes, data[position:][:size_in_bytes])[0]
print "word:", word
position += size_in_bytes

print ""
DecodeData(position)
print "\\x06 - Could be to tell that the pervious word 'test1' is 6 cells down"

print ""
position += 1
DecodeData(position)
print "@ - repetition"

print ""
position += 1
DecodeData(position)
print "\\0 - ?"

print ""
position += 1
DecodeData(position)
position += 1
DecodeData(position)
print "\\x00\\x01 - Seems to mean, next column second cell"

print ""
position += 1
DecodeData(position)
print "@ - repetition"

print ""
position += 1
DecodeData(position)
print "\\x00 - end of data or column"
1个回答

这是对我认为各个符号的含义的解释。我基于这样的假设,即一个小选择器正在一个一个地通过单元格。

  • \xFF = 空单元格
  • \x05= 一个字符串在后面,\xNumber在字符串之后定义从选择器的当前位置移动字符串多远,如果有的话。
  • \xNumber string = 一串长度数字
  • \x2A= 可能是一个字节,表示不替换当前字符串,并假设下一段数据正在定义要放置在下一个单元格中的字符串。有疑问的意思。
  • \x04 \xNumber= 将选择器向前移动\xNumber单元格并将前一个字符串放入那里。
  • 0 \x00 \x0Number= 新列,将选择器移动到 row \xNumber,并将前一个字符串放入那里。 @= 将先前使用的字符串放在当前字符串之后的单元格中。

所以这是我对您提供给我们的数据的解释:

  • \xFF\xFF = 两个空单元格
  • \x05= 一个单元格,单数,带有字符串,放置在空单元格之后,因为\x2A在字符串之后
  • \x04 test = 字符串。
  • \x2A \x05 test1= 另一个字符串放入下面的单元格中。不需要数字,因为 \x2A 意味着它被放置在“测试”之后
  • @ = 在第一次放置“test1”字符串后将“test1”放入单元格中。
  • \x04 \x03 = 将选择器向前移动三个单元格并将 test1 放在它所在的位置。
  • @@ = 也放入下面的两个单元格中。
  • \x04 \x05 @ = 跳过四个单元格,放入两个单元格。
  • 0 = 新列。
  • \x00 \x00 @ = 使用上次定义的字符串 (test1),放入列的前两个单元格中。
  • \x05 \x05 test2 \x03 = 放置一个单元格三个单元格后记。
  • \x05\x05test1\x06 = 在 test2 之后将 test1 放入单元格 6
  • @ = 再次放置 test1。
  • 0 = 移至下一列
  • \x00\x01 = 将上一个字符串放在位置 01
  • @ = 也在位置 02
  • \x00 = 完成

解释:我的方法是寻找一个模式,检查该模式是否经得起进一步审查——我检查的第一个模式似乎——并清除我对它的任何小问题。似乎奏效了。