Skip to content

Commit

Permalink
unofficial version 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ichitaso committed Nov 9, 2020
1 parent f1b4573 commit 688b6c8
Show file tree
Hide file tree
Showing 44 changed files with 1,865 additions and 546 deletions.
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,4 @@ theos/
_/
obj/
packages/
*.deb
*.o
.theos/*
debs/*
*.deb
*.dylib
**/.theos/*
*/.theos/*
*.sublime-workspace
_/*
*/obj/*
obj/*
*.deb
Binary file modified AnalysisResults/test.dmg
Binary file not shown.
44 changes: 23 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
ARCHS = arm64
ARCHS = arm64 arm64e
DEBUG = 0
GO_EASY_ON_ME = 1
PACKAGE_VERSION = $(THEOS_PACKAGE_BASE_VERSION)
FINALPACKAGE = 1

ARCHS = arm64 arm64e
THEOS_DEVICE_IP = localhost -p 2222
TARGET := iphone:clang:14.0:12.1.2
MIN_IOS_SDK_VERSION = 7.0

TOOL_NAME = changerootfs preparerootfs
TARGET := iphone:clang:14.0:14.0
THEOS_DEVICE_IP = localhost -p 2222

LIB_DIR := lib
TOOL_NAME = preparerootfs changerootfs

preparerootfs_FILES = preparerootfs.m
preparerootfs_CFLAGS = $(CFLAGS) -fobjc-arc -Wno-error=unused-variable -Wno-error=unused-function -D USE_DEV_FAKEVAR
preparerootfs_CODESIGN_FLAGS = -Sent.plist

changerootfs_FILES = changerootfs.m
changerootfs_CFLAGS = $(CFLAGS) -fobjc-arc -Wno-error=unused-variable -Wno-error=unused-function

ifdef USE_JELBREK_LIB
preparerootfs_LDFLAGS = $(LIB_DIR)/jelbrekLib.dylib
changerootfs_LDFLAGS = $(LIB_DIR)/jelbrekLib.dylib
endif
changerootfs_CODESIGN_FLAGS = -Sent.plist

SUBPROJECTS += zzzzzzzzznotifychroot
SUBPROJECTS += kernbypassprefs
SUBPROJECTS += kernbypassd
SUBPROJECTS += prerm

include $(THEOS)/makefiles/common.mk
include $(THEOS_MAKE_PATH)/tool.mk
include $(THEOS_MAKE_PATH)/aggregate.mk

LIB_DIR := lib

ifdef USE_JELBREK_LIB
preparerootfs_LDFLAGS = $(LIB_DIR)/jelbrekLib.dylib
changerootfs_LDFLAGS = $(LIB_DIR)/jelbrekLib.dylib
endif


ifdef USE_JELBREK_LIB
before-package::
Expand All @@ -38,16 +42,14 @@ endif
before-package::
mkdir -p $(THEOS_STAGING_DIR)/usr/lib/
cp $(LIB_DIR)/jelbrekLib.dylib $(THEOS_STAGING_DIR)/usr/lib
ldid -S./ent.plist $(THEOS_STAGING_DIR)/usr/bin/changerootfs
ldid -S./ent.plist $(THEOS_STAGING_DIR)/usr/bin/preparerootfs
sudo chown -R root:wheel $(THEOS_STAGING_DIR)
sudo chmod -R 755 $(THEOS_STAGING_DIR)
sudo chmod 6755 $(THEOS_STAGING_DIR)/usr/bin/kernbypassd
sudo chmod 666 $(THEOS_STAGING_DIR)/DEBIAN/control
cp ./layout/DEBIAN/* $(THEOS_STAGING_DIR)/DEBIAN
chmod -R 755 $(THEOS_STAGING_DIR)
chmod 6755 $(THEOS_STAGING_DIR)/usr/bin/kernbypassd
chmod 666 $(THEOS_STAGING_DIR)/DEBIAN/control


after-package::
make clean
sudo rm -rf .theos/_

after-install::
install.exec "killall backboardd"
install.exec "ldrestart"
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
# KernBypass
# KernBypass (Unofficial)
kernel level jailbreak detection bypass

## Support Devices
- iOS12.0-14.x? (confirmed on iOS12.4 and above)
- iOS12.0-14.1? (confirmed on iOS12.4 and above)
- A7-A13
- unc0ver or checkra1n
- unc0ver or checkra1n or odysseyra1n or Odyssey

**Note: Not compatible with iOS 14.2**

## Credits
- maphys by 0x7ff
- vnodebypass and iOS14 Support by @XsF1re
- jelbrekLib by @Jakeashacks
- Translated by sohsatoh
- iOS12 support by dora2-iOS
- Choicy Compatibility @level3tjg
- fakevar version added @NyaMisty
- Preferences refresh, overall code optimization @ichitaso


## WARNING
**This tweak is the kernel level. There is NO warranty. Run it at your own risk.**
**Note: Not all applications are supported.**
**(Please think that most don't work)**

## Getting Started
### Installation
1. Remove file `/var/mobile/Library/Preferences/jp.akusio.kernbypass.plist` if exist.
2. [download](https://github.com/XsF1re/KernBypass-Public/blob/master/packages/jp.akusio.kernbypass_0.0.3_iphoneos-arm.deb) and install the deb file.
### Setting up KernBypass
3. In terminal, run `su` and type your password.
4. Download the fakevar.zip from http://repo.misty.moe/apt/fakevar13.zip, and extract it to /var/mobile/fakevar (whatever method you use to extract, make sure there’s /var/mobile/fakevar/mobile)
1. Added my private repo: https://cydia.ichitaso.com
2. ​Install from Cydia or other package manager
### Setting up KernBypass (Manual)
3. **If you were using a previous version, be sure to Reboot first.**
4. In terminal, run `su` and type your password.
5. Run `preparerootfs`
6. Run `changerootfs &` (don't forget "&").
7. Run `disown %1`
8. Done. The changerootfs is now a daemon.

### Setting up KernBypass (GUI)
1. Settings -> KernBypass -> Enable KernBypass

### Selecting apps to bypass
1. After installing changerootfs, open Preferences > KernBypass, then select the applications to be enabled the bypass.

## Uninstall
1. Just uninstall from Cydia.
1. Just uninstall from Cydia or other package manager.
2. REBOOT!!!

## License
Expand Down
114 changes: 41 additions & 73 deletions changerootfs.m
Original file line number Diff line number Diff line change
@@ -1,126 +1,94 @@
#include <stdio.h>
#import <Foundation/Foundation.h>
#include <stdio.h>
#include <stdint.h>
#include <dirent.h>

#include "config.h"
#include "kernel.h"
#include "vnode_utils.h"
#include "utils.h"

#include <dirent.h>

//#if 0
extern CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);

bool change_rootvnode(uint64_t vp, pid_t pid){

if(!vp) return false;
bool change_rootvnode(uint64_t vp, pid_t pid) {

printf("getting proc_t\n");
if (!vp) return false;
printf("vp:%"PRIx64"\n",vp);

uint64_t proc = proc_of_pid(pid);

if(!proc) return false;

printf("reading pfd\n");
printf("getting proc_t:%"PRIx64"\n",proc);

if (!proc) return false;

uint64_t filedesc = kernel_read64(proc + off_p_pfd);

printf("writing fd_cdir\n");
printf("reading pfd:%"PRIx64"\n",filedesc);

kernel_write64(filedesc + off_fd_cdir, vp);

printf("writing fd_rdir\n");
printf("writing fd_cdir:%"PRIx64"\n",(filedesc + off_fd_cdir));

kernel_write64(filedesc + off_fd_rdir, vp);

printf("setting up fd_flags\n");
printf("writing fd_rdir:%"PRIx64"\n",(filedesc + off_fd_rdir));

uint32_t fd_flags = kernel_read32(filedesc + 0x58);

printf("setting up fd_flags:%"PRIx64"\n",filedesc + 0x58);

fd_flags |= 1; // FD_CHROOT = 1;

kernel_write32(filedesc + 0x58, fd_flags);

printf("finish\n");
printf("finish fd_flags:%"PRIx32"\n",fd_flags);
return true;

}

uint64_t rootvp;

void receive_notify_chrooter(CFNotificationCenterRef center,
void * observer,
CFStringRef name,
const void * object,
CFDictionaryRef userInfo){
NSDictionary* info = (__bridge NSDictionary*)userInfo;
CFDictionaryRef userInfo) {

NSDictionary *info = (__bridge NSDictionary*)userInfo;

NSLog(@"receive notify %@", info);

pid_t pid = [info[@"Pid"] intValue];

uint64_t rootvp = get_vnode_with_chdir(FAKEROOTDIR);
set_vnode_usecount(rootvp, 0x2000, 0x2000);

//change_rootvnode(FAKEROOTDIR, pid);

change_rootvnode(rootvp, pid);

//set_vnode_usecount(vnode_ref_by_chdir(FAKEROOTDIR), 0xf000);

set_vnode_usecount(rootvp, 0x2000, 0x2000);

usleep(100000);

kill(pid, SIGCONT);

}



bool is_empty(const char* path){

DIR* dir = opendir(path);
struct dirent* ent;
int count = 0;

while ((ent = readdir(dir)) != NULL) {
count++;
}

if(count == 2){
return YES;
}else{
return NO;
}

}


int main(int argc, char *argv[], char *envp[]) {

int err = init_kernel();
if (err) {
printf("error init_kernel\n");
return 1;
}

if(is_empty(FAKEROOTDIR) || access(FAKEROOTDIR"/private/var/containers", F_OK) != 0){
if (is_empty(FAKEROOTDIR) || access(FAKEROOTDIR"/private/var/containers", F_OK) != 0) {
printf("error fakeroot not mounted\n");
return 1;
}

//uint64_t rootvp = getVnodeAtPath(FAKEROOTDIR);
chdir("/");

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-function-declaration"


CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, receive_notify_chrooter, (__bridge CFStringRef)@"jp.akusio.chrooter", NULL, CFNotificationSuspensionBehaviorDeliverImmediately);


#pragma clang diagnostic pop


CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
NULL,
receive_notify_chrooter,
CFSTR(Notify_Chrooter),
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);

printf("start changerootfs\n");


FILE *fp = fopen(kernbypassMem, "w");
fclose(fp);

CFRunLoopRun();

return 1;


return 1;
}
//#endif
//int main() {}
12 changes: 9 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#define FAKEROOTDIR "/var/MobileSoftwareUpdate/mnt1"
//#define FAKEROOTDIR "/fakeroot"



#ifdef USE_DEV_FAKEVAR
#define FAKEVARDIR "/var/mobile/fakevar"
Expand All @@ -10,3 +7,12 @@
#define FAKEVAR_DMG "/var/mobile/test.dmg"
#define FINAL_FAKEVARDIR FAKEROOTDIR"/private/var"
#endif

// Preferences
#define PREF_PATH @"/var/mobile/Library/Preferences/jp.akusio.kernbypass-unofficial.plist"
#define Notify_Preferences "jp.akusio.kernbypass.preferencechanged"
#define Notify_Alert "jp.akusio.kernbypass.alert"
#define Notify_Chrooter "jp.akusio.chrooter"

#define kernbypassMem "/tmp/kernbypassMem"
#define changerootfsMem "/tmp/changerootfsMem"
21 changes: 14 additions & 7 deletions control
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
Package: jp.akusio.kernbypass
Author: akusio
Maintainer: ichitaso
Name: KernBypass
Version: 0.0.3
Depends: mobilesubstrate, applist, preferenceloader, firmware(>=12.0)
Package: jp.akusio.kernbypass-unofficial
Pre-Depends: firmware (>= 12.0), firmware (<< 14.2)
Depends: mobilesubstrate, preferenceloader
Conflicts: jp.akusio.kernbypass, com.apple.memecity
Replaces: jp.akusio.kernbypass-unofficial
Section: System
Version: 0.0.4
Architecture: iphoneos-arm
Description: kernel level jailbreak detection bypass.
Depiction: http://akusio.github.io/descriptions/kernbypass/index.html
Maintainer: akusio, Misty
Author: akusio, Misty
Section: System
Depiction: https://cydia.ichitaso.com/depiction/kernbypass.html
Homepage: https://ichitaso.com
dev: akusio, Misty, ichitaso
Tag: purpose::extension, compatible::ios12, compatible::ios13, compatible::ios14
Icon: file:///Library/PreferenceBundles/KernBypassPrefs.bundle/[email protected]
Binary file added fakevar13.zip
Binary file not shown.
7 changes: 3 additions & 4 deletions kernbypassd/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
DEBUG = 0
ARCHS = arm64 arm64e

TOOL_NAME = kernbypassd
kernbypassd_FILES = kernbypassd.m
kernbypassd_CFLAGS = -objc-arc
kernbypassd_CODESIGN_FLAGS = -S../ent.plist
$(TOOL_NAME)_FILES = kernbypassd.m
$(TOOL_NAME)_CFLAGS = -objc-arc
$(TOOL_NAME)_CODESIGN_FLAGS = -S../ent.plist

include $(THEOS)/makefiles/common.mk
include $(THEOS_MAKE_PATH)/tool.mk
Loading

0 comments on commit 688b6c8

Please sign in to comment.