Skip to content

Commit

Permalink
Updated for iOS 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Torbichuk committed Feb 8, 2015
1 parent e650ba5 commit 03a78a2
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 133 deletions.
1 change: 1 addition & 0 deletions Headers/PonyDebugger
1 change: 1 addition & 0 deletions Headers/SocketRocket
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARCHS = armv7 armv7s arm64
include theos/makefiles/common.mk

SDKVERSION = 8.1
INCLUDE_SDKVERSION = 8.1
TARGET_IPHONEOS_DEPLOYMENT_VERSION = 7.0
TARGET_CC = xcrun -sdk iphoneos clang
TARGET_CXX = xcrun -sdk iphoneos clang++
TARGET_LD = xcrun -sdk iphoneos clang++

TWEAK_NAME = PonyDebuggerInjected
PonyDebuggerInjected_FILES = Tweak.xm PonyDebugger/ObjC/DerivedSources/PDApplicationCacheDomain.m PonyDebugger/ObjC/DerivedSources/PDApplicationCacheTypes.m PonyDebugger/ObjC/DerivedSources/PDConsoleDomain.m PonyDebugger/ObjC/DerivedSources/PDConsoleTypes.m PonyDebugger/ObjC/DerivedSources/PDCSSDomain.m PonyDebugger/ObjC/DerivedSources/PDCSSTypes.m PonyDebugger/ObjC/DerivedSources/PDDatabaseDomain.m PonyDebugger/ObjC/DerivedSources/PDDatabaseTypes.m PonyDebugger/ObjC/DerivedSources/PDDebuggerDomain.m PonyDebugger/ObjC/DerivedSources/PDDebuggerTypes.m PonyDebugger/ObjC/DerivedSources/PDDOMDebuggerDomain.m PonyDebugger/ObjC/DerivedSources/PDDOMDomain.m PonyDebugger/ObjC/DerivedSources/PDDOMStorageDomain.m PonyDebugger/ObjC/DerivedSources/PDDOMStorageTypes.m PonyDebugger/ObjC/DerivedSources/PDDOMTypes.m PonyDebugger/ObjC/DerivedSources/PDFileSystemDomain.m PonyDebugger/ObjC/DerivedSources/PDFileSystemTypes.m PonyDebugger/ObjC/DerivedSources/PDIndexedDBDomain.m PonyDebugger/ObjC/DerivedSources/PDIndexedDBTypes.m PonyDebugger/ObjC/DerivedSources/PDInspectorDomain.m PonyDebugger/ObjC/DerivedSources/PDMemoryDomain.m PonyDebugger/ObjC/DerivedSources/PDMemoryTypes.m PonyDebugger/ObjC/DerivedSources/PDNetworkDomain.m PonyDebugger/ObjC/DerivedSources/PDNetworkTypes.m PonyDebugger/ObjC/DerivedSources/PDPageDomain.m PonyDebugger/ObjC/DerivedSources/PDPageTypes.m PonyDebugger/ObjC/DerivedSources/PDProfilerDomain.m PonyDebugger/ObjC/DerivedSources/PDProfilerTypes.m PonyDebugger/ObjC/DerivedSources/PDRuntimeDomain.m PonyDebugger/ObjC/DerivedSources/PDRuntimeTypes.m PonyDebugger/ObjC/DerivedSources/PDTimelineDomain.m PonyDebugger/ObjC/DerivedSources/PDTimelineTypes.m PonyDebugger/ObjC/DerivedSources/PDWebGLDomain.m PonyDebugger/ObjC/DerivedSources/PDWebGLTypes.m PonyDebugger/ObjC/DerivedSources/PDWorkerDomain.m PonyDebugger/ObjC/PonyDebugger/NSArray+PD_JSONObject.m PonyDebugger/ObjC/PonyDebugger/NSArray+PDRuntimePropertyDescriptor.m PonyDebugger/ObjC/PonyDebugger/NSData+PDDebugger.m PonyDebugger/ObjC/PonyDebugger/NSDate+PD_JSONObject.m PonyDebugger/ObjC/PonyDebugger/NSDate+PDDebugger.m PonyDebugger/ObjC/PonyDebugger/NSDictionary+PDRuntimePropertyDescriptor.m PonyDebugger/ObjC/PonyDebugger/NSError+PD_JSONObject.m PonyDebugger/ObjC/PonyDebugger/NSManagedObject+PDRuntimePropertyDescriptor.m PonyDebugger/ObjC/PonyDebugger/NSObject+PDRuntimePropertyDescriptor.m PonyDebugger/ObjC/PonyDebugger/NSOrderedSet+PDRuntimePropertyDescriptor.m PonyDebugger/ObjC/PonyDebugger/NSSet+PDRuntimePropertyDescriptor.m PonyDebugger/ObjC/PonyDebugger/PDConsoleDomainController.m PonyDebugger/ObjC/PonyDebugger/PDContainerIndex.m PonyDebugger/ObjC/PonyDebugger/PDDebugger.m PonyDebugger/ObjC/PonyDebugger/PDDefinitions.m PonyDebugger/ObjC/PonyDebugger/PDDomainController.m PonyDebugger/ObjC/PonyDebugger/PDDOMDomainController.m PonyDebugger/ObjC/PonyDebugger/PDDynamicDebuggerDomain.m PonyDebugger/ObjC/PonyDebugger/PDIndexedDBDomainController.m PonyDebugger/ObjC/PonyDebugger/PDInspectorDomainController.m PonyDebugger/ObjC/PonyDebugger/PDNetworkDomainController.m PonyDebugger/ObjC/PonyDebugger/PDObject.m PonyDebugger/ObjC/PonyDebugger/PDPageDomainController.m PonyDebugger/ObjC/PonyDebugger/PDPrettyStringPrinter.m PonyDebugger/ObjC/PonyDebugger/PDRuntimeDomainController.m PonyDebugger/ObjC/SocketRocket/SocketRocket/SRWebSocket.m
PonyDebuggerInjected_FRAMEWORKS = UIKit CoreGraphics CoreData CFNetwork Security
PonyDebuggerInjected_LIBRARIES = icucore

