diff --git a/paradigmctf.py/ctf_launchers/starknet_pwn_launcher.py b/paradigmctf.py/ctf_launchers/starknet_pwn_launcher.py index 26e7e9b..2da4957 100644 --- a/paradigmctf.py/ctf_launchers/starknet_pwn_launcher.py +++ b/paradigmctf.py/ctf_launchers/starknet_pwn_launcher.py @@ -1,9 +1,9 @@ import os - +import json import requests from ctf_launchers.launcher import Action, Launcher, ORCHESTRATOR_HOST, CHALLENGE from ctf_launchers.team_provider import TeamProvider, get_team_provider -from ctf_server.types import UserData +from ctf_server.types import UserData, get_privileged_web3 FLAG = os.getenv("FLAG", "PCTF{flag}") @@ -24,7 +24,8 @@ def __init__( ) def get_flag(self) -> int: - instance_body = requests.get(f"{ORCHESTRATOR_HOST}/instances/{self.get_instance_id()}").json() + instance_body = requests.get( + f"{ORCHESTRATOR_HOST}/instances/{self.get_instance_id()}").json() if not instance_body['ok']: print(instance_body['message']) return 1 @@ -41,16 +42,22 @@ def get_flag(self) -> int: return 0 def is_solved(self, user_data: UserData, addr: str) -> bool: - # web3 = get_privileged_web3(user_data, "main") - - # (result,) = abi.decode( - # ["bool"], - # web3.eth.call( - # { - # "to": addr, - # "data": web3.keccak(text="isSolved()")[:4], - # } - # ), - # ) - # return result - return False + web3 = get_privileged_web3(user_data, "main") + + x = requests.post(web3.provider.endpoint_uri + "/rpc", json={ + "id": 1, + "jsonrpc": "2.0", + "method": "starknet_call", + "params": [ + { + "contract_address": addr, + "calldata": [], + "entry_point_selector": "0x1f8ddd388f265b0bcab25a3e457e789fe182bdf8ede59d9ef42b3158a533c8" + }, + "latest" + ] + }) + + solved = True if json.loads(x.text)['result'][0] == "0x0" else False + + return solved diff --git a/paradigmctf.py/ctf_launchers/utils.py b/paradigmctf.py/ctf_launchers/utils.py index bf30e41..c01d7c8 100644 --- a/paradigmctf.py/ctf_launchers/utils.py +++ b/paradigmctf.py/ctf_launchers/utils.py @@ -104,9 +104,9 @@ def deploy_cairo( print(stderr) raise Exception("script failed to run") - output = stdout.split('address: ') + output = stdout.split('address: ')[1].replace("\\n", "") - return output[1] + return output[:65] def anvil_setCodeFromFile( diff --git a/paradigmctf.py/ctf_server/anvil_proxy.py b/paradigmctf.py/ctf_server/anvil_proxy.py index b33a2b2..9773e4c 100644 --- a/paradigmctf.py/ctf_server/anvil_proxy.py +++ b/paradigmctf.py/ctf_server/anvil_proxy.py @@ -12,7 +12,7 @@ from .utils import load_database -ALLOWED_NAMESPACES = ["web3", "eth", "net"] +ALLOWED_NAMESPACES = ["web3", "eth", "net", "starknet"] DISALLOWED_METHODS = [ "eth_sign", "eth_signTransaction",