Last active
February 19, 2017 07:29
-
-
Save juslee/a8a01be071d5111f21a0fb399683f2b1 to your computer and use it in GitHub Desktop.
iOS Jailbreak Checking Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// jailbreakcheck.h | |
// scbPhone | |
// | |
#ifndef jailbreakcheck_h | |
#define jailbreakcheck_h | |
@interface JailbreakCheck : NSObject | |
+ (BOOL)isDeviceJailbroken; | |
@end | |
#endif /* jailbreakcheck_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// jailbreakcheck.m | |
// scbPhone | |
// | |
// Reference: | |
// https://www.trustwave.com/Resources/SpiderLabs-Blog/Jailbreak-Detection-Methods/ | |
#import <Foundation/Foundation.h> | |
#import "JailbreakCheck.h" | |
#import "LOOCryptString.h" | |
// Defines | |
#define FORCE_INLINE inline __attribute__((always_inline)) | |
// Jailbreak checks | |
#import <sys/stat.h> | |
#import <arpa/inet.h> | |
#import <mach-o/dyld.h> | |
// Inline functions | |
FORCE_INLINE BOOL checkJailbreakSymlinks(); | |
FORCE_INLINE BOOL checkJailbreakSymLink(NSString *checkPath); | |
FORCE_INLINE BOOL checkJailbreakFiles(); | |
FORCE_INLINE BOOL checkJailbreakFile(NSString *checkPath); | |
FORCE_INLINE BOOL checkReadWritePermissions(); | |
FORCE_INLINE BOOL checkSandbox(); | |
FORCE_INLINE BOOL checkPortOpen(short port); | |
FORCE_INLINE BOOL checkCydiaScheme(); | |
FORCE_INLINE BOOL checkForInjection(); | |
@implementation JailbreakCheck | |
+(BOOL)isDeviceJailbroken { | |
return checkJailbreakFiles() // 1a | |
|| checkRootPermissions() // 1b (1c shouldn't implement) | |
|| checkJailbreakSymlinks() // 1d | |
|| checkReadWritePermissions() // 1e | |
|| checkSandbox() // 2a 2b (2c obsolete) | |
|| checkForInjection() // 2d | |
|| checkPortOpen(22) // 3 | |
|| checkCydiaScheme(); // 4 | |
} | |
#pragma mark - Jailbreak checks | |
BOOL checkJailbreakFiles() | |
{ | |
NSArray *fileChecks = @[LOO_CRYPT_STR_N("/private/var/stash", 18), | |
LOO_CRYPT_STR_N("/private/var/lib/apt", 20), | |
LOO_CRYPT_STR_N("/private/var/tmp/cydia.log", 26), | |
LOO_CRYPT_STR_N("/private/var/mobile/Library/SBSettings/Themes", 45), | |
LOO_CRYPT_STR_N("/Library/MobileSubstrate/MobileSubstrate.dylib", 46), | |
LOO_CRYPT_STR_N("/Library/MobileSubstrate/DynamicLibraries/Veency.plist", 54), | |
LOO_CRYPT_STR_N("/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist", 57), | |
LOO_CRYPT_STR_N("/System/Library/LaunchDaemons/com.ikey.bbot.plist", 49), | |
LOO_CRYPT_STR_N("/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist", 60), | |
LOO_CRYPT_STR_N("/var/cache/apt", 14), | |
LOO_CRYPT_STR_N("/var/lib/apt", 12), | |
LOO_CRYPT_STR_N("/var/log/syslog", 15), | |
LOO_CRYPT_STR_N("/var/tmp/cydia.log", 18), | |
LOO_CRYPT_STR_N("/usr/bin/sshd", 13), | |
LOO_CRYPT_STR_N("/etc/apt", 8), | |
#if !(TARGET_OS_SIMULATOR) | |
LOO_CRYPT_STR_N("/bin/bash", 9), | |
LOO_CRYPT_STR_N("/usr/sbin/sshd", 14), | |
LOO_CRYPT_STR_N("/usr/libexec/ssh-keysign", 24), | |
LOO_CRYPT_STR_N("/usr/libexec/sftp-server", 24), | |
LOO_CRYPT_STR_N("/etc/ssh/sshd_config", 20), | |
LOO_CRYPT_STR_N("/bin/sh", 7), | |
#endif | |
LOO_CRYPT_STR_N("/Applications/Cydia.app", 23), | |
LOO_CRYPT_STR_N("/Applications/RockApp.app", 25), | |
LOO_CRYPT_STR_N("/Applications/Icy.app", 21), | |
LOO_CRYPT_STR_N("/Applications/WinterBoard.app", 29), | |
LOO_CRYPT_STR_N("/Applications/SBSettings.app", 28), | |
LOO_CRYPT_STR_N("/Applications/MxTube.app", 24), | |
LOO_CRYPT_STR_N("/Applications/IntelliScreen.app", 31), | |
LOO_CRYPT_STR_N("/Applications/FakeCarrier.app", 29), | |
LOO_CRYPT_STR_N("/Applications/blackra1n.app", 27)]; | |
for (NSString *checkPath in fileChecks) | |
{ | |
if (checkJailbreakFile(checkPath)) { | |
return YES; | |
} | |
} | |
return NO; | |
} | |
BOOL checkJailbreakSymlinks() | |
{ | |
NSArray *linksChecks = @[LOO_CRYPT_STR_N("/Library/Ringtones", 18), | |
LOO_CRYPT_STR_N("/Library/Wallpaper", 18), | |
LOO_CRYPT_STR_N("/usr/arm-apple-darwin9", 22), | |
LOO_CRYPT_STR_N("/usr/include", 12), | |
LOO_CRYPT_STR_N("/usr/libexec", 12), | |
LOO_CRYPT_STR_N("/usr/share", 10), | |
LOO_CRYPT_STR_N("/Applications", 13)]; | |
for (NSString *checkPath in linksChecks) | |
{ | |
if (checkJailbreakSymLink(checkPath)) { | |
return YES; | |
} | |
} | |
return NO; | |
} | |
BOOL checkCydiaScheme() { | |
if([[UIApplication sharedApplication] canOpenURL: | |
[NSURL URLWithString:LOO_CRYPT_STR_N("cydia://package/com.com.com", 27)]]) | |
{ | |
return YES; | |
} | |
return NO; | |
} | |
BOOL checkReadWritePermissions() | |
{ | |
NSError *error; | |
NSString *stringToBeWritten = @"0"; | |
[stringToBeWritten writeToFile:LOO_CRYPT_STR_N("/private/jailbreak.test", 23) | |
atomically:YES | |
encoding:NSUTF8StringEncoding error:&error]; | |
if (error == nil) | |
{ | |
return YES; | |
} | |
return NO; | |
} | |
BOOL checkRootPermissions() { | |
if (access([LOO_CRYPT_STR_N("/", 1) UTF8String], R_OK|W_OK) > 0 ) | |
{ | |
return YES; | |
} | |
return NO; | |
} | |
BOOL checkJailbreakSymLink(NSString *checkPath) | |
{ | |
struct stat s; | |
if (lstat([checkPath UTF8String], &s) == 0) | |
{ | |
if (S_ISLNK(s.st_mode) == 1) | |
{ | |
return YES; | |
} | |
} | |
return NO; | |
} | |
BOOL checkJailbreakFile(NSString *checkPath) | |
{ | |
struct stat s; | |
if (stat([checkPath UTF8String], &s) == 0) | |
{ | |
return YES; | |
} | |
return NO; | |
} | |
BOOL checkPortOpen(short port) | |
{ | |
struct sockaddr_in addr; | |
int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); | |
memset(&addr, 0, sizeof(addr)); | |
addr.sin_family = AF_INET; | |
addr.sin_port = htons(port); | |
if (inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr)) | |
{ | |
int result = connect(sock, (struct sockaddr *)&addr, | |
sizeof(addr)); | |
if(result==0) { | |
close(sock); | |
return YES; | |
} | |
close(sock); | |
} | |
return NO; | |
} | |
BOOL checkSandbox() { | |
#if !(TARGET_OS_SIMULATOR) | |
int resultFork = fork(); // Simulator allows fork | |
if (resultFork >= 0) return YES; | |
int resultSystem = system(NULL); // Simulator will throw SIGABRT | |
if (resultSystem > 0) return YES; | |
#endif | |
return NO; | |
} | |
BOOL checkForInjection() | |
{ | |
uint32_t count = _dyld_image_count(); | |
char* evilLibs[] = | |
{ | |
"Substrate", "cycript" | |
}; | |
for(uint32_t i = 0; i < count; i++) | |
{ | |
const char *dyld = _dyld_get_image_name(i); | |
int slength = (int)strlen(dyld); | |
int j; | |
for(j = slength - 1; j>= 0; --j) | |
if(dyld[j] == '/') break; | |
char *name = strndup(dyld + ++j, slength - j); | |
for(int x=0; x < sizeof(evilLibs) / sizeof(char*); x++) | |
{ | |
if(strstr(name, evilLibs[x]) || strstr(dyld, evilLibs[x])) | |
{ | |
free(name); | |
return YES; | |
} | |
} | |
free(name); | |
} | |
return NO; | |
} | |
@end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// LOOCryptString.h | |
// | |
// Created by Marcin Swiderski on 6/8/12. | |
// Copyright (c) 2012 Marcin Swiderski. All rights reserved. | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. | |
// | |
// Permission is granted to anyone to use this software for any purpose, | |
// including commercial applications, and to alter it and redistribute it | |
// freely, subject to the following restrictions: | |
// | |
// 1. The origin of this software must not be misrepresented; you must not | |
// claim that you wrote the original software. If you use this software | |
// in a product, an acknowledgment in the product documentation would be | |
// appreciated but is not required. | |
// 2. Altered source versions must be plainly marked as such, and must not be | |
// misrepresented as being the original software. | |
// 3. This notice may not be removed or altered from any source distribution. | |
// | |
// | |
// USAGE: To hide the string you just have to surround it with a macro like this: | |
// | |
// NSString *secret = LOO_CRYPT_STR_N("A7LZ14F88Y", 10); | |
// | |
// Remember to use C-sting, because NSString literals cannot be processed in compile time. | |
// | |
// IMPORTANT: Works with -Os (Fastest, Smallest) optimization level. | |
#import <Foundation/Foundation.h> | |
// __str - C-string. | |
// __n - Number of characters in string (without trailing \0 character). | |
#define LOO_CRYPT_STR_N(__str, __n) LOODecrypStrN((const unsigned char []){ LOO_ENCRYPT_STR_TO_CHAR_##__n(__str) }, __n + 1) | |
// TODO: use more complex approach! | |
// XOR is easy to find | |
#define LOO_ENCRYPT_STR_CHAR_AT(__str, __i) ((unsigned char)(__str[__i]) ^ ("UIApplicationDidBecomeActiveNotification"[__i%40])) | |
// Obfuscate.U.I.A.p.p.l.i.c.a.t.i.o.n.D.idBecomeActiveNotification | |
// This must match LOO_ENCRYPT_STR_CHAR_AT. | |
NSString *LOODecrypStrN(const unsigned char encStr[], size_t n); | |
#define LOO_ENCRYPT_STR_TO_CHAR_0(__str) LOO_ENCRYPT_STR_CHAR_AT(__str, 0) | |
#define LOO_ENCRYPT_STR_TO_CHAR_1(__str) LOO_ENCRYPT_STR_TO_CHAR_0(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 1) | |
#define LOO_ENCRYPT_STR_TO_CHAR_2(__str) LOO_ENCRYPT_STR_TO_CHAR_1(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 2) | |
#define LOO_ENCRYPT_STR_TO_CHAR_3(__str) LOO_ENCRYPT_STR_TO_CHAR_2(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 3) | |
#define LOO_ENCRYPT_STR_TO_CHAR_4(__str) LOO_ENCRYPT_STR_TO_CHAR_3(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 4) | |
#define LOO_ENCRYPT_STR_TO_CHAR_5(__str) LOO_ENCRYPT_STR_TO_CHAR_4(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 5) | |
#define LOO_ENCRYPT_STR_TO_CHAR_6(__str) LOO_ENCRYPT_STR_TO_CHAR_5(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 6) | |
#define LOO_ENCRYPT_STR_TO_CHAR_7(__str) LOO_ENCRYPT_STR_TO_CHAR_6(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 7) | |
#define LOO_ENCRYPT_STR_TO_CHAR_8(__str) LOO_ENCRYPT_STR_TO_CHAR_7(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 8) | |
#define LOO_ENCRYPT_STR_TO_CHAR_9(__str) LOO_ENCRYPT_STR_TO_CHAR_8(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 9) | |
#define LOO_ENCRYPT_STR_TO_CHAR_10(__str) LOO_ENCRYPT_STR_TO_CHAR_9(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 10) | |
#define LOO_ENCRYPT_STR_TO_CHAR_11(__str) LOO_ENCRYPT_STR_TO_CHAR_10(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 11) | |
#define LOO_ENCRYPT_STR_TO_CHAR_12(__str) LOO_ENCRYPT_STR_TO_CHAR_11(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 12) | |
#define LOO_ENCRYPT_STR_TO_CHAR_13(__str) LOO_ENCRYPT_STR_TO_CHAR_12(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 13) | |
#define LOO_ENCRYPT_STR_TO_CHAR_14(__str) LOO_ENCRYPT_STR_TO_CHAR_13(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 14) | |
#define LOO_ENCRYPT_STR_TO_CHAR_15(__str) LOO_ENCRYPT_STR_TO_CHAR_14(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 15) | |
#define LOO_ENCRYPT_STR_TO_CHAR_16(__str) LOO_ENCRYPT_STR_TO_CHAR_15(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 16) | |
#define LOO_ENCRYPT_STR_TO_CHAR_17(__str) LOO_ENCRYPT_STR_TO_CHAR_16(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 17) | |
#define LOO_ENCRYPT_STR_TO_CHAR_18(__str) LOO_ENCRYPT_STR_TO_CHAR_17(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 18) | |
#define LOO_ENCRYPT_STR_TO_CHAR_19(__str) LOO_ENCRYPT_STR_TO_CHAR_18(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 19) | |
#define LOO_ENCRYPT_STR_TO_CHAR_20(__str) LOO_ENCRYPT_STR_TO_CHAR_19(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 20) | |
#define LOO_ENCRYPT_STR_TO_CHAR_21(__str) LOO_ENCRYPT_STR_TO_CHAR_20(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 21) | |
#define LOO_ENCRYPT_STR_TO_CHAR_22(__str) LOO_ENCRYPT_STR_TO_CHAR_21(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 22) | |
#define LOO_ENCRYPT_STR_TO_CHAR_23(__str) LOO_ENCRYPT_STR_TO_CHAR_22(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 23) | |
#define LOO_ENCRYPT_STR_TO_CHAR_24(__str) LOO_ENCRYPT_STR_TO_CHAR_23(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 24) | |
#define LOO_ENCRYPT_STR_TO_CHAR_25(__str) LOO_ENCRYPT_STR_TO_CHAR_24(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 25) | |
#define LOO_ENCRYPT_STR_TO_CHAR_26(__str) LOO_ENCRYPT_STR_TO_CHAR_25(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 26) | |
#define LOO_ENCRYPT_STR_TO_CHAR_27(__str) LOO_ENCRYPT_STR_TO_CHAR_26(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 27) | |
#define LOO_ENCRYPT_STR_TO_CHAR_28(__str) LOO_ENCRYPT_STR_TO_CHAR_27(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 28) | |
#define LOO_ENCRYPT_STR_TO_CHAR_29(__str) LOO_ENCRYPT_STR_TO_CHAR_28(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 29) | |
#define LOO_ENCRYPT_STR_TO_CHAR_30(__str) LOO_ENCRYPT_STR_TO_CHAR_29(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 30) | |
#define LOO_ENCRYPT_STR_TO_CHAR_31(__str) LOO_ENCRYPT_STR_TO_CHAR_30(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 31) | |
#define LOO_ENCRYPT_STR_TO_CHAR_32(__str) LOO_ENCRYPT_STR_TO_CHAR_31(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 32) | |
#define LOO_ENCRYPT_STR_TO_CHAR_33(__str) LOO_ENCRYPT_STR_TO_CHAR_32(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 33) | |
#define LOO_ENCRYPT_STR_TO_CHAR_34(__str) LOO_ENCRYPT_STR_TO_CHAR_33(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 34) | |
#define LOO_ENCRYPT_STR_TO_CHAR_35(__str) LOO_ENCRYPT_STR_TO_CHAR_34(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 35) | |
#define LOO_ENCRYPT_STR_TO_CHAR_36(__str) LOO_ENCRYPT_STR_TO_CHAR_35(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 36) | |
#define LOO_ENCRYPT_STR_TO_CHAR_37(__str) LOO_ENCRYPT_STR_TO_CHAR_36(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 37) | |
#define LOO_ENCRYPT_STR_TO_CHAR_38(__str) LOO_ENCRYPT_STR_TO_CHAR_37(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 38) | |
#define LOO_ENCRYPT_STR_TO_CHAR_39(__str) LOO_ENCRYPT_STR_TO_CHAR_38(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 39) | |
#define LOO_ENCRYPT_STR_TO_CHAR_40(__str) LOO_ENCRYPT_STR_TO_CHAR_39(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 40) | |
#define LOO_ENCRYPT_STR_TO_CHAR_41(__str) LOO_ENCRYPT_STR_TO_CHAR_40(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 41) | |
#define LOO_ENCRYPT_STR_TO_CHAR_42(__str) LOO_ENCRYPT_STR_TO_CHAR_41(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 42) | |
#define LOO_ENCRYPT_STR_TO_CHAR_43(__str) LOO_ENCRYPT_STR_TO_CHAR_42(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 43) | |
#define LOO_ENCRYPT_STR_TO_CHAR_44(__str) LOO_ENCRYPT_STR_TO_CHAR_43(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 44) | |
#define LOO_ENCRYPT_STR_TO_CHAR_45(__str) LOO_ENCRYPT_STR_TO_CHAR_44(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 45) | |
#define LOO_ENCRYPT_STR_TO_CHAR_46(__str) LOO_ENCRYPT_STR_TO_CHAR_45(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 46) | |
#define LOO_ENCRYPT_STR_TO_CHAR_47(__str) LOO_ENCRYPT_STR_TO_CHAR_46(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 47) | |
#define LOO_ENCRYPT_STR_TO_CHAR_48(__str) LOO_ENCRYPT_STR_TO_CHAR_47(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 48) | |
#define LOO_ENCRYPT_STR_TO_CHAR_49(__str) LOO_ENCRYPT_STR_TO_CHAR_48(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 49) | |
#define LOO_ENCRYPT_STR_TO_CHAR_50(__str) LOO_ENCRYPT_STR_TO_CHAR_49(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 50) | |
#define LOO_ENCRYPT_STR_TO_CHAR_51(__str) LOO_ENCRYPT_STR_TO_CHAR_50(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 51) | |
#define LOO_ENCRYPT_STR_TO_CHAR_52(__str) LOO_ENCRYPT_STR_TO_CHAR_51(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 52) | |
#define LOO_ENCRYPT_STR_TO_CHAR_53(__str) LOO_ENCRYPT_STR_TO_CHAR_52(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 53) | |
#define LOO_ENCRYPT_STR_TO_CHAR_54(__str) LOO_ENCRYPT_STR_TO_CHAR_53(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 54) | |
#define LOO_ENCRYPT_STR_TO_CHAR_55(__str) LOO_ENCRYPT_STR_TO_CHAR_54(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 55) | |
#define LOO_ENCRYPT_STR_TO_CHAR_56(__str) LOO_ENCRYPT_STR_TO_CHAR_55(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 56) | |
#define LOO_ENCRYPT_STR_TO_CHAR_57(__str) LOO_ENCRYPT_STR_TO_CHAR_56(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 57) | |
#define LOO_ENCRYPT_STR_TO_CHAR_58(__str) LOO_ENCRYPT_STR_TO_CHAR_57(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 58) | |
#define LOO_ENCRYPT_STR_TO_CHAR_59(__str) LOO_ENCRYPT_STR_TO_CHAR_58(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 59) | |
#define LOO_ENCRYPT_STR_TO_CHAR_60(__str) LOO_ENCRYPT_STR_TO_CHAR_59(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 60) | |
#define LOO_ENCRYPT_STR_TO_CHAR_61(__str) LOO_ENCRYPT_STR_TO_CHAR_60(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 61) | |
#define LOO_ENCRYPT_STR_TO_CHAR_62(__str) LOO_ENCRYPT_STR_TO_CHAR_61(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 62) | |
#define LOO_ENCRYPT_STR_TO_CHAR_63(__str) LOO_ENCRYPT_STR_TO_CHAR_62(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 63) | |
#define LOO_ENCRYPT_STR_TO_CHAR_64(__str) LOO_ENCRYPT_STR_TO_CHAR_63(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 64) | |
#define LOO_ENCRYPT_STR_TO_CHAR_65(__str) LOO_ENCRYPT_STR_TO_CHAR_64(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 65) | |
#define LOO_ENCRYPT_STR_TO_CHAR_66(__str) LOO_ENCRYPT_STR_TO_CHAR_65(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 66) | |
#define LOO_ENCRYPT_STR_TO_CHAR_67(__str) LOO_ENCRYPT_STR_TO_CHAR_66(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 67) | |
#define LOO_ENCRYPT_STR_TO_CHAR_68(__str) LOO_ENCRYPT_STR_TO_CHAR_67(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 68) | |
#define LOO_ENCRYPT_STR_TO_CHAR_69(__str) LOO_ENCRYPT_STR_TO_CHAR_68(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 69) | |
#define LOO_ENCRYPT_STR_TO_CHAR_70(__str) LOO_ENCRYPT_STR_TO_CHAR_69(__str), LOO_ENCRYPT_STR_CHAR_AT(__str, 70) | |
// Need more? Type (or better automatically generate) it yourself ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// LOOCryptString.m | |
// | |
// Created by Marcin Swiderski on 6/8/12. | |
// Copyright (c) 2012 Marcin Swiderski. All rights reserved. | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. | |
// | |
// Permission is granted to anyone to use this software for any purpose, | |
// including commercial applications, and to alter it and redistribute it | |
// freely, subject to the following restrictions: | |
// | |
// 1. The origin of this software must not be misrepresented; you must not | |
// claim that you wrote the original software. If you use this software | |
// in a product, an acknowledgment in the product documentation would be | |
// appreciated but is not required. | |
// 2. Altered source versions must be plainly marked as such, and must not be | |
// misrepresented as being the original software. | |
// 3. This notice may not be removed or altered from any source distribution. | |
// | |
#import "LOOCryptString.h" | |
NSString *LOODecrypStrN(const unsigned char encStr[], size_t n) { | |
char *buf = [[NSMutableData dataWithLength:n] mutableBytes]; | |
for (NSInteger i = 0; i != n; ++i) { | |
buf[i] = encStr[i] ^ ("UIApplicationDidBecomeActiveNotification"[i%40]); | |
} | |
return [NSString stringWithCString:buf encoding:NSASCIIStringEncoding]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment