Created
December 19, 2022 18:46
-
-
Save H0neyBadger/00e6eb2e7f28608ac753b4e9de9e97b7 to your computer and use it in GitHub Desktop.
convert mira-project payload to js https://github.com/sleirsgoevy/900-host/tree/master/mira
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
import sys | |
template_elf = """window.{name}_len = {length}; | |
window.{name} = malloc(window.{name}_len); | |
write_mem(window.{name}, [{payload}]); | |
""" | |
template_bin = """window.{name} = malloc(65536); | |
write_mem(window.{name}, [{payload}]); | |
""" | |
def bin2js(name, infile, outfile): | |
with open(infile, "rb") as mira: | |
data = mira.read() | |
data = [str(int(tmp)) for tmp in data] | |
with open(outfile, "w", encoding="utf8") as mira: | |
payload = ", ".join(data) | |
template = template_bin | |
if infile.endswith(".elf"): | |
template = template_elf | |
data = template.format( | |
name=name, | |
length=len(data), | |
payload=payload, | |
) | |
mira.write(data) | |
def main(mira_project_path): | |
loader = "loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_900.bin" | |
kernel = "kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_900.elf" | |
bin2js("mira_blob", mira_project_path + "/" + loader, "mira.js") | |
bin2js("window.mira_blob_2", mira_project_path + "/" + kernel, "mira2.js") | |
if __name__ == "__main__": | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment