Entity
Target Information
- IP:
161.35.36.157:32290
Exploitation
-
Running
telnet 161.35.36.157 32290
gets me into the server and runs the attached C code. -
Going through the program, the
(R)un
~>(L)ie down
option spits out43174422884
. -
The
(C)ry
option calls theget_flag()
function, which returns the flag ifDataStore.integer == 13371337
. -
The
set_field
function sets theDataStore.integer
value to the value of asscanf
call, but it exits the program if the value is13371337
.This means that we can't set the value to
13371337
directly, but we can hopefully overflow it. Thesscanf
call 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 subtract13371337
from 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.string
can 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_field
function 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?" ~>133713371337
sets the string to13371337
and the integer to3977579182370796337
, which probably isn't supposed to happen.Doing the same thing with
1
as the input sets the string to1
and the integer to2609
, which is a sign that we are going in the right direction.10
sets integer to667697
50
sets integer to667701
99
sets integer to670009
FF
sets integer to673350
\\
sets integer to679004
ff
sets integer to681574
\n
sets integer to683612
100
sets integer to170930225
001
sets integer to170995760
999
sets integer to171522361
- Up key (
^[[A
) sets integer to172055323
abc
sets integer to174285409
1337
sets integer to43875775281
7777777
sets integer to736117774387459895
18446744073696180279
sets integer to3761692294704805937
-18446744073696180279
sets integer to3762535611533635885