Skip to content

Instantly share code, notes, and snippets.

@PsychoTea
Last active February 26, 2024 01:43
Show Gist options
  • Select an option

  • Save PsychoTea/7ac675e6dda0c1c8eb8feaaa71fb0c88 to your computer and use it in GitHub Desktop.

Select an option

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

Leon-OS commented Sep 13, 2021

Copy link
Copy Markdown

where is panic .ips file

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