Last active
February 26, 2024 01:43
-
-
Save PsychoTea/7ac675e6dda0c1c8eb8feaaa71fb0c88 to your computer and use it in GitHub Desktop.
Parses an iOS .ips panic log and gives useful stack trace output
This file contains 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 | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where is panic .ips file