Irreductible
Category: Misc
Description
A Python deserialization challenge ? Easy ! I'll just copy-paste a generic payload and ... oh, oh no.
> Deploy on deploy.heroctf.fr
Format : Hero{flag}
Author : Alol
Attachments: chall.zip
Write-up
- This challenge involves Python deserialization using the
picklemodule. - Upon examining the source code, we can see that it is not a simple pickle2rce problem. The program only loads our serialized input if it iterates through the opcodes and does not encounter a REDUCE (
R) opcode. Since remote code execution (RCE) usingpickleheavily relies on__reduce__, this approach won't work. We need to find an alternative solution. - While inspecting the
picklemodule's source code, we discovered an intriguing function called_instantiate. This function attempts to instantiate a class from theklassparameter using the arguments fromargs. - The object is created at this line:
value = klass(*args). - Instead of passing a class to
klass, we can specify our own function along with the necessary arguments inargs, leading to an RCE. - Both
load_instandload_objfunctions call_instantiate, as seen here and here respectively. - Let's examine the
load_objfunction: - According to the comment, we can prepare our payload using opcodes in the specified sequence.
- To simplify the process of writing Pickle assembly, we can utilize the
pickleassemPython package. - The written payload (with comments) can be found here.

Flag: Hero{Ins3cur3_d3s3ri4liz4tion_tickl3s_my_pickl3}