Tags: reverse patching esoteric-language 

Rating:

# Chicken

**Chicken** is an [esoteric programming language](https://esolangs.org/wiki/Esoteric_programming_language "Esoteric programming language") by Torbjörn Söderstedt, in which "chicken" is the only valid symbol.

A chicken program consists of the tokens "chicken", " " and "\n". Every line has a number of chickens separated by spaces. The number of chickens corresponds to an opcode. Trailing newlines are significant, as an empty line will produce a "0" opcode.

Instructions are loaded onto the stack and executed there directly, which allows for injecting arbitrary code and executing it through a jump. Self-modifying code is also possible because the program stack is not bounded.

The user is able to supply an input value before executing the program. This input is stored in one of the two registers.

It looks like this.....

![](https://i.imgur.com/JLBvW04.png)

So, lets find some tool to execute it - https://github.com/kosayoda/chickenpy.

Some error.... I think that developer assumed that we should patch chicken code. But we are hackers and we found easier way.

![](https://i.imgur.com/PAFK14V.png)

Just patch else block in `vm.py` to this:
```
try:
token = op - 10
except TypeError:
op = ord(op)
token = op - 10

print(op)
print(self.stack)
```

After execution you'll see stack with flag

![](https://i.imgur.com/a4gNCLX.png)

![](https://i.imgur.com/JVbJkV3.png)

Original writeup (https://ctftime.org/team/144064).