Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Swift resistant against hooking?

Cycript is a console based application that is a blend of Objective-C and JavaScript. Cycript is very useful for dynamic analysis of iOS applications.

If you write any methods or the complete ipa with Swift is it still possible to hook the application on a jailbroken device? Or is Swift safe like "native C" Code on iOS ?

like image 369
user3859460 Avatar asked Nov 10 '22 04:11

user3859460


1 Answers

I'm not really familiar with Cycript but I have a little understanding of the Swift compiler.

Swift code will be more resistant to hooking but it should not be completely impossible. NSObject subclasses and Swift classes that are declared @objc should be as accessible as Objective-C code. Pure Swift code, especially in optimised builds would be harder to inject code into because they are often statically dispatched and in many cases will actually be inlined into the calling code.

Where code hasn't been inlined it may may be possible to patch the functions in memory themselves to jump to an alternative function but it wouldn't be as easy as just modifying function tables.

Where key functions have been inlined it may be possible to find and modify each usage if common patterns of code that could be identified and if the function is long enough it may be posible to patch in a jump to an alternate version but this would get really quite tricky.

like image 77
Joseph Lord Avatar answered Nov 15 '22 09:11

Joseph Lord