commit 6f2a4173324a652b042a66ec6cf4939954b8e4ca Author: wxb1ank Date: Fri Jan 3 02:21:46 2020 -0500 Initial upload diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..36e024d --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +ARCHS = arm64 arm64e +TARGET = iphone::latest + +include $(THEOS)/makefiles/common.mk + +TOOL_NAME = lockpick + +lockpick_FILES = main.m +lockpick_CFLAGS = -fobjc-arc +lockpick_PRIVATE_FRAMEWORKS = ManagedConfiguration SpringBoard +lockpick_CODESIGN_FLAGS = -Sent.xml + +include $(THEOS_MAKE_PATH)/tool.mk diff --git a/control b/control new file mode 100644 index 0000000..8fc39df --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: com.wxblank.lockpick +Name: lockpick +Version: 0.0.1 +Architecture: iphoneos-arm +Description: lock/unlock the device +Maintainer: wxblank +Author: wxblank +Section: System +Tag: role::hacker diff --git a/ent.xml b/ent.xml new file mode 100644 index 0000000..7950eb2 --- /dev/null +++ b/ent.xml @@ -0,0 +1,8 @@ + + + + + com.apple.springboard-ui.client + + + \ No newline at end of file diff --git a/main.m b/main.m new file mode 100644 index 0000000..62a553a --- /dev/null +++ b/main.m @@ -0,0 +1,81 @@ +#include +#include + +#import + +#define PROG_NAME "lockpick" + +@interface MCPasscodeManager : NSObject + ++ (MCPasscodeManager *)sharedManager; + ++ (BOOL)isDeviceUnlocked; ++ (BOOL)isDeviceLocked; +- (BOOL)isPasscodeSet; + +- (void)lockDevice; +- (BOOL)unlockDeviceWithPasscode:(id)passcode outError:(out NSError * _Nullable *)error; + +@end + +@interface SBLockdownManager : NSObject + ++ (SBLockdownManager *)sharedInstance; + +@end + +void print_usage() { + printf("Usage: %s lock\n", PROG_NAME); + printf(" %s unlock [passcode]\n", PROG_NAME); +} + +int main(int argc, char *argv[]) { + if(argc == 1) { + print_usage(); + return 0; + } + + if(strcmp(argv[1], "lock") == 0) { + if([MCPasscodeManager isDeviceUnlocked]) { + [[MCPasscodeManager sharedManager] lockDevice]; + } else { + fprintf(stderr, "Device is already locked.\n"); + return 1; + } + } + else if(strcmp(argv[1], "unlock") == 0) { + NSError *error = nil; + + if(![MCPasscodeManager isDeviceUnlocked]) { + if(![MCPasscodeManager sharedManager].isPasscodeSet) { + [[MCPasscodeManager sharedManager] unlockDeviceWithPasscode:nil outError:&error]; + if(error) { + fprintf(stderr, "Couldn't unlock device.\n"); + return 1; + } + } + else if(argc < 3) { + fprintf(stderr, "This device requires a passcode.\n"); + return 1; + } + + NSString *givenPasscode = @(argv[2]); + + [[MCPasscodeManager sharedManager] unlockDeviceWithPasscode:givenPasscode outError:&error]; + if(error) { + if(error.code == 5011) { + fprintf(stderr, "Wrong passcode.\n"); + return 1; + } + fprintf(stderr, "Unknown error code.\n"); + return 1; + } + } else { + fprintf(stderr, "Device is already unlocked.\n"); + return 1; + } + + } + + return 0; +} \ No newline at end of file