macOS Objective-C
Learn & practice AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Objective-C
Note that programs written in Objective-C retain their class declarations when compiled into Mach-O binaries. Such class declarations include the name and type of:
The class
The class methods
The class instance variables
You can get this information using class-dump:
class-dump Kindle.appNote that this names could be obfuscated to make the reversing of the binary more difficult.
Classes, Methods & Objects
Interface, Properties & Methods
Class
Object & Call Method
To create an instance of a class the alloc method is called which allocate memory for each property and zero those allocations. Then init is called, which initilize the properties to the required values.
Class Methods
Class methods are defined with the plus sign (+) not the hyphen (-) that is used with instance methods. Like the NSString class method stringWithString:
Setter & Getter
To set & get properties, you could do it with a dot notation or like if you were calling a method:
Instance Variables
Alternatively to setter & getter methods you can use instance variables. These variables have the same name as the properties but starting with a "_":
Protocols
Protocols are set of method declarations (without properties). A class that implements a protocol implement the declared methods.
There are 2 types of methods: mandatory and optional. By default a method is mandatory (but you can also indicate it with a @required tag). To indicate that a method is optional use @optional.
All together
Basic Classes
String
Basic classes are immutable, so to append a string to an existing one a new NSString needs to be created.
Or you could also use a mutable string class:
Number
Array, Sets & Dictionary
Blocks
Blocks are functions that behaves as objects so they can be passed to functions or stored in arrays or dictionaries. Also, they can represent a value if they are given values so it's similar to lambdas.
It's also possible to define a block type to be used as a parameter in functions:
Files
It's also possible to manage files using NSURL objects instead of NSString objects. The method names are similar, but with URL instead of Path.
Last updated