ADDITIONAL_CFLAGS = -IPonyDebugger/ObjC/DerivedSources -IPonyDebugger/ObjC -IPonyDebugger/ObjC/SocketRocket -fobjc-arc -Os -IHeaders -IHeaders/PonyDebugger -Qunused-arguments -Wno-unused-const-variable -Wno-c++11-extensions -Xclang -fobjc-runtime-has-weak

BUNDLE_NAME = PonyDebuggerInjectedBundle
PonyDebuggerInjectedBundle_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
include $(THEOS)/makefiles/bundle.mk

include $(THEOS_MAKE_PATH)/tweak.mk


after-install::
install.exec "killall -9 SpringBoard"
2 changes: 1 addition & 1 deletion PonyDebugger
Submodule PonyDebugger updated 77 files
+0 −3 .gitmodules
+ Documentation/Images/RemoteLogging.png
+ Examples/PDTestApp/[email protected]
+ Examples/PDTestApp/Icon.png
+ Examples/PDTestApp/[email protected]
+158 −86 Examples/PDTestApp/PDTestApp.xcodeproj/PDTwitterTest.xcodeproj/project.pbxproj
+0 −0 Examples/PDTestApp/PDTestApp.xcodeproj/PDTwitterTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+428 −0 Examples/PDTestApp/PDTestApp.xcodeproj/project.pbxproj
+1 −1 Examples/PDTestApp/PDTestApp/PDAppDelegate.h
+12 −8 Examples/PDTestApp/PDTestApp/PDAppDelegate.m
+19 −0 Examples/PDTestApp/PDTestApp/PDOwner.h
+18 −0 Examples/PDTestApp/PDTestApp/PDOwner.m
+7 −7 Examples/PDTestApp/PDTestApp/PDRepo.h
+8 −8 Examples/PDTestApp/PDTestApp/PDRepo.m
+1 −1 Examples/PDTestApp/PDTestApp/PDTestApp-Prefix.pch
+3 −3 Examples/PDTestApp/PDTestApp/PDURLConnectionViewController.h
+283 −0 Examples/PDTestApp/PDTestApp/PDURLConnectionViewController.m
+15 −0 Examples/PDTestApp/PDTestApp/PDURLSessionDownloadViewController.h
+63 −0 Examples/PDTestApp/PDTestApp/PDURLSessionDownloadViewController.m
+15 −0 Examples/PDTestApp/PDTestApp/PDURLSessionViewController.h
+101 −0 Examples/PDTestApp/PDTestApp/PDURLSessionViewController.m
+1 −1 Examples/PDTestApp/PDTestApp/main.m
+0 −0 Examples/PDTestApp/Resources/InfoPlist.strings
+251 −0 Examples/PDTestApp/Resources/MainStoryboard.storyboard
+1 −1 Examples/PDTestApp/Resources/PDTestApp-Info.plist
+19 −0 Examples/PDTestApp/Resources/PDTestApp.xcdatamodeld/PDTestApp.xcdatamodel/contents
+0 −1 Examples/PDTwitterTest/AFNetworking
+0 −20 Examples/PDTwitterTest/PDTwitterTest/PDUser.h
+0 −19 Examples/PDTwitterTest/PDTwitterTest/PDUser.m
+0 −330 Examples/PDTwitterTest/PDTwitterTest/PDViewController.m
+0 −88 Examples/PDTwitterTest/Resources/MainStoryboard.storyboard
+0 −8 Examples/PDTwitterTest/Resources/PDTwitterTest.xcdatamodeld/.xccurrentversion
+0 −20 Examples/PDTwitterTest/Resources/PDTwitterTest.xcdatamodeld/PDTwitterTest.xcdatamodel/contents
+ Examples/PDTwitterTest/Resources/twitter_egg.png
+ Examples/PDTwitterTest/Resources/[email protected]
+124 −32 ObjC/PonyDebugger.xcodeproj/project.pbxproj
+10 −1 ObjC/PonyDebugger.xcodeproj/xcshareddata/xcschemes/PonyDebugger.xcscheme
+8 −13 ObjC/PonyDebugger/NSArray+PDRuntimePropertyDescriptor.h
+97 −0 ObjC/PonyDebugger/NSArray+PDRuntimePropertyDescriptor.m
+0 −23 ObjC/PonyDebugger/NSData+PDB64Additions.h
+0 −228 ObjC/PonyDebugger/NSData+PDB64Additions.m
+9 −0 ObjC/PonyDebugger/NSData+PDDebugger.h
+20 −0 ObjC/PonyDebugger/NSData+PDDebugger.m
+15 −0 ObjC/PonyDebugger/NSDate+PDDebugger.h
+18 −0 ObjC/PonyDebugger/NSDate+PDDebugger.m
+22 −0 ObjC/PonyDebugger/NSDictionary+PDRuntimePropertyDescriptor.h
+14 −65 ObjC/PonyDebugger/NSDictionary+PDRuntimePropertyDescriptor.m
+11 −5 ObjC/PonyDebugger/NSManagedObject+PDRuntimePropertyDescriptor.m
+7 −1 ObjC/PonyDebugger/NSObject+PDRuntimePropertyDescriptor.h
+100 −64 ObjC/PonyDebugger/NSObject+PDRuntimePropertyDescriptor.m
+22 −0 ObjC/PonyDebugger/NSOrderedSet+PDRuntimePropertyDescriptor.h
+105 −0 ObjC/PonyDebugger/NSOrderedSet+PDRuntimePropertyDescriptor.m
+9 −18 ObjC/PonyDebugger/NSSet+PDRuntimePropertyDescriptor.h
+119 −0 ObjC/PonyDebugger/NSSet+PDRuntimePropertyDescriptor.m
+0 −191 ObjC/PonyDebugger/PDArrayContainer.m
+24 −0 ObjC/PonyDebugger/PDConsoleDomainController.h
+112 −0 ObjC/PonyDebugger/PDConsoleDomainController.m
+25 −0 ObjC/PonyDebugger/PDContainerIndex.h
+34 −0 ObjC/PonyDebugger/PDContainerIndex.m
+111 −37 ObjC/PonyDebugger/PDDOMDomainController.m
+32 −13 ObjC/PonyDebugger/PDDebugger.h
+43 −15 ObjC/PonyDebugger/PDDebugger.m
+3 −0 ObjC/PonyDebugger/PDDefinitions.h
+33 −2 ObjC/PonyDebugger/PDDefinitions.m
+12 −1 ObjC/PonyDebugger/PDIndexedDBDomainController.m
+17 −0 ObjC/PonyDebugger/PDNetworkDomainController.h
+584 −82 ObjC/PonyDebugger/PDNetworkDomainController.m
+3 −13 ObjC/PonyDebugger/PDObject.h
+36 −0 ObjC/PonyDebugger/PDPrettyStringPrinter.h
+145 −0 ObjC/PonyDebugger/PDPrettyStringPrinter.m
+1 −0 ObjC/PonyDebugger/PDRuntimeDomainController.h
+19 −0 ObjC/PonyDebugger/PDRuntimeDomainController.m
+1 −1 ObjC/SocketRocket
+16 −0 PonyDebugger.podspec
+169 −39 README.md
+1 −1 ponyd/gateway.py
+1 −1 scripts/_bootstrap_contents.py
1 change: 1 addition & 0 deletions PonyDebuggerInjected.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ Filter = { Bundles = ("com.apple.UIKit"); }; }
154 changes: 22 additions & 132 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ PonyDebuggerInjected

