# In a pickle
## Problem descriptionWe managed to intercept communication between und3rm4t3r and his hacker friends.However it is obfuscated using something. We just can't figure out what it is.Maybe you can help us find the flag?
[data](https://play.duc.tf/files/5f85a352ae3eaf93f5adf9cb06074ea0/data?token=eyJ1c2VyX2lkIjoyNDc4LCJ0ZWFtX2lkIjoxMDI2LCJmaWxlX2lkIjozM30.X2dFng.hYWA6IafRlMg4Q5kKhue7CHKnik)
Category: misc. Points: 200. Tag: easy.
### data``(dp0I1S'D'p1sI2S'UCTF'p2sI3S'{'p3sI4I112sI5I49sI6I99sI7I107sI8I108sI9I51sI10I95sI11I121sI12I48sI13I117sI14I82sI15I95sI16I109sI17I51sI18I53sI19I53sI20I52sI21I103sI22I51sI23S'}'p4sI24S"I know that the intelligence agency's are onto me so now i'm using ways to evade them: I am just glad that you know how to use pickle. Anyway the flag is "p5s.``
## Concepts* [Pickle](https://docs.python.org/3/library/pickle.html)* [ASCII table](https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html)
## Solving the challengeThe `data` file contains a pickled (serialized) Python object. Pickling converts aPython object hierarchy into a byte stream, while unpickling is the reverse process.To solve the challenge we need to unpickle (deserialize) the object, using the`pickle.load(file, *, fix_imports=True, encoding='ASCII', errors='strict')`method.
Unpickle `data` file into a variable `content`:
```import pickle
with open('./data', 'rb') as pickle_file:    content = pickle.load(pickle_file)```
Examining the `content` variable:```>>> print(content){1: 'D', 2: 'UCTF', 3: '{', 4: 112, 5: 49, 6: 99, 7: 107, 8: 108, 9: 51, 10: 95, 11: 121, 12: 48, 13: 117, 14: 82, 15: 95, 16: 109, 17: 51, 18: 53, 19: 53, 20: 52, 21: 103, 22: 51, 23: '}', 24: "I know that the intelligence agency's are onto me so now i'm using ways to evade them: I am just glad that you know how to use pickle. Anyway the flag is "}
>>> type(content)<class 'dict'>```
The `content` variable is a `dict`. Looking at the values, we can identify that all values belonging to key 4-22 are stored as ASCII decimal. Thus, we need to convert theASCII decimals to character. In this case (since there are no other integervalues in the dict), we can convert all int values to their corresponding characterusing the `chr(i)` function.
Storing the flag in a `flag` variable:```flag = ""for key in sorted(content)[:-1]: # Sorting dict to ensure correct ordering. Omitting the (string) value from the last key (24)    val = content[key]    if isinstance(val, int):        val = chr(val)  # Transforming ASCII decimal to character    flag += val```
Now we can output the flag:```>>> print(flag)DUCTF{p1ckl3_y0uR_m3554g3}```