Tags: reversing 

Rating:

# Python in One Line

We're given this script:

```python
print(' '.join([{'a':'...-', 'b':'--..', 'c':'/', 'd':'-.--', 'e':'.-.', 'f':'...', 'g':'.-..', 'h':'--', 'i':'---', 'j':'-', 'k':'-..-', 'l':'-..', 'm':'..', 'n':'.--', 'o':'-.-.', 'p':'--.-', 'q':'-.-', 'r':'.-', 's':'-...', 't':'..', 'u':'....', 'v':'--.', 'w':'.---', 'y':'..-.', 'x':'..-', 'z':'.--.', '{':'-.', '}':'.'}[i] for i in input('What do you want to secrify? ')]))
```

We're also given this encoded string:

```
.. - / .. ... -. - / -- --- .-. ... / -.-. --- -.. .
```

This is simple enough. This is a script I made to reverse it.

```python
#!/usr/bin/env python3

string = ".. - / .. ... -. - / -- --- .-. ... / -.-. --- -.. ."
encKey = {'a':'...-', 'b':'--..', 'c':'/', 'd':'-.--', 'e':'.-.', 'f':'...', 'g':'.-..', 'h':'--', 'i':'---', 'j':'-', 'k':'-..-', 'l':'-..', 'm':'..', 'n':'.--', 'o':'-.-.', 'p':'--.-', 'q':'-.-', 'r':'.-', 's':'-...', 't':'..', 'u':'....', 'v':'--.', 'w':'.---', 'y':'..-.', 'x':'..-', 'z':'.--.', '{':'-.', '}':'.'}
decKey = {v: k for k, v in encKey.items()}

print("".join(decKey[c] for c in string.split()))
```

```
tjctf{jchiefcoil}
```

Original writeup (https://github.com/shawnduong/ctf-writeups/blob/master/2019-TJ/Reversing/python-in-one-line.md).