Anheng 429 | why does web3session deserialization take it out separately? it is because there have been many deserialization holes and problems, including three white hats from p, some questions of a ctf involve this aspect.
However, some new things have been found in this question, so it is worth thinking about.
Reference http://drops.wooyun.org/tips/3909
And p total tips:
Session serialization refers to the serialization of strings stored in the session file, and the $ _ SESSION we can access is a variable that has been parsed.
First, we need to know that php will have a serialization and deserialization process when storing and reading data in sessions.
The magic method of the object will be called in deserialization, such as _ destruct () ,__ wakeup (), which is common and will not be repeated.
Here is a configuration option session. serialize_handler.
You can use ini_set or set it in php. ini.
The following types of processors are used to process serialization:
Storage format corresponding to the processor
Php key name + vertical bar + value processed by serialize () function
The length of the php_binary key name corresponds to the ASCII character + key name + value processed by the serialize () function
Php_serialize
(Php> = 5.5.4) array processed by serialize () function deserialization
For the php processor, if we first use php_serialize for serialization, then for such a string
a:1:{s:4:"test";s:20:"|O:8:"stdClass":0:{}";}
It is finally interpreted as an object with the key name a: 1: {s: 4: "test"; s: 20 :"
While the php processor is serialized, every key value of $ _ SESSION isSeparateTake it out, for example, $ _ SESSION ['test']
Is test | serialized value
Php_serialize directly serializes the entire session array. The final storage is a serialized value of the entire array.
So it is easy to understand. if the processor session. serialize_handler = php_serialize
We construct a string with a vertical line. when other processors are php, we can deserialize the forged object.
Here we obviously need to operate the session. what we use to test in this article is
$_SESSION['ryat'] = $_GET['ryat'];
However, what should I do if this condition is not met in many cases?
Http://php.net/manual/zh/session.upload-progress.php
Php to provide a data Upload progress
$ N = ini_get ("session. upload_progress.name ");
It is stored in $ _ SESSION ["$ n.
In this way, we construct a file upload page to successfully write data to the session.