Once a method is replaced with a malicious payload, the malicious code can then perform its own tasks and then return its own custom values. It can even call the original method’s code and make changes to the data prior to returning.
In this example, you’ll build a dynamic library (
.dylib) that will serve as a malicious payload,
and inject it into the Hello World program using a debugger. When the code
runs, your malicious function will replace the
say method that would normally print the
specified output to the screen, and will instead print malicious text out.
Don’t worry; your malicious payload will be G-rated.
Unlike other payloads in this book, which have been delivered in the form of an executable binary, the CodeTheft payload is built as a shared object. This is later dynamically loaded into the target application, and used to replace a targeted method.
As you’ve learned, an Objective-C method accepts two arguments: a receiver and a selector. Your ...