Browse Source

added uncaught notification hooker

Kevin Bradley 6 years ago
parent
commit
d30f3e0545
5 changed files with 161 additions and 0 deletions
  1. 12 0
      Hopperh4x/Hopperh4x.plist
  2. 18 0
      Hopperh4x/Makefile
  3. 10 0
      Hopperh4x/control
  4. 117 0
      Hopperh4x/main.x
  5. 4 0
      Makefile

+ 12 - 0
Hopperh4x/Hopperh4x.plist

@@ -0,0 +1,12 @@
+{
+	Filter = {
+		Bundles = (
+			"com.apple.CoreFoundation",
+			"com.netflix.Netflix",
+			"com.apple.UIKit",
+			"com.apple.TVAppStore",
+			"com.apple.ITMLKit",
+			"com.hulu.plus",
+		);
+	};
+}

+ 18 - 0
Hopperh4x/Makefile

@@ -0,0 +1,18 @@
+ARCHS = arm64
+TARGET = appletv
+export GO_EASY_ON_ME=1
+export SDKVERSION=10.2
+THEOS_DEVICE_IP=apple-tv.local
+
+include $(THEOS)/makefiles/common.mk
+
+TWEAK_NAME = Hopperh4x
+Hopperh4x_FILES = main.x
+Hopperh4x_LIBRARIES = substrate
+Hopperh4x_FRAMEWORKS = Foundation UIKit CoreGraphics MobileCoreServices
+Hopperh4x_LDFLAGS = -undefined dynamic_lookup
+
+include $(THEOS_MAKE_PATH)/tweak.mk
+
+after-install::
+	install.exec "killall -9 lsd"

+ 10 - 0
Hopperh4x/control

@@ -0,0 +1,10 @@
+Package: com.h4x.exceptioncatcher
+Name: exception catcher
+Pre-Depends: cy+model.appletv
+Depends: mobilesubstrate
+Version: 0.0.1
+Architecture: appletvos-arm64
+Description: Caught uncaught exceptions, helpeful for backporting apps
+Maintainer: Kevin Bradley
+Author: Kevin Bradley
+Section: Library

+ 117 - 0
Hopperh4x/main.x

@@ -0,0 +1,117 @@
+
+
+#import <Foundation/Foundation.h>
+#include <mach-o/dyld.h>
+#import <objc/runtime.h>
+
+%class LSContext
+%class FSNode
+
+
+id (*original_func2)();
+id (*original_func3)();
+/*
+
+Build = Build;
+FullVersionString = "Version 10.2.2 (Build 14W756)";
+MarketingVersion = "10.2.2";
+ProductBuildVersion = 14W756;
+ProductCopyright = "1983-2017 Apple Inc.";
+ProductName = "Apple TVOS";
+ProductVersion = "10.2.2";
+Version = Version;
+
+*/
+
+id serverversiondict()
+{
+    NSLog(@"called server version!");
+    //NSArray *callStack = [NSThread callStackSymbols];
+    //NSLog(@"callstack: %@", callStack);
+    id retv = original_func3();
+    NSMutableDictionary *a = [retv mutableCopy];
+    a[@"MarketingVersion"] = @"11.1";
+    a[@"ProductVersion"] = @"11.1";
+    a[@"ProductBuildVersion"] = @"15J582";
+    NSLog(@"og deets: %@", retv);
+    NSLog(@"new g: %@", a);
+    return retv;
+}
+
+id systemversiondict()
+{
+     NSLog(@"called system version!");
+     //NSArray *callStack = [NSThread callStackSymbols];
+     //NSLog(@"callstack: %@", callStack);
+     id retv = original_func2();
+     //NSMutableDictionary *a = [retv mutableCopy];
+     //a[@"MarketingVersion"] = @"11.1";
+     //a[@"ProductVersion"] = @"11.1";
+     //a[@"ProductBuildVersion"] = @"15J582";
+     //NSLog(@"og deets: %@", retv);
+     //NSLog(@"new g: %@", a);
+     return retv;
+}
+
+
+id (*original_func)(id a);
+
+//hook for _MobileInstallationCopyInstalledAppsForLaunchServices
+
+id we_really_out_here(id a)
+{
+NSLog(@"#### EXCEPTION CATCHER FOUND UNCAUGHT EXCEPTION: %@", a);
+    id retv = original_func(a);
+    NSLog(@"retv: %@", retv);
+    return retv;
+}
+
+
+
+%ctor
+{
+	dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
+	
+	MSImageRef gangshit = MSGetImageByName("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation");
+    if (gangshit != NULL)
+    {
+        NSLog(@"cf loaded!");
+    }
+    //tvos 10 symbol
+	void* weouthere = MSFindSymbol(gangshit, "___handleUncaughtException");
+	NSLog(@"CoreFoundation tvOS 10 hooking %p", weouthere);
+
+	if (weouthere)
+	{
+        NSLog(@"Found symbol!");
+		MSHookFunction((void*)weouthere, (void*)we_really_out_here, (void**)&original_func);
+
+	}
+
+
+	/*
+	void* weouthere2 = MSFindSymbol(gangshit, "__CFCopySystemVersionDictionary");
+	NSLog(@"CF hooking _CFCopySystemVersionDictionary: %p", weouthere2);
+
+
+	if (weouthere2)
+	{
+        	NSLog(@"Found _CFCopySystemVersionDictionary!");
+		MSHookFunction((void*) weouthere2, (void*)systemversiondict, (void**)&original_func2);
+
+	}
+
+    void* weouthere3 = MSFindSymbol(gangshit, "__CFCopyServerVersionDictionary");
+    NSLog(@"CF hooking _CFCopyServerVersionDictionary: %p", weouthere2);
+
+
+    if (weouthere3)
+    {
+        NSLog(@"Found _CFCopyServerVersionDictionary!");
+        MSHookFunction((void*) weouthere3, (void*)serverversiondict, (void**)&original_func3);
+
+    }
+*/
+
+    
+} 

+ 4 - 0
Makefile

@@ -16,6 +16,10 @@ export ARCHS = arm64
 DalesDeadBug_ARCHS = arm64
 
 include $(THEOS_MAKE_PATH)/tweak.mk
+
+#comment in to install our uncaught notification hooker
+#SUBPROJECTS += Hopperh4x
+#include $(THEOS_MAKE_PATH)/aggregate.mk
 	
 all::