PonyDebugger is a great remote debugging toolset. It is a client library and gateway server combination that uses Chrome Developer Tools on your browser to debug your application's network traffic, view tree, core data objects, etc.

One of the limitations of PonyDebugger is that one must implement the client functionality in project's source code and connect it to the gateway server. But what if you wanted to use PonyDebugger to get a peek on how other applications are built, inspect view tree hierarchy, get access to runtime objects and Core Data entities for the purpose of security/penetration testing or just for curiosity sake?
One of the limitations of PonyDebugger is that one must implement the client functionality in project's source code and connect it to the gateway server. But what if you wanted to use PonyDebugger to get a peek on how other applications are built, inspect view tree hierarchy, get access to runtime objects, Core Data entities, inspect networks calls, etc.

Here is where PonyDebuggerInjected comes in to play.

PonyDebuggerInjected is a MobileSubstrate extension, which can be used as a blackbox tool to inject PonyDebugger client library into running iOS Apps on a jailbroken iOS device. This allows one to use Chrome Developer Tools/PonyDebugger in your browser to inspect how applications are built, debug applications network traffic, managed object contexts, etc. For more info on PonyDebugger see https://github.com/square/PonyDebugger
PonyDebuggerInjected is a MobileSubstrate extension, which can be used to inject PonyDebugger client library into running iOS Apps on a jailbroken iOS device. This allows one to use Chrome Developer Tools/PonyDebugger in your browser to inspect how applications are built, debug applications network traffic, managed object contexts, etc. For more info on PonyDebugger see https://github.com/square/PonyDebugger

