SlideShare a Scribd company logo
1 of 23
Download to read offline
December 15th, 2014
Playing with SIMBL
What is SIMBL?
SIMple Bundle Loader
3
SIMBL	
  loads	
  an	
  NSBundle	
  in	
  a	
  running	
  applica5on	
  process	
  
Mac	
  OS	
  X	
  only	
  (no	
  iOS,	
  sorry)	
  
Objec5ve-­‐C	
  only	
  (No	
  SwiB!)
SIMple Bundle Loader
4
erm…	
  NSBundle?
Objective-C
Objective-C’s dynamic nature
6
Objec5ve-­‐C:	
  
All available classes are in a set
Classes are dictionaries of methods
As	
  a	
  consequence:	
  
Dynamic loading: loading new classes in the application’s “context”
Categories: adding new methods to existing classes
Method swizzling: exchange implementations of a method
Until the last consequences
NSBundle you said?
7
From	
  Apple	
  docs:	
  
An	
  NSBundle	
  object	
  represents	
  a	
  loca%on	
  in	
  the	
  file	
  system	
  
that	
  groups	
  code	
  and	
  resources	
  that	
  can	
  be	
  used	
  in	
  a	
  
program.	
  
NSBundle	
  objects	
  locate	
  program	
  resources,	
  dynamically	
  
load	
  and	
  unload	
  executable	
  code,	
  and	
  assist	
  in	
  localiza;on.	
  
You	
  build	
  a	
  bundle	
  in	
  Xcode	
  using	
  one	
  of	
  these	
  project	
  types:	
  
Applica;on,	
  Framework,	
  plug-­‐ins.
You’re already using NSBundles
Using SIMBL
SIMBL and NSBundle
9
SIMBL:	
  
Runs	
  as	
  a	
  daemon	
  in	
  the	
  system	
  
Watches	
  for	
  new	
  processes	
  to	
  be	
  launched	
  by	
  launchd	
  
This is done by observing NSWorkspace
Hooks	
  in	
  the	
  applica5on’s	
  process	
  and	
  loads	
  your	
  bundle	
  
Uses the ScriptingBridge interface, SBApplication
SIMBL mixes your NSBundle with the application’s ones
The entry point
10
PrincipalClass and +load
NSBundles	
  have	
  an	
  Info.plist	
  file	
  
Bundle version
Principal class: The principal class typically controls all the other classes
in the bundle; it should mediate between those classes and classes
external to the bundle
SIMBLTargetApplications: custom key to indicate applications where you
want the bundle loaded by SIMBL
+load	
  method	
  is	
  called	
  whenever	
  any	
  class	
  is	
  loaded	
  in	
  an	
  
applica5on’s	
  address	
  space	
  
SIMBL	
  plugins	
  use	
  +load	
  in	
  the	
  Principal	
  Class	
  to	
  ini5alise
Your hooking points
11
Singletons	
  
[NSApplication sharedApplication]
[NSNotificationCenter defaultCenter]
[NSHTTPCookieStorage sharedHTTPCookieStorage],…
Well-­‐known	
  classes	
  (by	
  method	
  swizzling)	
  
NSWindow,…
Classes	
  found	
  by	
  introspec5on	
  
Open source code
Debugging the process
Example project
12
demo	
  
https://github.com/rs/SafariTabSwitching
Useful tools
Running and debugging in Xcode
14
Run	
  Script	
  build	
  phase	
  to	
  install	
  your	
  project,	
  run	
  your	
  target	
  
applica5on	
  and	
  aXach	
  the	
  debugger	
  to	
  it	
  
https://github.com/iandai/Debug-SIMBL-Plugin
List classes in a binary
15
class-dump
Generates	
  .h	
  files	
  for	
  all	
  classes	
  and	
  methods	
  found	
  in	
  a	
  file	
  
hXp://stevenygard.com/projects/class-­‐dump/
List loaded classes at runtime
16
-(void) printClasses
{
int numClasses;
Class * classes = NULL;
classes = NULL;
numClasses = objc_getClassList(NULL, 0);
if (numClasses > 0 )
{
classes = (__unsafe_unretained Class *)malloc(sizeof(Class) *
numClasses);
numClasses = objc_getClassList(classes, numClasses);
for (int i = 0; i < numClasses; i++) {
Class c = classes[i];
NSLog(@"%s", class_getName(c));
}
free(classes);
}
}
Debug logging all notifications
17
void MyCallBack (CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo)
{
NSLog(@"name: %@, userinfo: %@", name, userInfo);
}
-(void)install
{
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
NULL,
MyCallBack,
NULL,
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
}
Objective-C tracing
18
Console and graphical debugger
hXp://www.dribin.org/dave/blog/archives/2006/04/22/
tracing_objc/	
  
command line: NSObjCMessageLoggingEnabled=YES
llvm: call (void)instrumentObjcMessageSends(YES)
dtrace	
  
