Skip to content

Instantly share code, notes, and snippets.

@PsychoTea
Last active February 26, 2024 01:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PsychoTea/7ac675e6dda0c1c8eb8feaaa71fb0c88 to your computer and use it in GitHub Desktop.
Save PsychoTea/7ac675e6dda0c1c8eb8feaaa71fb0c88 to your computer and use it in GitHub Desktop.
Parses an iOS .ips panic log and gives useful stack trace output
import sys
import json
import re
kslide = 0x0
if len(sys.argv) < 2:
print("Usage: PanicParser.py [file path]")
exit()
filePath = sys.argv[1]
fileData = ""
with open(filePath, "r") as file:
fileData = file.read()
panicLog = fileData[fileData.find('}') + 2:]
obj = json.loads(panicLog)
panicString = obj["panicString"]
panicString = panicString[:-3]
slideReg = re.search(r"Kernel slide:\s*(0x[0-9a-fA-F]{0,16})", panicString)
if slideReg:
kslide = int(slideReg.group(1), 16)
lrMatches = re.findall(r"lr:\s+(0x[f|F]{2}[0-9A-Fa-f]+)", panicString, re.MULTILINE)
if lrMatches:
for lrMatch in lrMatches:
hexValue = int(lrMatch, 16)
newValue = hexValue - kslide
panicString = panicString.replace(lrMatch, hex(newValue))
print(panicString)
@Leon-OS
Copy link

Leon-OS commented Sep 13, 2021

where is panic .ips file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment