Rating:

We are given this image: [Oni.png](https://github.com/JEF1056/riceteacatpanda/raw/master/Oni%20(2699)/Oni.png)
The pre-requisite task to unlocking this, is the "Clean Pandas" challenge, and this is hinted to in the challenge description.

Going back to "Clean Pandas", the different blocks decrypted to the following lines:

```
Todolist b'slayDemon'
Side note b'notUseful'
unknown step b'binary image'
unknown step 0 b'binary to string'
unknown step 1246523 b'shift by lucky number'
unknown step 39865432 b'binary to string'
unknown step 26745643547 b'base 32'
unknown step 69821830 b'byteencode to integerthough bytes from hex'
unknown flag 394052487124 b'rtcp{CAr3fu1_wH^t_y0u_c134n_696}'
unknown step 446537364 b'split in intervals of 5'
unknown step 53920324379187589 b'base 85'
unknown step 890348 b'divide by the demon-summoning number"
unknown step 923426390324272983 b'bytedecode integer'
```

To decode Oni, we simply follow these steps:

1. First we start at the image. Observe that there are white and black pixels, and going from left to right, it is the same repeating pattern over and over. We treat this as binary 1s and 0s, reading 8 pixels per line, from top to bottom.
2. Next up, we convert all 8-bit chunks into bytes.
3. Add `8` to each byte to make the entire piece fall into base32 alphabet range.
4. base32 decode
5. (Not mentioned in the instructions, but all patterns like `'\xe2\x96\xa2'` represent zeros, so preserve these)
6. Read the result in chunks of 5 bytes, decoding each with base85. This reveals hexadecimal numbers as ASCII.
7. Convert the ASCII to integers by treating it as ASCII, and divide by 666.
8. Put all the numbers together into a large number, and convert to bytes.

Here's some example code to do the above steps:

```python3
import base64
from Crypto.Util.number import long_to_bytes
from PIL import Image

img = Image.open("Oni.png")
im = img.load()
X, Y = img.size

out = ""
for y in range(Y):
tmp = ""
for x in range(8):
tmp += "1" if im[x,y] == (0,0,0,255) else "0"
out += chr(int(tmp,2))

x = base64.b32decode(''.join([chr(ord(e)+8) for e in out])).replace(b'\xe2\x96\xa2', b'Z')
y = [int(base64.b85decode(x[i:i+5]),16)//666 if b"F" in x[i:i+5] else 0 for i in range(0,len(x),5)]
z = int(''.join(map(str, y)))
print(long_to_bytes(z)[::-1])
```