written by hartmannsyg
Last Monday, I accidentally turned off all 10 air-conditioners at my internship workplace without even realizing it. But what led to this moment? Solve this challenge to find out :)
Goal is to set all air-conditioners to 25 degrees Celsius.
16/20 solves
This was the most solved pwn challenge by far, and yet we weren’t able to solve it.
The challenge
1. Change air-con temp 2. View air-con temps 3. Get flag > 2 [ID 0] Remote Temp: 20, Actual Temp: 20 [ID 1] Remote Temp: 21, Actual Temp: 21 [ID 2] Remote Temp: 22, Actual Temp: 22 [ID 3] Remote Temp: 23, Actual Temp: 23 [ID 4] Remote Temp: 24, Actual Temp: 24 [ID 5] Remote Temp: 25, Actual Temp: 25 [ID 6] Remote Temp: 26, Actual Temp: 26 [ID 7] Remote Temp: 27, Actual Temp: 27 [ID 8] Remote Temp: 28, Actual Temp: 28 [ID 9] Remote Temp: 29, Actual Temp: 29 |
We have 10 air-con remotes with their own temperature, and 10 actual air-con temperatures.
Our goal is to get all the actual temperatures to 25. However when we try to set one of them to 25:
1. Change air-con temp 2. View air-con temps 3. Get flag > 1 Which air-con remote to use: 0 What temperature to set to: 25 Changing temperature on remote ... Updating temperature of air-con ... Checking that all air-con temperatures are different ... Error: Different air-cons have the same temperature displayed! I'm kicking u out! |
1 | void change_aircon_temp(void) |
1 | undefined8 aircon_has_same_temps(void) |
We see that it:
- reads for our remote number
remote_no
- copies it to another variable
remote_no_
- read the temperature
- validate inputs
AIRCON_REMOTE_TEMP[remote_no] = temp
AIRCON_ACTUAL_TEMP[remote_no_] = AIRCON_REMOTE_TEMP[remote_no]
We can’t really overflow offsets either the remote ID or the temperature as validdate_inputs()
exists:
1 | undefined8 validate_inputs(short param_1,short param_2) |
So we were kinda stuck here. The only valid inputs are those that do nothing, e.g. for air-con remote ID 5, set temperature to 25. However when I tried that:
1. Change air-con temp 2. View air-con temps 3. Get flag > 1 Which air-con remote to use: 5 What temperature to set to: 25 Changing temperature on remote ... Updating temperature of air-con ... Checking that all air-con temperatures are different ... Successfully updated air-con temperature! 1. Change air-con temp 2. View air-con temps 3. Get flag > 2 |
????????
The 0th aircon gets changed?? I wasn’t sure what was going on and we kinda got stuck.
Actual Solution
%d
actually reads out 32 bits of data, which is greater than remote_no
and temp
‘s 16 bits (they are short
).
So when it reads from stdin the temperature of the remote, we can set remote_no_
along with it.
Script
1 | from pwn import * |
Flag: grey{one_rem0te_controls_a11_the_air_conditioners!} |