From 31df36d8484127c414cae7f447b02c3b331a6174 Mon Sep 17 00:00:00 2001 From: Val Date: Fri, 2 Sep 2022 06:24:19 -0500 Subject: [PATCH] Create microcorruption debugger scripts Call arbitrary funcs with arbitrary args --- 17-Chernobyl/Code/crappy_python/caller_id.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 17-Chernobyl/Code/crappy_python/caller_id.py diff --git a/17-Chernobyl/Code/crappy_python/caller_id.py b/17-Chernobyl/Code/crappy_python/caller_id.py new file mode 100644 index 0000000..a7dad25 --- /dev/null +++ b/17-Chernobyl/Code/crappy_python/caller_id.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +""" +caller_id: Call a function with arbitrary parameters in microcorruption +""" + +import re + +preamble = "reset; break main; continue; unbreak main;" + +while 1: + address, *args = re.split(r"[(,) ]",input("> ")) + if address == "": break + print(f"{preamble} Let pc = {address}", end=";") + reg = 15 + for arg in args: + if arg: + print(f"Let r{reg} = {arg}", end=";") + reg -= 1 + print("\b ")