Entity
Target Information
- IP:
161.35.36.157:32290
Exploitation
-
Running
telnet 161.35.36.157 32290gets me into the server and runs the attached C code. -
Going through the program, the
(R)un~>(L)ie downoption spits out43174422884. -
The
(C)ryoption calls theget_flag()function, which returns the flag ifDataStore.integer == 13371337. -
The
set_fieldfunction sets theDataStore.integervalue to the value of asscanfcall, but it exits the program if the value is13371337.This means that we can't set the value to
13371337directly, but we can hopefully overflow it. Thesscanfcall issscanf(buf, "%llu", &DataStore.integer).(T)ry to turn it off~>(L)ie down~> "Maybe try a ritual?" allows us to enter the text. The maximum 64-bit integer is18446744073709551615, so we can subtract13371337from that and make it negative to overflow the unsigned long long to the correct value. This value is-18446744073696180279.(T)ry to turn it off~>(L)ie down~> "Maybe try a ritual?" ~>-18446744073696180279, unfortunately, is also detected by the program and exits. -
The
DataStore.stringcan be set to an 8 character string, indicating that it is likely used somehow to set the integer value since they are both the same length.The
set_fieldfunction callsmemcpy(DataStore.string, buf, sizeof(DataStore.string))to set the string, which can possibly be used to overflow the integer value. Running(T)ry to turn it off~>(L)ie down~> "Anything else to try?" ~>133713371337sets the string to13371337and the integer to3977579182370796337, which probably isn't supposed to happen.Doing the same thing with
1as the input sets the string to1and the integer to2609, which is a sign that we are going in the right direction.10sets integer to66769750sets integer to66770199sets integer to670009FFsets integer to673350\\sets integer to679004ffsets integer to681574\nsets integer to683612100sets integer to170930225001sets integer to170995760999sets integer to171522361- Up key (
^[[A) sets integer to172055323 abcsets integer to1742854091337sets integer to438757752817777777sets integer to73611777438745989518446744073696180279sets integer to3761692294704805937-18446744073696180279sets integer to3762535611533635885