Skip to content

Commit

Permalink
Use tabs, not spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
akemin-dayo committed Nov 23, 2014
1 parent 6d9b365 commit e5e40f0
Show file tree
Hide file tree
Showing 9 changed files with 846 additions and 846 deletions.
34 changes: 17 additions & 17 deletions AppSyncUnified.sublime-project
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"folders":
[
{
"follow_symlinks": false,
"path": ".",
"file_exclude_patterns": [
"*.deb"
],
"folder_exclude_patterns": [
"_",
"obj",
"theos",
".theos",
"debs"
]
}
]
"folders":
[
{
"follow_symlinks": false,
"path": ".",
"file_exclude_patterns": [
"*.deb"
],
"folder_exclude_patterns": [
"_",
"obj",
"theos",
".theos",
"debs"
]
}
]
}
262 changes: 131 additions & 131 deletions AppSyncUnified/AppSyncUnified.x
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/*
* AppSyncUnified.x
* AppSync Unified
* AppSyncUnified.x
* AppSync Unified
*
* https://github.com/angelXwind/AppSync
* http://cydia.angelxwind.net/?page/net.angelxwind.appsyncunified
* https://github.com/angelXwind/AppSync
* http://cydia.angelxwind.net/?page/net.angelxwind.appsyncunified
*
* Copyright (c) 2014 Linus Yang <laokongzi+appsync@gmail.com>, Karen Tsai <angelXwind@angelxwind.net>
* Copyright (c) 2014 Linus Yang <laokongzi+appsync@gmail.com>, Karen Tsai <angelXwind@angelxwind.net>
*
* AppSync Unified is NOT for piracy. Use it legally.
* AppSync Unified is NOT for piracy. Use it legally.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#import <Foundation/Foundation.h>
Expand All @@ -41,22 +41,22 @@ void MSHookFunction(void *symbol, void *replace, void **result);
#endif

#define DECL_FUNC(name, ret, ...) \
static ret (*original_ ## name)(__VA_ARGS__); \
ret custom_ ## name(__VA_ARGS__)
static ret (*original_ ## name)(__VA_ARGS__); \
ret custom_ ## name(__VA_ARGS__)
#define HOOK_FUNC(name, image) do { \
void *_ ## name = MSFindSymbol(image, "_" #name); \
if (_ ## name == NULL) { \
LOG(@"Failed to load symbol: " #name "."); \
return; \
} \
MSHookFunction(_ ## name, (void *) custom_ ## name, (void **) &original_ ## name); \
void *_ ## name = MSFindSymbol(image, "_" #name); \
if (_ ## name == NULL) { \
LOG(@"Failed to load symbol: " #name "."); \
return; \
} \
MSHookFunction(_ ## name, (void *) custom_ ## name, (void **) &original_ ## name); \
} while(0)
#define LOAD_IMAGE(image, path) do { \
image = MSGetImageByName(path); \
if (image == NULL) { \
LOG(@"Failed to load " #image "."); \
return; \
} \
image = MSGetImageByName(path); \
if (image == NULL) { \
LOG(@"Failed to load " #image "."); \
return; \
} \
} while (0)

#define kSecMagicBytesLength 2
Expand All @@ -68,125 +68,125 @@ static const uint32_t kInfoBytes[kInfoBytesLength] = {0x68e8f97, 0xc67e14de, 0xf

static void copyIdentifierAndEntitlements(NSString *path, NSString **identifier, NSDictionary **info)
{
if (path == nil || identifier == NULL || info == NULL) {
LOG(@"copyIdentifierAndEntitlements: null args");
return;
}

LOG(@"bundle path: %@", path);
NSBundle *bundle = [NSBundle bundleWithPath:path];

NSString *bundleIdentifier = [bundle bundleIdentifier];
if (bundleIdentifier != nil) {
*identifier = [[NSString alloc] initWithString:bundleIdentifier];
LOG(@"bundle id: %@", bundleIdentifier);
}

NSString *executablePath = [bundle executablePath];
NSArray *paths = [executablePath pathComponents];
if (paths.count > 0 && [paths.lastObject isEqualToString:@"Cydia"]) {
NSMutableArray *newPaths = [NSMutableArray arrayWithArray:paths];
newPaths[newPaths.count - 1] = @"MobileCydia";
executablePath = [NSString pathWithComponents:newPaths];
}
LOG(@"bundle exec: %@", executablePath);

NSMutableData *data = [NSMutableData data];
int ret = copyEntitlementDataFromFile(executablePath.UTF8String, (CFMutableDataRef) data);
if (ret == kCopyEntSuccess) {
NSError *error;
NSDictionary *plist = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:NULL error:&error];
*info = [[NSDictionary alloc] initWithDictionary:plist];
} else {
LOG(@"failed to fetch entitlements: %@", (NSString *) entErrorString(ret));
}
if (path == nil || identifier == NULL || info == NULL) {
LOG(@"copyIdentifierAndEntitlements: null args");
return;
}

LOG(@"bundle path: %@", path);
NSBundle *bundle = [NSBundle bundleWithPath:path];

NSString *bundleIdentifier = [bundle bundleIdentifier];
if (bundleIdentifier != nil) {
*identifier = [[NSString alloc] initWithString:bundleIdentifier];
LOG(@"bundle id: %@", bundleIdentifier);
}

NSString *executablePath = [bundle executablePath];
NSArray *paths = [executablePath pathComponents];
if (paths.count > 0 && [paths.lastObject isEqualToString:@"Cydia"]) {
NSMutableArray *newPaths = [NSMutableArray arrayWithArray:paths];
newPaths[newPaths.count - 1] = @"MobileCydia";
executablePath = [NSString pathWithComponents:newPaths];
}
LOG(@"bundle exec: %@", executablePath);

NSMutableData *data = [NSMutableData data];
int ret = copyEntitlementDataFromFile(executablePath.UTF8String, (CFMutableDataRef) data);
if (ret == kCopyEntSuccess) {
NSError *error;
NSDictionary *plist = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:NULL error:&error];
*info = [[NSDictionary alloc] initWithDictionary:plist];
} else {
LOG(@"failed to fetch entitlements: %@", (NSString *) entErrorString(ret));
}
}

DECL_FUNC(SecCertificateCreateWithData, SecCertificateRef, CFAllocatorRef allocator, CFDataRef data)
{
SecCertificateRef result = original_SecCertificateCreateWithData(allocator, data);
if (result == NULL) {
CFDataRef dataRef = CFDataCreate(NULL, kSecMagicBytes, kSecMagicBytesLength);
if (data != NULL && CFEqual(dataRef, data)) {
result = (SecCertificateRef) dataRef;
} else {
CFRelease(dataRef);
}
}
return result;
SecCertificateRef result = original_SecCertificateCreateWithData(allocator, data);
if (result == NULL) {
CFDataRef dataRef = CFDataCreate(NULL, kSecMagicBytes, kSecMagicBytesLength);
if (data != NULL && CFEqual(dataRef, data)) {
result = (SecCertificateRef) dataRef;
} else {
CFRelease(dataRef);
}
}
return result;
}

DECL_FUNC(SecCertificateCopySubjectSummary, CFStringRef, SecCertificateRef certificate)
{
if (CFGetTypeID(certificate) == CFDataGetTypeID()) {
return CFStringCreateWithCString(NULL, kSecSubjectCStr, kCFStringEncodingUTF8);
}
CFStringRef result = original_SecCertificateCopySubjectSummary(certificate);
return result;
if (CFGetTypeID(certificate) == CFDataGetTypeID()) {
return CFStringCreateWithCString(NULL, kSecSubjectCStr, kCFStringEncodingUTF8);
}
CFStringRef result = original_SecCertificateCopySubjectSummary(certificate);
return result;
}

DECL_FUNC(MISValidateSignatureAndCopyInfo, uintptr_t, NSString *path, uintptr_t b, NSDictionary **info)
{
#ifdef KAREN_ASU
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/net.angelxwind.appsyncunified.list"]) {
NSLog(@"You seem to have installed AppSync Unified from an APT repository that is not cydia.angelxwind.net (package ID net.angelxwind.appsyncunified).");
NSLog(@"If someone other than Linus Yang (laokongzi) or Karen Tsai (angelXwind) is taking credit for the development of this tweak, they are likely lying.");
NSLog(@"Remember: AppSync Unified is NOT for piracy. Use it legally.");
}
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/net.angelxwind.appsyncunified.list"]) {
NSLog(@"You seem to have installed AppSync Unified from an APT repository that is not cydia.angelxwind.net (package ID net.angelxwind.appsyncunified).");
NSLog(@"If someone other than Linus Yang (laokongzi) or Karen Tsai (angelXwind) is taking credit for the development of this tweak, they are likely lying.");
NSLog(@"Remember: AppSync Unified is NOT for piracy. Use it legally.");
}
#endif
#ifdef YANG_ASU
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/com.linusyang.appsync.list"]) {
NSLog(@"You seem to have installed AppSync from an APT repository that is not yangapp.googlecode.com/svn/ (package ID com.linusyang.appsync).");
NSLog(@"If someone other than Linus Yang (laokongzi) or Karen Tsai (angelXwind) is taking credit for the development of this tweak, they are likely lying.");
NSLog(@"Remember: AppSync is NOT for piracy. Use it legally.");
}
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/com.linusyang.appsync.list"]) {
NSLog(@"You seem to have installed AppSync from an APT repository that is not yangapp.googlecode.com/svn/ (package ID com.linusyang.appsync).");
NSLog(@"If someone other than Linus Yang (laokongzi) or Karen Tsai (angelXwind) is taking credit for the development of this tweak, they are likely lying.");
NSLog(@"Remember: AppSync is NOT for piracy. Use it legally.");
}
#endif
COPY_NSLOG_ONCE(kInfoBytes, kInfoBytesLength, kSecMagicBytes[0]);
original_MISValidateSignatureAndCopyInfo(path, b, info);
if (info == NULL) {
LOG(@"Boo, NULL info");
} else if (*info == nil) {
LOG(@"Ahh, nil info, fake it");
if (SYSTEM_GE_IOS_8()) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
MSImageRef imageSec;
LOAD_IMAGE(imageSec, "/System/Library/Frameworks/Security.framework/Security");
HOOK_FUNC(SecCertificateCreateWithData, imageSec);
HOOK_FUNC(SecCertificateCopySubjectSummary, imageSec);
LOG(@"Security.framework injected");
});

NSMutableDictionary *fakeInfo = [[NSMutableDictionary alloc] init];
NSDictionary *entitlements = nil;
NSString *identifier = nil;
copyIdentifierAndEntitlements(path, &identifier, &entitlements);
if (entitlements != nil) {
[fakeInfo setObject:entitlements forKey:@"Entitlements"];
[entitlements release];
}
if (identifier != nil) {
[fakeInfo setObject:identifier forKey:@"SigningID"];
[identifier release];
}
[fakeInfo setObject:[NSData dataWithBytes:kSecMagicBytes length:kSecMagicBytesLength] forKey:@"SignerCertificate"];
[fakeInfo setObject:[NSDate date] forKey:@"SigningTime"];
[fakeInfo setObject:[NSNumber numberWithBool:NO] forKey:@"ValidatedByProfile"];
LOG(@"faked info: %@", fakeInfo);
*info = fakeInfo;
}
} else {
LOG(@"Hooray, info is okay");
LOG(@"orig info: %@", *info);
}
return 0;
COPY_NSLOG_ONCE(kInfoBytes, kInfoBytesLength, kSecMagicBytes[0]);
original_MISValidateSignatureAndCopyInfo(path, b, info);
if (info == NULL) {
LOG(@"Boo, NULL info");
} else if (*info == nil) {
LOG(@"Ahh, nil info, fake it");
if (SYSTEM_GE_IOS_8()) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
MSImageRef imageSec;
LOAD_IMAGE(imageSec, "/System/Library/Frameworks/Security.framework/Security");
HOOK_FUNC(SecCertificateCreateWithData, imageSec);
HOOK_FUNC(SecCertificateCopySubjectSummary, imageSec);
LOG(@"Security.framework injected");
});

NSMutableDictionary *fakeInfo = [[NSMutableDictionary alloc] init];
NSDictionary *entitlements = nil;
NSString *identifier = nil;
copyIdentifierAndEntitlements(path, &identifier, &entitlements);
if (entitlements != nil) {
[fakeInfo setObject:entitlements forKey:@"Entitlements"];
[entitlements release];
}
if (identifier != nil) {
[fakeInfo setObject:identifier forKey:@"SigningID"];
[identifier release];
}
[fakeInfo setObject:[NSData dataWithBytes:kSecMagicBytes length:kSecMagicBytesLength] forKey:@"SignerCertificate"];
[fakeInfo setObject:[NSDate date] forKey:@"SigningTime"];
[fakeInfo setObject:[NSNumber numberWithBool:NO] forKey:@"ValidatedByProfile"];
LOG(@"faked info: %@", fakeInfo);
*info = fakeInfo;
}
} else {
LOG(@"Hooray, info is okay");
LOG(@"orig info: %@", *info);
}
return 0;
}

%ctor {
@autoreleasepool {
MSImageRef image;
LOAD_IMAGE(image, "/usr/lib/libmis.dylib");
HOOK_FUNC(MISValidateSignatureAndCopyInfo, image);
LOG(@"libmis.dylib injected");
}
@autoreleasepool {
MSImageRef image;
LOAD_IMAGE(image, "/usr/lib/libmis.dylib");
HOOK_FUNC(MISValidateSignatureAndCopyInfo, image);
LOG(@"libmis.dylib injected");
}
}
Loading

0 comments on commit e5e40f0

Please sign in to comment.