sudo dtrace -q -n 'objc1234:::entry { printf("%s %sn", probemod,
probefunc); }' // where 1234 is the process ID of the app.
F-Script
19
Console and graphical debugger
hXp://www.fscript.org/	
  
hXp://areciv.com/blog/2014/08/f-­‐script-­‐injec5on-­‐in-­‐
mavericks/	
  (also	
  works	
  for	
  Yosemite)	
  
Tip: put the Framework under /System, so that you can also get to it
from a sandboxed application
Discussion
SIMBL future
21
Doesn’t look that good
SIMBL	
  project	
  no	
  longer	
  maintained,	
  not	
  suppor5ng	
  
sandboxed	
  applica5ons	
  
EasySIMBL	
  supports	
  sandboxed	
  applica5ons	
  up	
  to	
  Yosemite	
  
SwiB	
  design	
  is	
  not	
  so	
  dynamic	
  
Still compatible with Objective-C to some extent
One of the main speed gains is because the classes and methods are
statically compiled if possible
Security	
  concerns	
  
SIMBL allows you to do virtually anything in a process
Reference
22
SIMBL:	
  
https://code.google.com/p/simbl/wiki/
https://github.com/norio-nomura/EasySIMBL
Sample	
  plugins:	
  
https://github.com/rs/SafariTabSwitching (doesn’t work)
https://github.com/inket/cosyTabs (doesn’t work)
https://code.google.com/p/greasekit/ (doesn’t work)
Cool	
  images:	
  ano.lolcathost.org
Thanks!
!
"
mobilejazz.com
+34 931 702 770
Jordi Giménez#

More Related Content

What's hot

Introduction to Type Level Programming
Introduction to Type Level ProgrammingIntroduction to Type Level Programming
Introduction to Type Level ProgrammingYuval Itzchakov
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVMJung Kim
 
Kyua and Jenkins: Testing Framework for BSD
Kyua and Jenkins: Testing Framework for BSDKyua and Jenkins: Testing Framework for BSD
Kyua and Jenkins: Testing Framework for BSDCraig Rodrigues
 
Deploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerSander van der Burg
 
Practical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaPractical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaRoberto Casadei
 
Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02Omer van Kloeten
 

What's hot (7)

Introduction to Type Level Programming
Introduction to Type Level ProgrammingIntroduction to Type Level Programming
Introduction to Type Level Programming
 
LLVM
LLVMLLVM
LLVM
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 
Kyua and Jenkins: Testing Framework for BSD
Kyua and Jenkins: Testing Framework for BSDKyua and Jenkins: Testing Framework for BSD
Kyua and Jenkins: Testing Framework for BSD
 
Deploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package manager
 
Practical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaPractical Aggregate Programming in Scala
Practical Aggregate Programming in Scala
 
Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02
 

Similar to Playing with SIMBL - Mobile Jazz Inspirational Talks

What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?Kyle Oba
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)DroidConTLV
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using SwiftDiego Freniche Brito
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONAYESHA JAVED
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Paris Android User Group
 
ShipItCon - Continuous Deployment and Multicloud with Ansible and Kubernetes
ShipItCon - Continuous Deployment and Multicloud with Ansible and KubernetesShipItCon - Continuous Deployment and Multicloud with Ansible and Kubernetes
ShipItCon - Continuous Deployment and Multicloud with Ansible and KubernetesMihai Criveti
 
WP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual StudioWP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual StudioMICTT Palma
 
Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18James Leone
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Mohamed Essam
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - IntroductionRakesh Jha
 
OutSystems UserGroup ODC External Logic.pdf
OutSystems UserGroup ODC External Logic.pdfOutSystems UserGroup ODC External Logic.pdf
OutSystems UserGroup ODC External Logic.pdfMartinHenning3
 

Similar to Playing with SIMBL - Mobile Jazz Inspirational Talks (20)

What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?
 
Roslyn
RoslynRoslyn
Roslyn
 
Type script
Type scriptType script
Type script
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
109842496 jni
109842496 jni109842496 jni
109842496 jni
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
ShipItCon - Continuous Deployment and Multicloud with Ansible and Kubernetes
ShipItCon - Continuous Deployment and Multicloud with Ansible and KubernetesShipItCon - Continuous Deployment and Multicloud with Ansible and Kubernetes
ShipItCon - Continuous Deployment and Multicloud with Ansible and Kubernetes
 
WP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual StudioWP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual Studio
 
Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 
IntroML_2.
IntroML_2.IntroML_2.
IntroML_2.
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
Complete Java Course
Complete Java CourseComplete Java Course
Complete Java Course
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - Introduction
 
OutSystems UserGroup ODC External Logic.pdf
OutSystems UserGroup ODC External Logic.pdfOutSystems UserGroup ODC External Logic.pdf
OutSystems UserGroup ODC External Logic.pdf
 

