Description
This guy in the USACO server gave me this implementation of a segment tree, and I made this program to test it out. I don't know if he's ever written a program without bits/stdc++.h but it can't be that bad.
Docker base image: ubuntu@sha256:c9cf959fd83770dfdefd8fb42cfef0761432af36a764c077aed54bbc5bb25368
Attachments
https://imaginaryctf.org/f/rvrKW#segtree
nc 34.90.233.82 1337
Writeup
We have an arbitrary OOB read/write in set/range_min. Use this to leak the vtable address, which gives us a PIE leak, and the address of the vector member in MinSegmentTree, which gives is a heap leak. Then we can read from the GOT which gives us a libc leak. Finally, forge a vtable and use a one-gadget to get RCE.
https://imaginaryctf.org/f/fc3dX#solve.py
Flag
ictf{h0p_0ff_c0d3f0rc35_0583a9b8}