More options

This commit is contained in:
Nick Chan committed 2023-01-18 16:02:43 +08:00
1 parent abfd306bdd
commit f67415067f
4 files changed
+139 -14

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ SRC = $(shell pwd)
DEP = $(SRC)/dep_root
STRIP = strip
CC = cc
CFLAGS += -mmacosx-version-min=10.8 -I$(DEP)/include -I/opt/procursus/include -I$(SRC)/include -I$(SRC) -Wall -Wextra
CFLAGS += -mmacosx-version-min=10.8 -I$(DEP)/include -I/opt/procursus/include -I$(SRC)/include -I$(SRC) -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\"
LIBS = $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a $(DEP)/lib/libplist-2.0.a $(DEP)/lib/libimobiledevice-glue-1.0.a -pthread
LIBS += $(DEP)/lib/libcrypto.35.tbd $(DEP)/lib/libssl.35.tbd $(DEP)/lib/libusb-1.0.a
LIBS += -framework CoreFoundation -framework SystemConfiguration -framework IOKit -framework Security
+2 -1
View File
@@ -12,6 +12,7 @@
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define CLEAR() printf("\33[2K\r");
#define palerain_option_version 129
typedef enum {
LOG_FATAL = 0,
@@ -41,7 +42,7 @@ typedef struct {
// set this value to 0 gracefully exit
extern int spin;
extern int verbose;
extern unsigned int verbose;
extern int demote;
extern bool dfuhelper_only;
+99
View File
@@ -0,0 +1,99 @@
/*
* pongoOS - https://checkra.in
*
* Copyright (C) 2019-2022 checkra1n team
*
* This file is part of pongoOS.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef _KERNINFO_H
#define _KERNINFO_H
#include <stdbool.h>
#include <stdint.h>
#define MAX_BOOTARGS_LEN 256
#define checkrain_option_none 0x00000000
#define checkrain_option_all 0x7fffffff
#define checkrain_option_failure 0x80000000
// Host options
#define checkrain_option_verbose_logging (1 << 0)
#define checkrain_option_demote (1 << 1)
#define checkrain_option_early_exit (1 << 2)
#define checkrain_option_quick_mode (1 << 3)
#define checkrain_option_pongo_shell (1 << 4)
#define checkrain_option_pongo_full (1 << 5)
// KPF options
#define checkrain_option_verbose_boot (1 << 0)
// Global options
#define checkrain_option_safemode (1 << 0)
#define checkrain_option_bind_mount (1 << 1)
#define checkrain_option_overlay (1 << 2)
#define checkrain_option_force_revert (1 << 7) /* keep this at 7 */
typedef uint32_t checkrain_option_t, *checkrain_option_p;
typedef enum {
jailbreak_capability_tfp0 = 1 << 0,
jailbreak_capability_userspace_reboot = 1 << 1,
jailbreak_capability_dyld_ignore_os = 1 << 2, // TODO: This needs a better name
} jailbreak_capability_t, *jailbreak_capability_p;
#define DEFAULT_CAPABILITIES (jailbreak_capability_tfp0|jailbreak_capability_userspace_reboot)
struct kerninfo {
uint64_t size;
uint64_t base;
uint64_t slide;
checkrain_option_t flags;
};
struct kpfinfo {
struct kerninfo k;
checkrain_option_t kpf_flags;
char bootargs[MAX_BOOTARGS_LEN];
};
#define checkrain_set_option(options, option, enabled) do { \
if (enabled) \
options = (checkrain_option_t)(options | option); \
else \
options = (checkrain_option_t)(options & ~option); \
} while (0);
static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_option_t opt)
{
if(flags == checkrain_option_failure)
{
switch(opt)
{
case checkrain_option_safemode:
return true;
default:
return false;
}
}
return (flags & opt) != 0;
}
#endif
+37 -12
View File
@@ -24,16 +24,20 @@
#include "ANSI-color-codes.h"
#include "common.h"
#include "checkra1n.h"
#include "kerninfo.h"
#define CMD_LEN_MAX 512
int verbose = 0;
unsigned int verbose = 0;
int enable_fakefs = 0;
int do_pongo_sleep = 0;
int demote = 0;
char xargs_cmd[0x270] = "xargs serial=3 wdt=-1";
char checkrain_flags_cmd[0x20] = "checkra1n_flags 0x0";
char fakefs[512];
uint32_t checkrain_flags = 0;
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...)
{
int ret = 0;
@@ -60,7 +64,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
printf(BWHT "[Verbose] " WHT);
break;
}
if (verbose >= 1 || loglevel < LOG_VERBOSE)
if (verbose >= (loglevel - 3) || loglevel < LOG_VERBOSE)
{
ret = vprintf(format, args);
va_end(args);
@@ -83,18 +87,16 @@ void *pongo_usb_callback(void *arg)
upload_pongo_file(handle, checkra1n_kpf_pongo, checkra1n_kpf_pongo_len);
issue_pongo_command(handle, "modload");
issue_pongo_command(handle, "kpf_flags 0x00000000");
issue_pongo_command(handle, "checkra1n_flags 0x00000000");
if (enable_fakefs)
{
issue_pongo_command(handle, checkrain_flags_cmd);
if (enable_fakefs) {
issue_pongo_command(handle, fakefs);
}
else
{
} 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");
}
issue_pongo_command(handle, xargs_cmd);
issue_pongo_command(handle, "kpf");
@@ -113,16 +115,21 @@ static struct option longopts[] = {
{"debug-logging", no_argument, NULL, 'V'},
{"boot-args", required_argument, NULL, 'e'},
{"rootfs", required_argument, NULL, 'f'},
{"rootless", required_argument, NULL, 'l'},
{"demote", required_argument, NULL, 'd'},
{"rootless", no_argument, NULL, 'l'},
{"demote", no_argument, NULL, 'd'},
{"force-revert", no_argument, NULL, checkrain_option_force_revert},
{"safe-mode", no_argument, NULL, 's'},
{"version", no_argument, NULL, palerain_option_version},
{NULL, 0, NULL, 0}};
int usage(int e)
{
fprintf(stderr,
"Usage: %s [-DhpPvld] [-e boot arguments] [-f root device]\n"
"Usage: %s [-DhpPvlds] [-e boot arguments] [-f root device]\n"
"Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n"
"iOS/iPadOS 15+ arm64 jailbreaking tool\n\n"
"\t--version\t\t\t\tPrint version\n"
"\t--force-revert\t\t\t\tRemove jailbreak (on rootless)\n"
"\t-D, --dfuhelper-only\t\t\tExit after entering DFU\n"
"\t-h, --help\t\t\t\tShow this help\n"
"\t-p, --pongo-shell\t\t\tBoots to PongoOS shell\n"
@@ -132,6 +139,7 @@ int usage(int e)
"\t-e, --boot-args <boot arguments>\tXNU boot arguments\n"
"\t-f, --rootfs <root device>\t\tBoots rootful setup on <root device>\n"
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
"\t-s, --safe-mode\t\t\t\tEnter safe mode (on rootless)\n"
"\t-d, --demote\t\t\t\tDemote\n",
getprogname());
exit(e);
@@ -140,12 +148,13 @@ int usage(int e)
bool dfuhelper_only = false;
bool pongo_exit = false;
bool start_from_pongo = false;
bool palerain_version = false;
int main(int argc, char *argv[])
{
int opt;
int index;
while ((opt = getopt_long(argc, argv, "DhpPve:f:ld", longopts, NULL)) != -1)
while ((opt = getopt_long(argc, argv, "DhpPvldse:f:", longopts, NULL)) != -1)
{
switch (opt)
{
@@ -177,11 +186,27 @@ int main(int argc, char *argv[])
case 'd':
demote = 1;
break;
case 's':
checkrain_flags |= checkrain_option_safemode;
break;
case checkrain_option_force_revert:
checkrain_flags |= checkrain_option_force_revert;
break;
case palerain_option_version:
palerain_version = true;
break;
default:
usage(1);
break;
}
}
if (palerain_version) {
printf("palera1n %s\n", PALERAIN_VERSION);
return 0;
}
snprintf(checkrain_flags_cmd, 0x20, "checkra1n_flags 0x%x", checkrain_flags);
LOG(LOG_VERBOSE2, "checkrain_flags: %s\n", checkrain_flags_cmd);
for (index = optind; index < argc; index++)
{
if (!strcmp("windows", argv[index]))