2021-01-14 18:56:45 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2021-01-29 06:19:34 +00:00
|
|
|
from setup import *
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
payload = open(sys.argv[1], "rb").read()
|
|
|
|
|
2021-01-29 06:19:34 +00:00
|
|
|
try:
|
|
|
|
# Try to use the m1n1 heap to avoid wasting 128MB RAM on every load
|
|
|
|
new_base = p.memalign(0x10000, len(payload))
|
|
|
|
except:
|
|
|
|
# Fall back to proxy heap, which will be at the right place in old versions
|
|
|
|
new_base = u.memalign(0x10000, len(payload))
|
2021-01-14 18:56:45 +00:00
|
|
|
|
2021-01-29 06:19:34 +00:00
|
|
|
# FIXME: this will currently still waste the whole m1n1 size including payload area (64+MB) on each
|
|
|
|
# chainload. The best way to fix this is to support in-place chainloading, which has other
|
|
|
|
# advantages.
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
print("Loading %d bytes to 0x%x" % (len(payload), new_base))
|
|
|
|
|
|
|
|
iface.writemem(new_base + 0x4000, payload[0x4000:], True)
|
|
|
|
|
2021-01-16 15:45:10 +00:00
|
|
|
entry = new_base + 0x4800
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
print("Jumping to 0x%x" % entry)
|
|
|
|
|
2021-01-29 06:19:34 +00:00
|
|
|
p.reboot(entry, u.ba_addr)
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
iface.nop()
|
|
|
|
print("Proxy is alive again")
|