rootful ramdisk

This commit is contained in:
Nick Chan committed 2023-01-27 22:06:43 +08:00
1 parent f327c694c8
commit 919ccef99d
3 files changed
+54 -34

No files matched your search

+18 -18
View File
@@ -16,13 +16,13 @@ jobs:
- name: Download dependencies - name: Download dependencies
run: | run: |
cd src cd src
curl -LOOO https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo \ curl -LOOO https://cdn.nickchan.lol/palera1n/c-rewrite/experiments/rootful_rootless/checkra1n-kpf-pongo \
https://static.palera.in/deps/c-rewrite/binpack.dmg \ https://cdn.nickchan.lol/palera1n/c-rewrite/experiments/rootful_rootless/binpack.dmg \
https://static.palera.in/deps/c-rewrite/ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/experiments/rootful_rootless/ramdisk.dmg
cd .. cd ..
curl -LO https://static.palera.in/deps/c-rewrite/dep_root-macos.tgz curl -LO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/dep_root_macos.tgz
tar xf dep_root-macos.tgz tar xf dep_root_macos.tgz
make -j5 download-checkra1n make -j5 download-checkra1n
- name: Build - name: Build
@@ -40,14 +40,14 @@ jobs:
- name: Upload artifact - name: Upload artifact
uses: wangyucode/[email protected] uses: wangyucode/[email protected]
with: with:
host: ${{ secrets.STATIC_FTP_HOST }} host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: 6061 port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: nebula username: palera1n
password: ${{ secrets.STATIC_FTP_PASS }} privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true forceUpload: true
dryRun: false dryRun: false
localDir: 'ready/' localDir: 'ready/'
remoteDir: '/upload/artifacts/c-rewrite' remoteDir: '/palera1n/artifacts/c-rewrite'
build-Linux: build-Linux:
strategy: strategy:
@@ -113,9 +113,9 @@ jobs:
- name: Download dependencies (embedded binaries) - name: Download dependencies (embedded binaries)
run: | run: |
cd src cd src
curl -LOOO https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo \ curl -LOOO https://cdn.nickchan.lol/palera1n/c-rewrite/experiments/rootful_rootless/checkra1n-kpf-pongo \
https://static.palera.in/deps/c-rewrite/binpack.dmg \ https://cdn.nickchan.lol/palera1n/c-rewrite/experiments/rootful_rootless/binpack.dmg \
https://static.palera.in/deps/c-rewrite/ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/experiments/rootful_rootless/ramdisk.dmg
cd .. cd ..
make -j5 download-checkra1n make -j5 download-checkra1n
@@ -232,11 +232,11 @@ jobs:
- name: Upload artifact - name: Upload artifact
uses: wangyucode/[email protected] uses: wangyucode/[email protected]
with: with:
host: ${{ secrets.STATIC_FTP_HOST }} host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: 6061 port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: nebula username: palera1n
password: ${{ secrets.STATIC_FTP_PASS }} privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true forceUpload: true
dryRun: false dryRun: false
localDir: 'ready/' localDir: 'ready/'
remoteDir: '/upload/artifacts/c-rewrite' remoteDir: '/palera1n/artifacts/c-rewrite'
+11
View File
@@ -53,6 +53,11 @@
#define checkrain_option_overlay (1 << 2) #define checkrain_option_overlay (1 << 2)
#define checkrain_option_force_revert (1 << 7) /* keep this at 7 */ #define checkrain_option_force_revert (1 << 7) /* keep this at 7 */
// palera1n option
#define palerain_option_rootful (1 << 0)
#define PALEINFO_MAGIC 'PLSH'
typedef uint32_t checkrain_option_t, *checkrain_option_p; typedef uint32_t checkrain_option_t, *checkrain_option_p;
typedef enum { typedef enum {
@@ -68,6 +73,12 @@ struct kerninfo {
uint64_t slide; uint64_t slide;
checkrain_option_t flags; checkrain_option_t flags;
}; };
struct paleinfo {
uint32_t magic; // 'PLSH' / 0x504c5348
uint32_t version; // 1
checkrain_option_t flags;
char rootdev[0x10];
};
struct kpfinfo { struct kpfinfo {
struct kerninfo k; struct kerninfo k;
checkrain_option_t kpf_flags; checkrain_option_t kpf_flags;
+25 -16
View File
@@ -60,18 +60,21 @@ struct mach_header_64
#define OVERRIDE_MAGIC 0xd803b376 #define OVERRIDE_MAGIC 0xd803b376
unsigned int verbose = 0; unsigned int verbose = 0;
int enable_fakefs = 0; int enable_rootful = 0;
int do_pongo_sleep = 0; int do_pongo_sleep = 0;
int demote = 0; int demote = 0;
char xargs_cmd[0x270] = "xargs serial=3 wdt=-1"; char xargs_cmd[0x270] = "xargs serial=3 wdt=-1";
char checkrain_flags_cmd[0x20] = "checkra1n_flags 0x0"; char checkrain_flags_cmd[0x20] = "checkra1n_flags 0x0";
char fakefs[512]; char palerain_flags_cmd[0x20] = "checkra1n_flags 0x0";
char dtpatch_cmd[0x20] = "dtpatch md0";
char rootfs_cmd[512];
override_file_t override_ramdisk; override_file_t override_ramdisk;
override_file_t override_kpf; override_file_t override_kpf;
override_file_t override_overlay; override_file_t override_overlay;
uint32_t checkrain_flags = 0; uint32_t checkrain_flags = 0;
uint32_t palerain_flags = 0;
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...) int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...)
{ {
@@ -124,19 +127,17 @@ void *pongo_usb_callback(void *arg)
issue_pongo_command(handle, "modload"); issue_pongo_command(handle, "modload");
issue_pongo_command(handle, "kpf_flags 0x00000000"); issue_pongo_command(handle, "kpf_flags 0x00000000");
issue_pongo_command(handle, checkrain_flags_cmd); issue_pongo_command(handle, checkrain_flags_cmd);
if (enable_fakefs) issue_pongo_command(handle, palerain_flags_cmd);
if (enable_rootful)
{ {
issue_pongo_command(handle, fakefs); issue_pongo_command(handle, rootfs_cmd);
} issue_pongo_command(handle, dtpatch_cmd);
else
{
strcat(xargs_cmd, " rootdev=md0");
upload_pongo_file(handle, ramdisk_dmg, ramdisk_dmg_len);
issue_pongo_command(handle, "ramdisk");
upload_pongo_file(handle, binpack_dmg, binpack_dmg_len);
issue_pongo_command(handle, "overlay");
issue_pongo_command(handle, "dtpatch md0");
} }
strcat(xargs_cmd, " rootdev=md0");
upload_pongo_file(handle, ramdisk_dmg, ramdisk_dmg_len);
issue_pongo_command(handle, "ramdisk");
upload_pongo_file(handle, binpack_dmg, binpack_dmg_len);
issue_pongo_command(handle, "overlay");
issue_pongo_command(handle, xargs_cmd); issue_pongo_command(handle, xargs_cmd);
issue_pongo_command(handle, "kpf"); issue_pongo_command(handle, "kpf");
issue_pongo_command(handle, "bootux"); issue_pongo_command(handle, "bootux");
@@ -280,11 +281,12 @@ int main(int argc, char *argv[])
snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg); snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg);
break; break;
case 'f': case 'f':
snprintf(fakefs, sizeof(fakefs), "dtpatch %s", optarg); snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg);
enable_fakefs = 1; snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg);
enable_rootful = 1;
break; break;
case 'l': case 'l':
enable_fakefs = 0; enable_rootful = 0;
break; break;
case 'd': case 'd':
demote = 1; demote = 1;
@@ -331,8 +333,15 @@ int main(int argc, char *argv[])
printf("palera1n %s\n", PALERAIN_VERSION); printf("palera1n %s\n", PALERAIN_VERSION);
return 0; return 0;
} }
if (enable_rootful) {
palerain_flags |= palerain_option_rootful;
}
snprintf(checkrain_flags_cmd, 0x20, "checkra1n_flags 0x%x", checkrain_flags); snprintf(checkrain_flags_cmd, 0x20, "checkra1n_flags 0x%x", checkrain_flags);
snprintf(palerain_flags_cmd, 0x20, "palera1n_flags 0x%x", palerain_flags);
LOG(LOG_VERBOSE2, "checkrain_flags: %s\n", checkrain_flags_cmd); LOG(LOG_VERBOSE2, "checkrain_flags: %s\n", checkrain_flags_cmd);
LOG(LOG_VERBOSE2, "palerain_flags: %s\n", palerain_flags_cmd);
LOG(LOG_VERBOSE4, "binpack_dmg @ %p", binpack_dmg); LOG(LOG_VERBOSE4, "binpack_dmg @ %p", binpack_dmg);
LOG(LOG_VERBOSE4, "ramdisk_dmg @ %p", ramdisk_dmg); LOG(LOG_VERBOSE4, "ramdisk_dmg @ %p", ramdisk_dmg);
LOG(LOG_VERBOSE4, "checkra1n_kpf_pongo @ %p", checkra1n_kpf_pongo); LOG(LOG_VERBOSE4, "checkra1n_kpf_pongo @ %p", checkra1n_kpf_pongo);