# Pixelated - bad OCR? Generate an adversarial image instead!

I heard a lot of people are complaining about how bad the OCR is in the Pixelated problem. I feel the same, and was having a hard time making an image that the server will read correctly.
Out of desperation, I took Huggingface TrOCR model, and generate an adversarial image using it. Suprisingly the server will decode my adversarial image with high accuracy, even when the encoded text is very long!
To get the flag, I encoded the following string into my adversarial image:
801-867-5309truea
That string is encoded into the following generated image:
![](assets/adfcd596c2320ad325b9b249.png)
Then voila, the server returned the flag!
Another interesting point is I had difficulty sending a blank or empty string in a normal image, even when the image is blank. But using this adversarial image, we can generate an image that will be decoded as empty string. The image lead me to know that the content of
<text>
element should not be empty due to "Invalid XML" message.
My code is a mess and currently lack of comment or description, but you can read it here
[https://www.kaggle.com/code/thariqnugrohotomo/ctf-defcon31-pixelated-ocr-image-generator/](https://www.kaggle.com/code/thariqnugrohotomo/ctf-defcon31-pixelated-ocr-image-generator/)