Installation
------------

Most users should download the pre-compiled Debian package available at:
https://www.dropbox.com/s/geh03hpwjnaqggw/com.open.PonyDebuggerInjected_1.0-1_iphoneos-arm.deb
Most users should download the pre-compiled Debian package available under Releases.

### Dependencies

PonyDebuggerInjected was tested on iOS 6.01 and 5.0. A jailbroken device
PonyDebugger Injected was tested on iOS 8.1, but it should work on other iOS versions too. A jailbroken device
is required. Using Cydia make sure the following packages are installed:
- dpkg
- MobileSubstrate
Expand All @@ -28,157 +27,48 @@ Additionally, PonyDebugger Gateway Server must be installed and running on the c

### How to install

Most users should first download the latest pre-compiled Debian package available in the release section of the project page at: https://github.com/dtrukr/PonyDebuggerInjected/releases

The tool was tested on iOS8 running on an iPhone 5S.

Download and copy the Debian package to the device; install it:

dpkg -i com.open.PonyDebuggerInjected_1.0-1_iphoneos-arm.deb
dpkg -i com.daapps.ponydebuggerinjected_0.0.1-1-2_iphoneos-arm.deb

Respring the device:

killall -HUP SpringBoard

There should be a new menu in the device's Settings where you can
enable the extension and set the server address (for example 192.168.0.3:9000).
enable the extension:

