# Really Powerful Gnomes
## Topics
- Scripting
## Script
```python#!/usr/bin/env python3from pwn import *
#--------setup--------#
host = "jh2i.com"port = 50031
#--------helper functions--------#
def buy(i): log.info(r.sendlineafter("> ", "6")) log.info(r.sendlineafter("What would you like to buy? (press 0 to exit the shop): ", str(i)).decode())
def read_gold(): log.info(r.readuntil("Gold: ").decode())	gold = int(r.readuntil("\n").rstrip().decode()) log.info(f"Gold: {gold}")
	return gold
def get_gold(i, need):	gold = read_gold()	while gold < need:		fight(i)		gold = read_gold()
def fight(i): log.info(r.sendlineafter("> ", str(i)).decode())
def prepare(weapon, level, need):	buy(weapon)	get_gold(level, need)
#--------interact--------#
r = remote(host, port)
prepare(1, 5, 1000)prepare(2, 4, 2000)prepare(3, 3, 10000)prepare(4, 2, 100000)
# fight gnomesbuy(5)fight(1)
# print flaglog.info(r.readall().decode())```
## Flag
```plaintextflag{it_was_in_fact_you_that_was_really_powerful}```