main.x 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #import <Foundation/Foundation.h>
  2. #include <mach-o/dyld.h>
  3. #import <objc/runtime.h>
  4. %class LSContext
  5. %class FSNode
  6. id (*original_func2)();
  7. id (*original_func3)();
  8. /*
  9. Build = Build;
  10. FullVersionString = "Version 10.2.2 (Build 14W756)";
  11. MarketingVersion = "10.2.2";
  12. ProductBuildVersion = 14W756;
  13. ProductCopyright = "1983-2017 Apple Inc.";
  14. ProductName = "Apple TVOS";
  15. ProductVersion = "10.2.2";
  16. Version = Version;
  17. */
  18. id serverversiondict()
  19. {
  20. NSLog(@"called server version!");
  21. //NSArray *callStack = [NSThread callStackSymbols];
  22. //NSLog(@"callstack: %@", callStack);
  23. id retv = original_func3();
  24. NSMutableDictionary *a = [retv mutableCopy];
  25. a[@"MarketingVersion"] = @"11.1";
  26. a[@"ProductVersion"] = @"11.1";
  27. a[@"ProductBuildVersion"] = @"15J582";
  28. NSLog(@"og deets: %@", retv);
  29. NSLog(@"new g: %@", a);
  30. return retv;
  31. }
  32. id systemversiondict()
  33. {
  34. NSLog(@"called system version!");
  35. //NSArray *callStack = [NSThread callStackSymbols];
  36. //NSLog(@"callstack: %@", callStack);
  37. id retv = original_func2();
  38. //NSMutableDictionary *a = [retv mutableCopy];
  39. //a[@"MarketingVersion"] = @"11.1";
  40. //a[@"ProductVersion"] = @"11.1";
  41. //a[@"ProductBuildVersion"] = @"15J582";
  42. //NSLog(@"og deets: %@", retv);
  43. //NSLog(@"new g: %@", a);
  44. return retv;
  45. }
  46. id (*original_func)(id a);
  47. //hook for _MobileInstallationCopyInstalledAppsForLaunchServices
  48. id we_really_out_here(id a)
  49. {
  50. HBLogInfo(@"#### EXCEPTION CATCHER FOUND UNCAUGHT EXCEPTION: %@", a);
  51. NSLog(@"#### EXCEPTION CATCHER FOUND UNCAUGHT EXCEPTION: %@", a);
  52. id retv = original_func(a);
  53. NSLog(@"retv: %@", retv);
  54. return retv;
  55. }
  56. %ctor
  57. {
  58. dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
  59. MSImageRef gangshit = MSGetImageByName("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation");
  60. if (gangshit != NULL)
  61. {
  62. NSLog(@"cf loaded!");
  63. }
  64. //tvos 10 symbol
  65. void* weouthere = MSFindSymbol(gangshit, "___handleUncaughtException");
  66. NSLog(@"CoreFoundation tvOS 10 hooking %p", weouthere);
  67. if (weouthere)
  68. {
  69. NSLog(@"Found symbol!");
  70. MSHookFunction((void*)weouthere, (void*)we_really_out_here, (void**)&original_func);
  71. }
  72. /*
  73. void* weouthere2 = MSFindSymbol(gangshit, "__CFCopySystemVersionDictionary");
  74. NSLog(@"CF hooking _CFCopySystemVersionDictionary: %p", weouthere2);
  75. if (weouthere2)
  76. {
  77. NSLog(@"Found _CFCopySystemVersionDictionary!");
  78. MSHookFunction((void*) weouthere2, (void*)systemversiondict, (void**)&original_func2);
  79. }
  80. void* weouthere3 = MSFindSymbol(gangshit, "__CFCopyServerVersionDictionary");
  81. NSLog(@"CF hooking _CFCopyServerVersionDictionary: %p", weouthere2);
  82. if (weouthere3)
  83. {
  84. NSLog(@"Found _CFCopyServerVersionDictionary!");
  85. MSHookFunction((void*) weouthere3, (void*)serverversiondict, (void**)&original_func3);
  86. }
  87. */
  88. }