Skip to content

Commit

Permalink
Changes to string comparisons of file paths to be more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Kc57 committed Sep 3, 2021
1 parent 84fae1f commit 63af81c
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 94 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include $(THEOS)/makefiles/common.mk

TWEAK_NAME = ihide

ihide_FILES = Tweak.x src/utility.c
ihide_FILES = Tweak.x src/utility.c src/objcutils.m
ihide_CFLAGS = -fobjc-arc

include $(THEOS_MAKE_PATH)/tweak.mk
Expand Down
98 changes: 6 additions & 92 deletions Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <spawn.h>
#include "include/cfuncs.h"
#include "include/utility.h"
#import "include/objcutils.h"

#define _PLIST @"/var/mobile/Library/Preferences/com.kc57.ihideprefs.plist"
#define pref_getValue(key) [[NSDictionary dictionaryWithContentsOfFile:_PLIST] valueForKey:key]
Expand Down Expand Up @@ -87,98 +88,11 @@ static NSString *nsNotificationString = @"com.kc57.ihideprefs/settingschanged";

%hook NSFileManager
- (BOOL)fileExistsAtPath:(NSString *)path {
NSArray *common_paths = [NSArray arrayWithObjects:
@"/.bootstrapped_electra",
@"/.cydia_no_stash",
@"/.installed_unc0ver",
@"/Applications/blackra1n.app",
@"/Applications/Cydia.app",
@"/Applications/FakeCarrier.app",
@"/Applications/Filza.app",
@"/Applications/Icy.app",
@"/Applications/IntelliScreen.app",
@"/Applications/MxTube.app",
@"/Applications/RockApp.app",
@"/Applications/SBSettings.app",
@"/Applications/SBSetttings.app",
@"/Applications/Sileo.app",
@"/Applications/Snoop-itConfig.app",
@"/Applications/TrustMe.app",
@"/Applications/WinterBoard.app",
@"/bin/bash",
@"/bin/sh",
@"/etc/apt",
@"/etc/apt/sources.list.d/electra.list",
@"/etc/apt/sources.list.d/sileo.sources",
@"/etc/apt/undecimus/undecimus.list",
@"/etc/ssh/sshd_config",
@"/jb/amfid_payload.dylib",
@"/jb/jailbreakd.plist",
@"/jb/libjailbreak.dylib",
@"/jb/lzma",
@"/jb/offsets.plist",
@"/Library/MobileSubstrate/CydiaSubstrate.dylib",
@"/Library/MobileSubstrate/DynamicLibraries/Liberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist",
@"/Library/MobileSubstrate/DynamicLibraries/Veency.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzzLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzzzLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzzzzLiberty.plist",
@"/Library/MobileSubstrate/MobileSubstrate.dylib",
@"/Library/PreferenceBundles/ABypassPrefs.bundle",
@"/Library/PreferenceBundles/FlyJBPrefs.bundle",
@"/Library/PreferenceBundles/LibertyPref.bundle",
@"/Library/PreferenceBundles/ShadowPreferences.bundle",
@"/private/etc/apt",
@"/private/etc/dpkg/origins/debian",
@"/private/etc/ssh/sshd_config",
@"/private/var/cache/apt/",
@"/private/var/lib/apt",
@"/private/var/lib/cydia",
@"/private/var/log/syslog",
@"/private/var/mobile/Library/SBSettings/Themes",
@"/private/var/stash",
@"/private/var/tmp/cydia.log",
@"/private/var/Users/",
@"/System/Library/LaunchDaemons/com.ikey.bbot.plist",
@"/System/Library/LaunchDaemons/[email protected]",
@"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist",
@"/usr/bin/cycript",
@"/usr/bin/ssh",
@"/usr/bin/sshd",
@"/usr/libexec/cydia",
@"/usr/libexec/cydia/firmware.sh",
@"/usr/libexec/sftp-server",
@"/usr/libexec/ssh-keysign",
@"/usr/lib/libcycript.dylib",
@"/usr/lib/libhooker.dylib",
@"/usr/lib/libjailbreak.dylib",
@"/usr/lib/libsubstitute.dylib",
@"/usr/lib/substrate",
@"/usr/lib/TweakInject",
@"/usr/local/bin/cycript",
@"/usr/sbin/frida-server",
@"/usr/sbin/sshd",
@"/usr/share/jailbreak/injectme.plist",
@"/var/binpack",
@"/var/cache/apt",
@"/var/checkra1n.dmg",
@"/var/lib/apt",
@"/var/lib/cydia",
@"/var/lib/dpkg/info/mobilesubstrate.md5sums",
@"/var/log/apt",
@"/var/log/syslog",
@"/var/tmp/cydia.log",
nil];

for(NSString *str in common_paths) {
if ([path isEqualToString:str]) {
NSLog(@"[iHide] Hooked fileExistsAtPath -> %@", str);
NSLog(@"[iHide] Patching fileExistsAtPath return: NO");
return NO;
}

if (objc_isKnownBadPath(path)) {
NSLog(@"[iHide] Hooked fileExistsAtPath -> %@", path);
NSLog(@"[iHide] Patching fileExistsAtPath return: NO");
return NO;
}

// If we didn't find any file checks we care about, return the original value
Expand Down
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: com.kc57.ihide
Name: iHide
Version: 1.0.0
Version: 1.0.1
Architecture: iphoneos-arm
Description: Utility for hiding jailbreak from applications
Maintainer: Rob Simon (@_Kc57)
Expand Down
3 changes: 3 additions & 0 deletions include/objcutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#import <Foundation/Foundation.h>

bool objc_isKnownBadPath(NSString *path);
106 changes: 106 additions & 0 deletions src/objcutils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#import "../include/objcutils.h"

bool objc_isKnownBadPath(NSString *path) {
NSArray *bad_paths = [NSArray arrayWithObjects:
@"/.bootstrapped_electra",
@"/.cydia_no_stash",
@"/.installed_unc0ver",
@"/Applications/blackra1n.app",
@"/Applications/Cydia.app",
@"/Applications/FakeCarrier.app",
@"/Applications/Filza.app",
@"/Applications/Icy.app",
@"/Applications/IntelliScreen.app",
@"/Applications/MxTube.app",
@"/Applications/RockApp.app",
@"/Applications/SBSettings.app",
@"/Applications/SBSetttings.app",
@"/Applications/Sileo.app",
@"/Applications/Snoop-itConfig.app",
@"/Applications/TrustMe.app",
@"/Applications/WinterBoard.app",
@"/bin/bash",
@"/bin/sh",
@"/etc/apt",
@"/etc/apt/sources.list.d/electra.list",
@"/etc/apt/sources.list.d/sileo.sources",
@"/etc/apt/undecimus/undecimus.list",
@"/etc/ssh/sshd_config",
@"/jb/amfid_payload.dylib",
@"/jb/jailbreakd.plist",
@"/jb/libjailbreak.dylib",
@"/jb/lzma",
@"/jb/offsets.plist",
@"/Library/MobileSubstrate/CydiaSubstrate.dylib",
@"/Library/MobileSubstrate/DynamicLibraries/Liberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist",
@"/Library/MobileSubstrate/DynamicLibraries/Veency.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzzLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzzzLiberty.plist",
@"/Library/MobileSubstrate/DynamicLibraries/zzzzzLiberty.plist",
@"/Library/MobileSubstrate/MobileSubstrate.dylib",
@"/Library/PreferenceBundles/ABypassPrefs.bundle",
@"/Library/PreferenceBundles/FlyJBPrefs.bundle",
@"/Library/PreferenceBundles/LibertyPref.bundle",
@"/Library/PreferenceBundles/ShadowPreferences.bundle",
@"/private/etc/apt",
@"/private/etc/dpkg/origins/debian",
@"/private/etc/ssh/sshd_config",
@"/private/var/cache/apt",
@"/private/var/lib/apt",
@"/private/var/lib/cydia",
@"/private/var/log/syslog",
@"/private/var/mobile/Library/SBSettings/Themes",
@"/private/var/stash",
@"/private/var/tmp/cydia.log",
@"/private/var/Users",
@"/System/Library/LaunchDaemons/com.ikey.bbot.plist",
@"/System/Library/LaunchDaemons/[email protected]",
@"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist",
@"/usr/bin/cycript",
@"/usr/bin/ssh",
@"/usr/bin/sshd",
@"/usr/libexec/cydia",
@"/usr/libexec/cydia/firmware.sh",
@"/usr/libexec/sftp-server",
@"/usr/libexec/ssh-keysign",
@"/usr/lib/libcycript.dylib",
@"/usr/lib/libhooker.dylib",
@"/usr/lib/libjailbreak.dylib",
@"/usr/lib/libsubstitute.dylib",
@"/usr/lib/substrate",
@"/usr/lib/TweakInject",
@"/usr/local/bin/cycript",
@"/usr/sbin/frida-server",
@"/usr/sbin/sshd",
@"/usr/share/jailbreak/injectme.plist",
@"/var/binpack",
@"/var/cache/apt",
@"/var/checkra1n.dmg",
@"/var/lib/apt",
@"/var/lib/cydia",
@"/var/lib/dpkg/info/mobilesubstrate.md5sums",
@"/var/log/apt",
@"/var/log/syslog",
@"/var/tmp/cydia.log",
nil];
for(NSString *str in bad_paths) {
NSString *strParam = path;
if([strParam hasSuffix:@"/"]) {
// Remove trailing '/'
strParam = [strParam substringToIndex:[strParam length]-1];
}
// do a case insensitive comparison against the paths
if( [str caseInsensitiveCompare:strParam] == NSOrderedSame ) {
//NSLog(@"[iHide] Hooked fileExistsAtPath -> %@", str);
//NSLog(@"[iHide] Patching fileExistsAtPath return: NO");
return true;
}
}

// default return if we don't match any paths
return false;

}

0 comments on commit 63af81c

Please sign in to comment.