点击此处获得更好的阅读体验
WriteUp来源
https://dunsp4rce.github.io/csictf-2020/pwn/2020/07/22/Global-warming.html
by AnandSaminathan
题目描述
题目考点
解题思路
The binary contains two functions - main
and login
, the main
function reads an input and passes it to login
. On decompiling login using Ghidra:
1 | void login(int32_t arg_ch) |
It is clear that printf
prints the input without any format string, so the binary has format string vulnerability. The input has to some how overwrite admin
to 0xb4dbabe3
which is a global variable at 0x804c02c
. This can be done using %n
or %hn
format string. But instead it is easier to do it using pwntools' fmstr_payload
function, which only requires the location of format string from the stack pointer and <address, value> pairs of the variables to overwritten as a dict.
In this case, the format string is 12 positions away from the stack pointer (found manually by using %x
's as inputs). This script worked:
1 | from pwn import * |
Flag
1 | csictf{n0_5tr1ng5_@tt@ch3d} |