Recently uploaded

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Playing with SIMBL - Mobile Jazz Inspirational Talks

  • 3. SIMple Bundle Loader 3 SIMBL  loads  an  NSBundle  in  a  running  applica5on  process   Mac  OS  X  only  (no  iOS,  sorry)   Objec5ve-­‐C  only  (No  SwiB!)
  • 6. Objective-C’s dynamic nature 6 Objec5ve-­‐C:   All available classes are in a set Classes are dictionaries of methods As  a  consequence:   Dynamic loading: loading new classes in the application’s “context” Categories: adding new methods to existing classes Method swizzling: exchange implementations of a method Until the last consequences
  • 7. NSBundle you said? 7 From  Apple  docs:   An  NSBundle  object  represents  a  loca%on  in  the  file  system   that  groups  code  and  resources  that  can  be  used  in  a   program.   NSBundle  objects  locate  program  resources,  dynamically   load  and  unload  executable  code,  and  assist  in  localiza;on.   You  build  a  bundle  in  Xcode  using  one  of  these  project  types:   Applica;on,  Framework,  plug-­‐ins. You’re already using NSBundles
  • 9. SIMBL and NSBundle 9 SIMBL:   Runs  as  a  daemon  in  the  system   Watches  for  new  processes  to  be  launched  by  launchd   This is done by observing NSWorkspace Hooks  in  the  applica5on’s  process  and  loads  your  bundle   Uses the ScriptingBridge interface, SBApplication SIMBL mixes your NSBundle with the application’s ones
  • 10. The entry point 10 PrincipalClass and +load NSBundles  have  an  Info.plist  file   Bundle version Principal class: The principal class typically controls all the other classes in the bundle; it should mediate between those classes and classes external to the bundle SIMBLTargetApplications: custom key to indicate applications where you want the bundle loaded by SIMBL +load  method  is  called  whenever  any  class  is  loaded  in  an   applica5on’s  address  space   SIMBL  plugins  use  +load  in  the  Principal  Class  to  ini5alise
  • 11. Your hooking points 11 Singletons   [NSApplication sharedApplication] [NSNotificationCenter defaultCenter] [NSHTTPCookieStorage sharedHTTPCookieStorage],… Well-­‐known  classes  (by  method  swizzling)   NSWindow,… Classes  found  by  introspec5on   Open source code Debugging the process
  • 14. Running and debugging in Xcode 14 Run  Script  build  phase  to  install  your  project,  run  your  target   applica5on  and  aXach  the  debugger  to  it   https://github.com/iandai/Debug-SIMBL-Plugin
  • 15. List classes in a binary 15 class-dump Generates  .h  files  for  all  classes  and  methods  found  in  a  file   hXp://stevenygard.com/projects/class-­‐dump/
  • 16. List loaded classes at runtime 16 -(void) printClasses { int numClasses; Class * classes = NULL; classes = NULL; numClasses = objc_getClassList(NULL, 0); if (numClasses > 0 ) { classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses); numClasses = objc_getClassList(classes, numClasses); for (int i = 0; i < numClasses; i++) { Class c = classes[i]; NSLog(@"%s", class_getName(c)); } free(classes); } }
  • 17. Debug logging all notifications 17 void MyCallBack (CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { NSLog(@"name: %@, userinfo: %@", name, userInfo); } -(void)install { CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, MyCallBack, NULL, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); }
  • 18. Objective-C tracing 18 Console and graphical debugger hXp://www.dribin.org/dave/blog/archives/2006/04/22/ tracing_objc/   command line: NSObjCMessageLoggingEnabled=YES llvm: call (void)instrumentObjcMessageSends(YES) dtrace   sudo dtrace -q -n 'objc1234:::entry { printf("%s %sn", probemod, probefunc); }' // where 1234 is the process ID of the app.
  • 19. F-Script 19 Console and graphical debugger hXp://www.fscript.org/   hXp://areciv.com/blog/2014/08/f-­‐script-­‐injec5on-­‐in-­‐ mavericks/  (also  works  for  Yosemite)   Tip: put the Framework under /System, so that you can also get to it from a sandboxed application
  • 21. SIMBL future 21 Doesn’t look that good SIMBL  project  no  longer  maintained,  not  suppor5ng   sandboxed  applica5ons   EasySIMBL  supports  sandboxed  applica5ons  up  to  Yosemite   SwiB  design  is  not  so  dynamic   Still compatible with Objective-C to some extent One of the main speed gains is because the classes and methods are statically compiled if possible Security  concerns   SIMBL allows you to do virtually anything in a process
  • 22. Reference 22 SIMBL:   https://code.google.com/p/simbl/wiki/ https://github.com/norio-nomura/EasySIMBL Sample  plugins:   https://github.com/rs/SafariTabSwitching (doesn’t work) https://github.com/inket/cosyTabs (doesn’t work) https://code.google.com/p/greasekit/ (doesn’t work) Cool  images:  ano.lolcathost.org