B166ER B166ER - 4 months ago 66
PHP Question

Python unserialize PHP session

I have been trying to unserialize PHP session data in Python by using phpserialize and a serek's modules(got it from Unserialize PHP data in python), but it seems like impossible to me.

Both modules expect PHP session data to be like:

a:2:{s:3:"Usr";s:5:"AxL11";s:2:"Id";s:1:"2";}


But the data stored in the session file is:

Id|s:1:"2";Usr|s:5:"AxL11";


Any help would be very much appreciated.

Answer

After reaching page 3 on Google, I found a fork of the original application phpserialize that worked with the string that I provided:

>>> loads('Id|s:1:"2";Usr|s:5:"AxL11";')
{'Id': '2', 'Usr': 'AxL11'}
Comments