![Settings](http://biudvikling.dk/images/ponydebugger/Injected_Settings.png)
![Settings](Screenshots/Settings1.png)

Finally, start / restart the App you want to test and open PonyDebugger Server URL in your Chrome browser (http://localhost:9000 by default).

Once the an app is started we can connect to PonyDebugger and inspect the app:
![Settings Pony Debugger Injected](Screenshots/Settings2.png)

![App Inspection](http://biudvikling.dk/images/ponydebugger/pony1-small.png)
![Calculator inside PonyDebugger](Screenshots/Calculator.png)

### How to uninstall

dpkg -r com.open.ponydebuggerinjected
dpkg -r com.daapps.ponydebuggerinjected


Build
-----

Most users should just download and install the Debian package.
The build requires the iOSOpenDev suite to be installed; see http://iosopendev.com/download/
Once installed, clone this repository, do submodule init/update, open and build the included xcodeproj file.


## PonyDebugger Standard Features

The following PonyDebugger features can be used for debugging 3rd party apps injected using PonyDebuggerInjected:

- View Hierarchy Debugging
- Network Traffic Debugging
- Core Data Browser

## PonyDebugger Extensions for Advanced Debugging

The following extensions are currently a work in progress / not available in public branch.

# Runtime Object Browser

This extension is built upon https://github.com/nst/RuntimeBrowser project and gives you access to all classes loaded in the runtime, shows every method implemented on each class and displays information in a header (.h) file format.

![Runtime Object Browser](http://biudvikling.dk/images/ponydebugger/pony-objects.png)

Header view:

![Runtime Object Browser - Header View](http://biudvikling.dk/images/ponydebugger/pony-source.png)

# Cycript Console

This extension is built upon http://www.cycript.org project and acts as a bridge between Objective-C runtime and Javascript console allowing one to run arbitrary code inside injected application context. Code typed in the console will be immediately executed inside application context and result returned back to the console.

Here is an example how to get current view controller and change title:

![Cycript console](http://biudvikling.dk/images/ponydebugger/screenshot-cycript.jpg)

![Cycript result](http://biudvikling.dk/images/ponydebugger/iphone2-new-small.png)

# Objective-C objc_msgSend Logger

This extension is built upon Subjective-C project (http://networkpx.blogspot.dk/2009/09/introducing-subjective-c.html) which allow you to log all objc_msgSend calls in order to understand how the code application code works from within.
The extension can be enabled usign Record/Stop button and logs all objc_msgSend calls (in a nice call tree), including all arguments, and the return value.

Here is an example of what happens after tapping an UIButton:

![Objective-C objc_msgSend Logger](http://biudvikling.dk/images/ponydebugger/pony-capturestack.png)

# CCCrypt API Logging

This extension is built upon hooking into CCCrypt* functions for the purpose of capturing all calls to symmetric encryption algorithms that your application uses. This can be helpful to determine whether the encryption keys are hardcoded inside the application.

This is implemented by creating an MSHookFunction hook to the appropriate CCCrypt API functions:

static CCCryptorStatus (*old_CCCryptorCreate)(
CCOperation op, /* kCCEncrypt, etc. */
CCAlgorithm alg, /* kCCAlgorithmDES, etc. */
CCOptions options, /* kCCOptionPKCS7Padding, etc. */
const void *key, /* raw key material */
size_t keyLength,
const void *iv, /* optional initialization vector */
CCCryptorRef *cryptorRef);
CCCryptorStatus hk_CCCryptorCreate(
CCOperation op, /* kCCEncrypt, etc. */
CCAlgorithm alg, /* kCCAlgorithmDES, etc. */
CCOptions options, /* kCCOptionPKCS7Padding, etc. */
const void *key, /* raw key material */
size_t keyLength,
const void *iv, /* optional initialization vector */
CCCryptorRef *cryptorRef) /* RETURNED */
{
NSString *_operation;
if(op == kCCEncrypt) _operation = @"kCCEncrypt";
else if (op == kCCDecrypt) _operation = @"kCCDecrypt";
NSString *_algorithm;
if(alg == kCCAlgorithmAES128) _algorithm = @"kCCAlgorithmAES128";
else if(alg == kCCAlgorithmDES) _algorithm = @"kCCAlgorithmDES";
else if(alg == kCCAlgorithm3DES) _algorithm = @"kCCAlgorithm3DES";
else if(alg == kCCAlgorithmCAST) _algorithm = @"kCCAlgorithmCAST";
else if(alg == kCCAlgorithmRC4) _algorithm = @"kCCAlgorithmRC4";
else if(alg == kCCAlgorithmRC2) _algorithm = @"kCCAlgorithmRC2";
else if(alg == kCCAlgorithmBlowfish) _algorithm = @"kCCAlgorithmBlowfish";
else _algorithm = @"Unknown";
NSString *_options;
if(options == kCCOptionPKCS7Padding) _options = @"kCCOptionPKCS7Padding";
else if(options == kCCOptionECBMode) _options = @"kCCOptionECBMode";
else _options = @"Unknown";
[[PDDebuggerdefaultInstance] writeToConsole:[NSStringstringWithFormat:@"CryptoDebug2> CCCryptCreate(Operation: %@, Algorithm: %@, Options: %@, Key: %s, Vector: %s, Key Length: %ld)", _operation, _algorithm, _options, key, iv, keyLength]];
return old_CCCryptorCreate(op,alg,options,key,keyLength,iv,cryptorRef);
}


Let's consider that we have the following code in our application:

NSString *key =@"YourKey";
char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero( keyPtr, sizeof(keyPtr) ); // fill with zeroes (for padding)
// fetch key data
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
char *dataIn = "This is your data";
char dataOut[500];// set it acc ur data
bzero(dataOut, sizeof(dataOut));
size_t numBytesEncrypted = 0;
CCCryptorStatus result = CCCrypt(kCCEncrypt, kCCAlgorithmAES128,kCCOptionPKCS7Padding, keyPtr,kCCKeySizeAES256, NULL, dataIn, strlen(dataIn), dataOut, sizeof(dataOut), &numBytesEncrypted);
The build requires the Theos suite to be installed;
see http://www.iphonedevwiki.net/index.php/Theos/Getting_Started .
You first have to create a symlink to your theos installation:


Here is what happens when such a call gets captured by PonyDebuggerInjected - as you can see there is both encryption key/vector and data visible:

![CCCrypt API](http://biudvikling.dk/images/ponydebugger/pony-key.png)
ln -s /opt/theos/ theos

Make sure dpkg is installed. If you have Homebrew, use:

License
-------

PonyDebuggerInjected is licensed under the Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).
brew install dpkg

Then, the package can be built using:

make package
Binary file added Screenshots/Calculator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Settings1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/Settings2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions Tweak.xm
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#import <dlfcn.h>
#import <UIKit/UIKit.h>
#include <notify.h>
#include <objc/message.h>
#import <PonyDebugger/PDDebugger.h>

__attribute__((visibility("hidden")))
@interface PonyDebuggerInjected : NSObject {
@private
}
@end

#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/PonyDebuggerInjectedBundle.bundle"

@implementation PonyDebuggerInjected

+ (instancetype)sharedInstance
{
static PonyDebuggerInjected *_sharedFactory;
static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{
_sharedFactory = [[self alloc] init];
});

return _sharedFactory;
}

- (id)init
{
if ((self = [super init]))
{

}
return self;
}

-(void)inject {

NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.daapps.PonyDebuggerInjected.plist"];
id setting = [settings objectForKey:[NSString stringWithFormat:@"PonyDebuggerInjectedEnabled-%@", [NSBundle mainBundle].bundleIdentifier]];
if (setting && [setting boolValue]) {

PDDebugger *debugger = [PDDebugger defaultInstance];

// Enable Network debugging, and automatically track network traffic that comes through any classes that NSURLConnectionDelegate methods.
[debugger enableNetworkTrafficDebugging];
[debugger forwardAllNetworkTraffic];

// Enable Core Data debugging, and broadcast the main managed object context.
[debugger enableCoreDataDebugging];
[self performSelector:@selector(attachToCoreData) withObject:nil afterDelay:1.0];

// Enable View Hierarchy debugging. This will swizzle UIView methods to monitor changes in the hierarchy
// Choose a few UIView key paths to display as attributes of the dom nodes
[debugger enableViewHierarchyDebugging];
[debugger setDisplayedViewAttributeKeyPaths:@[@"frame", @"hidden", @"alpha", @"opaque"]];

// Connect to a specific host
[debugger autoConnect];

}

}

-(void)attachToCoreData {

PDDebugger *debugger = [PDDebugger defaultInstance];

id app = (id)[UIApplication sharedApplication];
if(app != nil)
{

id appDelegate = (id)[app delegate];
if(appDelegate !=nil && [appDelegate respondsToSelector:@selector(managedObjectContext)]) {
id ctx = [appDelegate managedObjectContext];

if(ctx != nil) {

[debugger addManagedObjectContext:ctx withName:@"Application Context"];
NSLog(@"Adding application context to Core Data debugging");

} else {
NSLog(@"** There is no UIApplication Delegate Managed Context for Core Data");
}

} else {
NSLog(@"** There is no UIApplication Delegate for Core Data or the delegate does not respond to managedObjectContext selector");
}

} else {
NSLog(@"** There is no UIApplication for Core Data");
}

}

@end


%ctor {

[[NSNotificationCenter defaultCenter] addObserver:[PonyDebuggerInjected sharedInstance] selector:@selector(inject) name:UIApplicationDidFinishLaunchingNotification object:nil];

}
9 changes: 9 additions & 0 deletions layout/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: com.daapps.ponydebuggerinjected
Name: PonyDebuggerInjected
Depends: firmware (>= 6), mobilesubstrate, preferenceloader (>= 2.2), applist (>= 1.5.3)
Architecture: iphoneos-arm
Description: Injection library that allows inspection of 3rd party apps with PonyDebugger app
Maintainer: Den
Author: Den
Section: Development
Version: 0.0.1-1
2 changes: 2 additions & 0 deletions layout/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
killall -HUP SpringBoard
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
entry = {
bundle = AppList;
cell = PSLinkCell;
icon = "/Library/PreferenceLoader/Preferences/PonyDebuggerInjected.png";
isController = 1;
label = PonyDebuggerInjected;
ALSettingsPath = "/var/mobile/Library/Preferences/com.daapps.PonyDebuggerInjected.plist";
ALSettingsKeyPrefix = "PonyDebuggerInjectedEnabled-";
ALChangeNotification = "com.daapps.PonyDebuggerInjected.settingschanged";
ALSettingsDefaultValue = 0;
ALSectionDescriptors = (
{
title = "System Applications";
predicate = "(isSystemApplication = TRUE)";
"cell-class-name" = "ALSwitchCell";
"icon-size" = 29;
"suppress-hidden-apps" = 1;
},
{
title = "User Applications";
predicate = "(isSystemApplication = FALSE)";
"cell-class-name" = "ALSwitchCell";
"icon-size" = 29;
"suppress-hidden-apps" = 1;
"footer-title" = "© 2010-2013 Dennis Torbichuk\n© 2013 Square Inc.";
}
);
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 03a78a2

Please sign in to comment.