我有这个数据集,它可能是用 php 函数 serialize() 序列化的
C:8:"Poreikis":768:{a:14:{s:3:"_id";a:1:{s:2:"id";s:4:"5889";}s:5:"_data";a:12:{s:2:"id";s:4:"5889";s:11:"stokojantis";s:4:"2748";s:17:"parent_kategorija";s:1:"1";s:10:"kategorija";s:1:"3";s:11:"pavadinimas";s:6:"Komoda";s:9:"aprasymas";s:89:"blah blah";s:7:"pasiula";N;s:6:"active";s:1:"Y";s:10:"created_at";s:19:"2013-02-10 12:10:48";s:10:"updated_at";s:19:"2013-02-10 12:10:48";s:7:"creator";s:4:"1842";s:6:"editor";N;}s:7:"_values";a:0:{}s:6:"_state";i:3;s:13:"_lastModified";a:0:{}s:9:"_modified";a:0:{}s:10:"_oldValues";a:0:{}s:15:"_pendingDeletes";a:0:{}s:15:"_pendingUnlinks";a:0:{}s:20:"_serializeReferences";b:0;s:17:"_invokedSaveHooks";b:0;s:4:"_oid";i:2;s:8:"_locator";N;s:10:"_resources";a:0:{}}}
我试过unserialize()
功能:
var_dump( unserialize($var) );
我有这个:
PHP Warning: Class __PHP_Incomplete_Class has no unserializer in /root/hacked.php on line 4
object(__PHP_Incomplete_Class)#1 (1) {
["__PHP_Incomplete_Class_Name"]=>
string(8) "Poreikis"
}
我也用python试过这个:
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import pprint
5 import phpserialize
6 from path import path
7
8 #filename = sys.argv[1]
9 content = u'_THAT_STRING_FROM_TOP'
10
11 unser = phpserialize.unserialize(content)
13 print unser
明白啦
~# python unserialize.py
Traceback (most recent call last):
File "hacked.py", line 11, in <module>
unser = phpserialize.unserialize(content)
File "/usr/local/lib/python2.7/dist-packages/phpserialize.py", line 522, in loads
object_hook, array_hook)
File "/usr/local/lib/python2.7/dist-packages/phpserialize.py", line 512, in load
return _unserialize()
File "/usr/local/lib/python2.7/dist-packages/phpserialize.py", line 510, in _unserialize
raise ValueError('unexpected opcode')
似乎该变量可能无效?好的,现在关于这些数据。
PHP中有一个ORM引擎叫做“Doctrine”,而在doctrine中有一个模型类叫做“BaseRecycleBin.php”,它实际上是定义了一个叫做“_deleted_items”的表,它存储了这种值。我什至在教义中找到了序列化类。这似乎根本没有做任何不规则的事情。
所以主要问题是:如何反序列化这个字符串?
另外,如果可以回答,Doctrine 是否可以从该表中恢复该数据?因为这是我最初的意图,从大量序列化字符串构造查询,这些字符串最初来自那个“_deleted_items”表。