在Java中没有原始对象信息的情况下从字符串反序列化对象

时间:2019-03-08 22:28:29

标签: java serialization deserialization

说我有一个对象序列化的字符串,在终端中显示时看起来像这样:

bd40efbfbdefbfbd00000000000a7371007e00000aefbfbdefbfbdefbfbd
2b020c49efbfbdefbfbdefbfbdefbfbd2b020c49efbfbd3fefbfbdefbfbd
efbfbd126eefbfbdefbfbd40efbfbdefbfbd000000000a7371007e00000a
efbfbdefbfbdefbfbdefbfbdefbfbd126eefbfbdefbfbdefbfbd53efbfbd
efbfbdefbfbd16efbfbd3fefbfbdefbfbdefbfbdefbfbd45efbfbd40efbf
bdefbfbd00000000000a7371007e00000aefbfbdefbfbdefbfbd3b645a1c
efbfbdefbfbdd0b4395810624e3fefbfbd020c49efbfbd5e3540efbfbdef
bfbd000000000a7371007e00000aefbfbdefbfbdefbfbdefbfbd126eefbf
bdefbfbdefbfbdefbfbd1aefbfbdefbfbd76c8b43fefbfbdefbfbd53efbf
bdefbfbdefbfbd1740efbfbdefbfbd00000000000a7371007e0000efbfbd
c49befbfbdefbfbd53efbfbdcfbf50624defbfbdefbfbdefbfbd3fefbfbd
efbfbd45efbfbdefbfbdefbfbd40efbfbdefbfbd000000000a7371007e00
00efbfbdc9ba5e353f7cefbfbdefbfbd1cefbfbd083126efbfbd3fefbfbd
2d0e560418efbfbd40efbfbdefbfbd00000000000a7371007e0000efbfbd
efbfbdefbfbd45efbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbf
bd126eefbfbd3fefbfbdefbfbd45efbfbdefbfbdefbfbd40efbfbdefbfbd
000000000a7371007e0000efbfbdefbfbd26efbfbd78efbfbdefbfbdefbf
bdefbfbd6eefbfbdefbfbd4fefbfbd3b3fefbfbd10624defbfbdefbfbd40
efbfbdefbfbd00000000000a7371007e00000aefbfbdefbfbd4fefbfbd3b
645aefbfbdefbfbd126eefbfbdefbfbd503fefbfbdefbfbdefbfbd22efbf
bdefbfbd6040efbfbdefbfbd000000000a7371007e0000efbfbdefbfbd49
efbfbd5e353f7defbfbdefbfbd10624defbfbdefbfbd3fefbfbd083126ef
bfbd78efbfbd40efbfbdefbfbd00000000000a7371007e00000aefbfbdef
bfbd26efbfbd78efbfbdefbfbdefbfbdefbfbdefbfbdefbfbd126eefbfbd
efbfbd3fefbfbdefbfbd16efbfbd2b020c40efbfbdef

这是我在键入时看到的十六进制: xxd -p fileName在终端中。我也可以将其视为Binary,但不确定如何解码序列化的对象。

我知道它是一组Java序列化的对象,但是我不知道序列化的开始/结束位置。我试图遍历开始和结束索引,但我不断得到: java.io.StreamCorruptedException:无效的流标头:30303061

我不知道还能尝试什么,任何帮助将不胜感激。

谢谢!

1 个答案:

答案 0 :(得分:0)

我弄清楚了如何反序列化对象。经过一些研究,我逐步进行了十六进制转储以提取相关信息。棘手的部分是一些数据通过HTTP在不同的数据包中发送,因此反序列化被缝合在一起。无论如何,这就是我能够想到的。如果有人在下面的代码片段的未知部分有任何输入,请不要犹豫发表评论,我将尝试相应地编辑我的答案。

0005 – STREAM_VERSION 
0a - UNKNOWN
73 – TC_OBJECT
72 – TC_CLASSDESC
0015 – length of the class name
616461732e746f6f6c6b69742e646174612e504144 - class name
efbfbd221844efbf – SerialVersionUID
bdefbfbdefbfbdefbfbd - UNKNOWN
02 - OBJECT SERIALIZABLE
0004 - NUMBER OF PROPERTIES (4)
44 - PROPERTY CODE (D : Double)

0001 - PROPERTY NAME LENGTH
61 - PROPERTY NAME (a)?

44 - PROPERTY CODE (D : Double)
0001 - PROPERTY NAME LENGTH 
64 - PROPERTY NAME (d)

44 - PROPERTY CODE (D : Double)
0001 - PROPERTY NAME LENGTH 
70 - PROPERTY NAME (p)

44 - PROPERTY CODE (D : Double)
0008 - PROPERTY NAME LENGTH 
73657175656e6365 - PROPERTY NAME (sequence)
0a -UNKNOWN
78 - END BLOCK

70efbfbdefbfbdef - VALUE OF a: 1.00947731285363886197528984273E236 
bfbd2b020c49efbf - VALUE OF d: -1.13937500000189637083813920526E-1 
bdefbfbdefbfbd45 - VALUE OF p: -2.3100431973060554004134169949E-10 
efbfbdefbfbdefbf - VALUE OF sequence: -1.9249974767166909849440370334E230 

我希望这可以帮助和我一样处境的人。

谢谢!

有用的链接:

Javaworld

Javapapers