Cycript: Objective-JavaScript ,它懂Objective-C,也懂javascript。我們能夠藉助Cycript使用Objective-C或者javascript ,給某個正在執行的程式的runtime傳送訊息。
本文以修改支付寶app介面為例,介紹Cycript的使用方法。
1)安裝Cycript
到Cycript官方網站下載資源工具,然後推進已越獄的iPhone中,進行安裝:
1 2 |
dpkg -i cycript_0.9.461_iphoneos-arm.deb dpkg -i libffi_1-3.0.10-5_iphoneos-arm.deb |
2)確定支付寶程式
執行支付寶app,然後獲取它的程式號:
1 2 3 4 |
Primer:/ root# ps aux | grep Portal mobile 479 0.6 4.3 590776 44956 ?? Ss 5:14PM 0:09.58 /var/mobile/Applications/8723004E-9E54-4B37-856D-86292780E958/Portal.app/Portal root 497 0.0 0.0 329252 176 s000 R+ 5:21PM 0:00.00 grep Portal |
3)Cycript鉤住支付寶程式
1 2 |
Primer:/ root# cycript -p 479 cy# |
4)獲取當前介面的viewController並修改背景色
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
cy# var app = [UIApplication sharedApplication] @"<DFApplication: 0x16530660>" cy# app.delegate @"<DFClientDelegate: 0x165384d0>" cy# var keyWindow = app.keyWindow @"<UIWindow: 0x1654abb0; frame = (0 0; 320 568); gestureRecognizers = <NSArray: 0x1654b190>; layer = <UIWindowLayer: 0x1654ace0>>" cy# var rootController = keyWindow.rootViewController @"<DFNavigationController: 0x1654b6c0>" cy# var visibleController = rootController.visibleViewController @"<ALPLauncherController: 0x166acfb0>" cy# visibleController.childViewControllers @["<HPHomeWidgetGroup: 0x166afbc0>","<ADWRootViewController: 0x165745c0>","<ALPAssetsRootViewController: 0x16577250>","<SWSecurityWidgetGroup: 0x166bd940>"] cy# var assetsController = new Instance(0x16577250) @"<ALPAssetsRootViewController: 0x16577250>" cy# assetsController.view.backgroundColor = [UIColor blueColor] @"UIDeviceRGBColorSpace 0 0 1 1" |
當然,只是修改個背景色好沒意思……
想修改更多資訊,還得介紹一下另一個利器: class-dump 。下篇再總結~