Last active
June 11, 2023 19:54
-
-
Save PsychoTea/d9ca14d2687890f15900d901f600bf6a to your computer and use it in GitHub Desktop.
Revisions
-
PsychoTea revised this gist
Apr 10, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ #!/bin/bash if [ -d ~/Desktop/logs_panic ]; then rm -r ~/Desktop/logs_panic fi -
PsychoTea revised this gist
Apr 10, 2020 . 3 changed files with 81 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ 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) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash out="/tmp/dumplogs" if [ -d $out ]; then rm -r $out fi mkdir -p $out if [ "$#" -eq "1" ]; then out="$HOME/Desktop/$1" if [ -d $out ]; then echo "Output directory already exists." exit 0 fi mkdir -p $out fi echo "Dumping logs to $out..." while [ $(ls -l $out | wc -l | sed 's/^ *//') == "0" ]; do echo "Attempting to dump logs..." idevicecrashreport -e $out sleep 0.5 done echo "Finished dumping logs to $out" 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ if [ -d ~/Desktop/logs_panic ]; then rm -r ~/Desktop/logs_panic fi dumplogs logs_panic filename=$(ls -1 ~/Desktop/logs_panic/panic-* | sort -r | head -1) if [ ! -e $filename ]; then echo File $filename not found. exit 0 fi python3 ~/Documents/Python/PanicParser.py $filename rm -r ~/Desktop/logs_panic -
PsychoTea revised this gist
Jan 8, 2020 . 1 changed file with 44 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,8 @@ # Requires ideviceinfo (libimobiledevice), pzb, jtool2, jq build_kernel_string () { # $1 = product type ie. iPhone12,1 # $2 = product version ie. 13.2.2 short_product_type=$(echo "$1" | sed 's/iPhone//g; s/iPad//g; s/,//g') @@ -13,6 +13,44 @@ build_kernel_string () { echo "$short_product_type-$short_product_version" } find_kernel_file() { # $1 = URL string # $2 = HardwareModel pzb -g BuildManifest.plist "$1" 1>/dev/null found_kernel_file="" ctr=0 while true; do plist_parse=$(plutil -extract BuildIdentities.$ctr.Info.DeviceClass xml1 -o - BuildManifest.plist) if [[ ! "$?" -eq "0" ]]; then break fi curr_id=$(echo $plist_parse | sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p" | tr [a-z] [A-Z]) kernel_file=$(plutil -extract BuildIdentities.$ctr.Manifest.KernelCache.Info.Path xml1 -o - BuildManifest.plist | sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p") if [[ "$2" == "$curr_id" ]]; then found_kernel_file=$kernel_file break fi ((ctr++)) done rm BuildManifest.plist if [[ "$found_kernel_file" == "" ]]; then echo "Failed to find kernel file from BuildManifest for model: $2" exit 1 fi echo "$found_kernel_file" } if [[ "$#" == "0" ]]; then echo "Usage: pullkernel [uuid] {version}" exit 0 @@ -32,6 +70,7 @@ product_type=$(echo "$device_info" | grep ProductType | sed 's/ProductType: //g' device_name=$(echo "$device_info" | grep DeviceName | sed 's/DeviceName: //g') product_version=$(echo "$device_info" | grep ProductVersion | sed 's/ProductVersion: //g') build_version=$(echo "$device_info" | grep BuildVersion | sed 's/BuildVersion: //g') hardware_model=$(echo "$device_info" | grep HardwareModel | sed 's/HardwareModel: //g') if [[ "$#" == "2" ]]; then requested_version="$2" @@ -70,7 +109,9 @@ url_string="https://api.ipsw.me/v4/ipsw/download/$product_type/$build_version" echo "URL: $url_string" echo "Fetching files..." pzb_kernel_string=$(find_kernel_file $url_string $hardware_model) # pzb_kernel_string=$(pzb -l "$url_string" | grep kernelcache | tail -1 | cut -d' ' -f5) if [[ $(echo $pzb_kernel_string | wc -c) -lt 3 ]]; then echo "Failed to find kernel string." -
PsychoTea revised this gist
Jan 8, 2020 . 1 changed file with 21 additions and 48 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ #!/bin/bash # Requires ideviceinfo (libimobiledevice), pzb, jtool2, jq build_kernel_string () { # $0 = product type ie. iPhone12,1 # $1 = product version ie. 13.2.2 short_product_type=$(echo "$1" | sed 's/iPhone//g; s/iPad//g; s/,//g') @@ -13,51 +13,13 @@ build_kernel_string () { echo "$short_product_type-$short_product_version" } if [[ "$#" == "0" ]]; then echo "Usage: pullkernel [uuid] {version}" exit 0 fi target_uuid=$1 echo "Pulling kernel for $target_uuid..." device_info=$(ideviceinfo -u $target_uuid) @@ -66,11 +28,24 @@ if [[ "$device_info" == ERROR* ]]; then exit 0 fi product_type=$(echo "$device_info" | grep ProductType | sed 's/ProductType: //g') device_name=$(echo "$device_info" | grep DeviceName | sed 's/DeviceName: //g') product_version=$(echo "$device_info" | grep ProductVersion | sed 's/ProductVersion: //g') build_version=$(echo "$device_info" | grep BuildVersion | sed 's/BuildVersion: //g') if [[ "$#" == "2" ]]; then requested_version="$2" echo "Finding Build ID for requested version $requested_version..." all_ipsw_info=$(curl https://api.ipsw.me/v4/device/$product_type?type=ipsw 2>/dev/null) build_id=$(echo "$all_ipsw_info" | jq -r '.firmwares[] | select (.version == "'$requested_version'") | .buildid') echo "Found Build ID: $build_id" product_version="$requested_version" build_version="$build_id" fi kernel_string=$(build_kernel_string $product_type $product_version) echo "Device name: $device_name" @@ -95,9 +70,7 @@ url_string="https://api.ipsw.me/v4/ipsw/download/$product_type/$build_version" echo "URL: $url_string" echo "Fetching files..." pzb_kernel_string=$(pzb -l "$url_string" | grep kernelcache | tail -1 | cut -d' ' -f5) if [[ $(echo $pzb_kernel_string | wc -c) -lt 3 ]]; then echo "Failed to find kernel string." -
PsychoTea revised this gist
Dec 25, 2019 . 1 changed file with 58 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,44 @@ build_kernel_string () { echo "$short_product_type-$short_product_version" } find_kernel_file() { # $1 = URL string # $2 = HardwareModel pzb -g BuildManifest.plist "$1" 1>/dev/null found_kernel_file="" ctr=0 while true; do plist_parse=$(plutil -extract BuildIdentities.$ctr.Info.DeviceClass xml1 -o - BuildManifest.plist) if [[ ! "$?" -eq "0" ]]; then break fi curr_id=$(echo $plist_parse | sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p" | tr [a-z] [A-Z]) kernel_file=$(plutil -extract BuildIdentities.$ctr.Manifest.KernelCache.Info.Path xml1 -o - BuildManifest.plist | sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p") if [[ "$2" == "$curr_id" ]]; then found_kernel_file=$kernel_file break fi ((ctr++)) done rm BuildManifest.plist if [[ "$found_kernel_file" == "" ]]; then echo "Failed to find kernel file from BuildManifest for model: $2" exit 1 fi echo "$found_kernel_file" } if [[ "$#" == "0" ]]; then echo "Usage: pullkernel [uuid]" exit 0 @@ -32,6 +70,7 @@ device_name=$(echo "$device_info" | grep DeviceName | sed 's/DeviceName: //g') product_type=$(echo "$device_info" | grep ProductType | sed 's/ProductType: //g') product_version=$(echo "$device_info" | grep ProductVersion | sed 's/ProductVersion: //g') build_version=$(echo "$device_info" | grep BuildVersion | sed 's/BuildVersion: //g') hardware_model=$(echo "$device_info" | grep HardwareModel | sed 's/HardwareModel: //g') kernel_string=$(build_kernel_string $product_type $product_version) echo "Device name: $device_name" @@ -56,22 +95,37 @@ url_string="https://api.ipsw.me/v4/ipsw/download/$product_type/$build_version" echo "URL: $url_string" echo "Fetching files..." pzb_kernel_string=$(find_kernel_file $url_string $hardware_model) # pzb_kernel_string=$(pzb -l "$url_string" | grep kernelcache | tail -1 | cut -d' ' -f5) if [[ $(echo $pzb_kernel_string | wc -c) -lt 3 ]]; then echo "Failed to find kernel string." exit 0 fi echo "Pulling kernel file $pzb_kernel_string..." pzb -g $pzb_kernel_string $url_string if [[ ! -e $pzb_kernel_string ]]; then echo "Failed to download kernel file." exit 0 fi echo "Decompressing with jtool2..." jtool2 -dec $pzb_kernel_string if [[ ! -e kernel ]]; then echo "Failed to decompress kernel file." exit 0 fi mv kernel $final_kernel_path echo listdevices echo echo "Complete!" -
PsychoTea revised this gist
Nov 22, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,7 @@ echo "Kernel string: $kernel_string" final_kernel_path="/Users/ben/Desktop/kernels/$kernel_string" if [[ -e $final_kernel_path ]]; then echo "Kernel already found, exiting..." exit 0 fi -
PsychoTea revised this gist
Nov 22, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,8 @@ # Requires ideviceinfo (libimobiledevice), pzb, jtool2 build_kernel_string () { # $1 = product type ie. iPhone12,1 # $2 = product version ie. 13.2.2 short_product_type=$(echo "$1" | sed 's/iPhone//g; s/iPad//g; s/,//g') -
PsychoTea revised this gist
Nov 22, 2019 . 1 changed file with 28 additions and 30 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,42 +1,40 @@ #!/bin/bash for id in $(idevice_id -l); do ideviceinfo_data=$(ideviceinfo -u $id) product_type=$(echo "$ideviceinfo_data" | grep ProductType | sed 's/ProductType: //g') # strip 'iPhone' or 'iPad' and the comma from the product type short_product_type=$(echo "$product_type" | sed 's/iPhone//g; s/iPad//g; s/,//g' ) short_product_version=$(echo "$ideviceinfo_data" | grep ProductVersion | sed 's/ProductVersion: //g; s/\.//g') kernel_string="$short_product_type"-"$short_product_version" if [[ "$product_type" == iPad* ]]; then kernel_string=ipad"$kernel_string" fi kernel_path="/Users/ben/Desktop/kernels/$kernel_string" printf "$id" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep DeviceName | sed 's/DeviceName: //g')" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep ProductType | sed 's/ProductType: //g')" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep ProductVersion | sed 's/ProductVersion: //g')" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep BuildVersion | sed 's/BuildVersion: //g')" printf ' | ' if [[ -e "$kernel_path" ]]; then quick_path=$(echo $kernel_path | sed 's/\/Users\/ben/~/') printf "$quick_path" else printf '-' fi printf '\n' done -
PsychoTea revised this gist
Nov 22, 2019 . No changes.There are no files selected for viewing
-
PsychoTea revised this gist
Nov 22, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/bin/bash # Requires idevice_id, ideviceinfo (libimobiledevice) for id in $(idevice_id -l); do ideviceinfo_data=$(ideviceinfo -u $id) -
PsychoTea created this gist
Nov 22, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ #!/bin/bash for id in $(idevice_id -l); do ideviceinfo_data=$(ideviceinfo -u $id) product_type=$(echo "$ideviceinfo_data" | grep ProductType | sed 's/ProductType: //g') # strip 'iPhone' or 'iPad' and the comma from the product type short_product_type=$(echo "$product_type" | sed 's/iPhone//g; s/iPad//g; s/,//g' ) short_product_version=$(echo "$ideviceinfo_data" | grep ProductVersion | sed 's/ProductVersion: //g; s/\.//g') kernel_string="$short_product_type"-"$short_product_version" if [[ "$product_type" == iPad* ]]; then kernel_string=ipad"$kernel_string" fi kernel_path="/Users/ben/Desktop/kernels/$kernel_string" printf "$id" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep DeviceName | sed 's/DeviceName: //g')" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep ProductType | sed 's/ProductType: //g')" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep ProductVersion | sed 's/ProductVersion: //g')" printf ' | ' printf "$(echo "$ideviceinfo_data" | grep BuildVersion | sed 's/BuildVersion: //g')" printf ' | ' if [[ -e "$kernel_path" ]]; then quick_path=$(echo $kernel_path | sed 's/\/Users\/ben/~/') printf "$quick_path" else printf '-' fi printf '\n' done 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ #!/bin/bash # Requires ideviceinfo (libimobiledevice), pzb, curl, jq if [[ "$#" -lt "2" ]]; then echo "Usage: pullipsw [uuid] [version]" exit 0 fi target_uuid="$1" target_version="$2" echo "Finding IPSW for $target_uuid, version $target_version..." device_info=$(ideviceinfo -u $target_uuid) if [[ "$device_info" == ERROR* ]]; then echo "Failed to find device with UUID $target_uuid!" exit 0 fi device_name=$(echo "$device_info" | grep DeviceName | sed 's/DeviceName: //g') product_type=$(echo "$device_info" | grep ProductType | sed 's/ProductType: //g') product_version=$(echo "$device_info" | grep ProductVersion | sed 's/ProductVersion: //g') build_version=$(echo "$device_info" | grep BuildVersion | sed 's/BuildVersion: //g') echo "Device name: $device_name" echo "Product type: $product_type" echo "Product version: $product_version" echo "Build version: $build_version" # Find the buildid from the version number ipsw_url=$(curl https://api.ipsw.me/v4/device/$product_type?type=ipsw 2>/dev/null | jq -r '.firmwares[] | select(.version == "'$target_version'") | .url') echo echo IPSW URL: $ipsw_url echo cd /tmp wget $ipsw_url file_name=$(echo $ipsw_curl | rev | cut -d'/' -f1 | rev) echo "Saved to $file_name." 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,77 @@ #!/bin/bash # Requires ideviceinfo (libimobiledevice), pzb, jtool2 build_kernel_string () { # $0 = product type ie. iPhone12,1 # $1 = product version ie. 13.2.2 short_product_type=$(echo "$1" | sed 's/iPhone//g; s/iPad//g; s/,//g') short_product_version=$(echo "$2" | sed 's/\.//g') echo "$short_product_type-$short_product_version" } if [[ "$#" == "0" ]]; then echo "Usage: pullkernel [uuid]" exit 0 fi target_uuid=$1 echo "Finding kernel for $target_uuid..." device_info=$(ideviceinfo -u $target_uuid) if [[ "$device_info" == ERROR* ]]; then echo "Failed to find device with UUID $target_uuid!" exit 0 fi device_name=$(echo "$device_info" | grep DeviceName | sed 's/DeviceName: //g') product_type=$(echo "$device_info" | grep ProductType | sed 's/ProductType: //g') product_version=$(echo "$device_info" | grep ProductVersion | sed 's/ProductVersion: //g') build_version=$(echo "$device_info" | grep BuildVersion | sed 's/BuildVersion: //g') kernel_string=$(build_kernel_string $product_type $product_version) echo "Device name: $device_name" echo "Product type: $product_type" echo "Product version: $product_version" echo "Build version: $build_version" echo "Kernel string: $kernel_string" final_kernel_path="/Users/ben/Desktop/kernels/$kernel_string" if [[ ! -e $final_kernel_path ]]; then echo "Kernel already found, exiting..." exit 0 fi # Download the kernel cd /tmp url_string="https://api.ipsw.me/v4/ipsw/download/$product_type/$build_version" echo "URL: $url_string" echo "Fetching files..." pzb_kernel_string=$(pzb -l "$url_string" | grep kernelcache | cut -d' ' -f5) echo "Pulling kernel file $pzb_kernel_string..." pzb -g $pzb_kernel_string $url_string | grep '\[' echo "Decompressing with jtool2..." jtool2 -dec $pzb_kernel_string mv kernel $final_kernel_path echo listdevices echo echo "Complete!"