Some notes, tools, and techniques for reverse engineering macOS binaries.
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
// Used to detect specific issue with JSON decoding | |
func decodeOrReport(data: Data) { | |
do { | |
let _ = try JSONDecoder().decode(WidgetResponse.self, from: data) | |
print("\n\n👍ALL GOOD\n\n") | |
} catch DecodingError.keyNotFound( let key, let context) { | |
print("\n\n⛔️FAILED TO DECODE\n\n") | |
print("could not find key \(key) in JSON: \(context.debugDescription)") | |
} catch DecodingError.valueNotFound( let type, let context) { | |
print("\n\n⛔️FAILED TO DECODE\n\n") |
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
// taken 2018-03-19 from wikipedia. https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 | |
enum Iso3166_1a2: String { | |
case af = "AF" | |
case ax = "AX" | |
case al = "AL" | |
case dz = "DZ" | |
case `as` = "AS" | |
case ad = "AD" | |
case ao = "AO" |
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
// | |
// CGCoordinateSpaces.swift | |
// | |
// Created by Stephan Casas on 11/7/23. | |
// | |
import Foundation; | |
// MARK: - CGPoint |
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
// | |
// ImageDraggableModifier.swift | |
// Pictura | |
// | |
// Created by Jonathan Benavides Vallejo on 25.08.23. | |
// | |
import SwiftUI | |
import AppKit |
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
// Type-safe State Machine with Phantom Type May 2022 @AtarayoSD | |
import Foundation | |
protocol State {} | |
// Transitions | |
protocol TransferableToB {} | |
protocol TransferableToC {} | |
protocol TransferableToD {} |
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 lldb | |
def __lldb_init_module(debugger, internal_dict): | |
debugger.HandleCommand('command script add -f SwiftPrinter.printer pjson') | |
def printer(debugger, command, result, internal_dict): | |
debugger.HandleCommand('p print(String(data: try! JSONSerialization.data(withJSONObject:' + command + ', options: .prettyPrinted), encoding: .utf8 )!)') |
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
// A URLSession extension that fetches data from a URL and decodes to some Decodable type. | |
// Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL) | |
// Note: this requires Swift 5.5. | |
extension URLSession { | |
func decode<T: Decodable>( | |
_ type: T.Type = T.self, | |
from url: URL, | |
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData, | |
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate |
This is an effort to document what is known about Google's (Blogger's/Blogspot's) image URL parameters. Some of these options were taken from existing first or third party documentation (see the links at the end of this document), but the majority is based off my own investigations.
- On Blogger's image URL's:
2.bp.blogspot.com/-OF7u67HQE1M/VHc8S8qJTDI/AAAAAAAACxI/UD-11c63diQ/
s1600
/005.png
- On just about any googleusercontent image URL:
https://lh3.googleusercontent.com/Jvmz11cLrvNIHG_LWjVO9B-UV2IN4Cfk1pycbhWZl6IriMgCAGCOFuBRtoHaiZ6xeVGqCugZcCql=
w176-h176-n-o
Replace the bolded parts with the parameters.
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
// Run any SwiftUI view as a Mac app. | |
import Cocoa | |
import SwiftUI | |
NSApplication.shared.run { | |
VStack { | |
Text("Hello, World") | |
.padding() | |
.background(Capsule().fill(Color.blue)) |
NewerOlder