Tags: re 

Rating:

Reverse engineering with Ghidra give me a source code which is difficult to read and analysis.So rewrite with python and got the logic of loop.
Each function return specific value if we selected
* Eat healthy : 4
* Do 50 push-ups : 1
* Go Sleep : 3
* Go Run : 2
![](https://i.imgur.com/NjORzan.png)

```
if user_input == 3: # // if 3 execetely
go_run = 2 #return value
current_weight = current_weight - go_run # // 211 - 2 = 209
print current_weight
else:
if user_input != 4:
day += 1
go_sleep = 3 # return value
current_weight = current_weight - go_sleep;
```
Above conditions show, if user choose 3 (go_run) script will do two jobs go_run and go_sleep.
So
* Day 1. 3 go_run ( 211 - 2 - 3 = 206 )
* Day 2. 3 go_run ( 206 - 2 - 3 = 201 )
* Day 3. 3 go_run ( 201 - 2 -3 = 196 )
* Day 4. 3 go_run ( 196 - 2 -3 = 191 )
* Day 5. 3 go_run ( 191 - 2 -3 = 186 )
* Day 6. 3 go_run ( 186 - 2 - 3 = 181 )
* Day 7. 2 Do 50 push-ups ( 181 - 1 = 180 )

They give us flag as `tjctf{w3iGht_l055_i5_d1ff1CuLt}`

Original writeup (https://tjctf.org/).