From 0a3e1c151694070d4a1023e357c98e132d3e215f Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 24 Oct 2014 02:59:04 -0700 Subject: [PATCH] Use Substrate to modify Services.plist on iOS 8+. --- afc2dService.mm | 47 ++++++++++++++++++++++++++++++++++++++++++++++ afc2dService.plist | 17 +++++++++++++++++ control.in | 1 + extrainst.mm | 28 ++++++++++++++++++--------- make.sh | 5 +++++ 5 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 afc2dService.mm create mode 100644 afc2dService.plist diff --git a/afc2dService.mm b/afc2dService.mm new file mode 100644 index 0000000..0e8eecd --- /dev/null +++ b/afc2dService.mm @@ -0,0 +1,47 @@ +/* AFC2 - the original definition of "jailbreak" + * Copyright (C) 2014 Jay Freeman (saurik) +*/ + +/* GNU General Public License, Version 3 {{{ */ +/* + * Cydia 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. + * + * Cydia 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 Cydia. If not, see . +**/ +/* }}} */ + +#include +#include +#include + +%hook CFPropertyListRef CFPropertyListCreateWithData(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error) { + CFPropertyListRef list(%original(allocator, data, options, format, error)); + NSDictionary *dict((NSDictionary *) list); + + if ([dict objectForKey:@"com.apple.afc"] != nil) { + NSMutableDictionary *copy([dict mutableCopy]); + CFRelease(list); + list = (CFPropertyListRef) copy; + + [copy setObject:@{ + @"AllowUnactivatedService": @true, + @"Label": @"com.apple.afc2", + @"ProgramArguments": @[@"/usr/libexec/afc2d", @"-S", @"-L", @"-d", @"/"], + } forKey:@"com.apple.afc2"]; + } + + return list; +} + +MSInitialize { + MSHookFunction(&CFPropertyListCreateWithData, MSHake(CFPropertyListCreateWithData)); +} diff --git a/afc2dService.plist b/afc2dService.plist new file mode 100644 index 0000000..7bab7a2 --- /dev/null +++ b/afc2dService.plist @@ -0,0 +1,17 @@ + + + + + Filter + + CoreFoundationVersion + + 1000 + + Executables + + lockdownd + + + + diff --git a/control.in b/control.in index e707f2d..23fa0bd 100644 --- a/control.in +++ b/control.in @@ -5,6 +5,7 @@ Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm Version: ${ver} Pre-Depends: dpkg (>= 1.14.25-8) +Depends: firmware (<< 8.0) | mobilesubstrate Conflicts: us.scw.afctwoadd, net.angelxwind.afc2ios70, afc2.25pp, afc2.25pp7, afc2.91, app.taig.afc2 Replaces: us.scw.afctwoadd, net.angelxwind.afc2ios70, afc2.25pp, afc2.25pp7, afc2.91, app.taig.afc2 Provides: us.scw.afctwoadd, net.angelxwind.afc2ios70, afc2.25pp, afc2.25pp7, afc2.91, app.taig.afc2 diff --git a/extrainst.mm b/extrainst.mm index 9c4764e..21e7796 100644 --- a/extrainst.mm +++ b/extrainst.mm @@ -87,19 +87,29 @@ int main(int argc, const char *argv[]) { return 1; } - NSString *path(@"/System/Library/Lockdown/Services.plist"); - NSMutableDictionary *services([NSMutableDictionary dictionaryWithContentsOfFile:path]); + if (kCFCoreFoundationVersionNumber < 1000) { + NSString *path(@"/System/Library/Lockdown/Services.plist"); - [services setObject:@{ - @"AllowUnactivatedService": @true, - @"Label": @"com.apple.afc2", - @"ProgramArguments": @[@"/usr/libexec/afc2d", @"-S", @"-L", @"-d", @"/"], - } forKey:@"com.apple.afc2"]; + NSMutableDictionary *services([NSMutableDictionary dictionaryWithContentsOfFile:path]); + if (services == nil) { + fprintf(stderr, "cannot read Services.plist\n"); + return 1; + } + + [services setObject:@{ + @"AllowUnactivatedService": @true, + @"Label": @"com.apple.afc2", + @"ProgramArguments": @[@"/usr/libexec/afc2d", @"-S", @"-L", @"-d", @"/"], + } forKey:@"com.apple.afc2"]; + + if (![services writeToFile:path atomically:YES]) { + fprintf(stderr, "cannot write Services.plist\n"); + return 1; + } + } - [services writeToFile:path atomically:YES]; system("/bin/launchctl stop com.apple.mobile.lockdown"); [pool release]; - return 0; } diff --git a/make.sh b/make.sh index 29972fc..7e32a60 100755 --- a/make.sh +++ b/make.sh @@ -3,6 +3,11 @@ set -e ver=$(git describe --tags --dirty="+" --match="v*" "${flags[@]}" | sed -e 's@-\([^-]*\)-\([^-]*\)$@+\1.\2@;s@^v@@;s@%@~@g') sudo rm -rf _ mkdir -p _/DEBIAN +ms=_/Library/MobileSubstrate/DynamicLibraries +mkdir -p "${ms}" +cp -a afc2dService.plist "${ms}" +plutil -convert binary1 "${ms}"/afc2dService.plist +cycc -i2.0 -o"${ms}"/afc2dService.dylib -s afc2dService.mm -- -framework Foundation cycc -i2.0 -o_/DEBIAN/extrainst_ -- extrainst.mm -lz -framework Foundation cycc -i2.0 -o_/DEBIAN/postrm -- postrm.mm -lz -framework Foundation sed -e 's/\${ver}/'"${ver}"'/' control.in >_/DEBIAN/control -- 2.45.2