From d36693c1d8c69c501b30f1f2883ee5db733b00ef Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Tue, 9 Apr 2024 15:56:58 +0800 Subject: [PATCH] support starting telnetd if requested --- docs/palera1n.1 | 4 +++- include/paleinfo.h | 1 + src/optparse.c | 13 +++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/palera1n.1 b/docs/palera1n.1 index 4c3075c..1e8f0df 100644 --- a/docs/palera1n.1 +++ b/docs/palera1n.1 @@ -9,7 +9,7 @@ .Nd arm64 iOS/iPadOS/tvOS 15.0-17.5, bridgeOS 5.0-8.3 jailbreaking tool .Sh SYNOPSIS .Nm -.Op Fl cCdDEfhIlLnpRsSvV +.Op Fl cCdDEfhIlLnpRsSTvV .Op Fl e Ar Boot arguments .Op Fl k Ar Pongo image .Op Fl o Ar overlay file @@ -221,6 +221,8 @@ section below) will be executed. The loader app and the built in SSH server can as well as any jailbreak-specific apps you have installed. .It Fl S , -no-colors Disable colors on the command line. External programs like checkra1n clones may still output colors. +.It Fl T , -telnetd +Enable the TELNET daemon on port 46, all interfaces. Please note that there is no authentication and is therefore insecure. .It Fl v , -debug-logging Enable debug logging. The option may be repeated for extra verbosity. .It Fl V , -verbose-boot diff --git a/include/paleinfo.h b/include/paleinfo.h index 3a92124..b2bd696 100644 --- a/include/paleinfo.h +++ b/include/paleinfo.h @@ -47,6 +47,7 @@ typedef uint64_t palerain_option_t; // #define palerain_option_emerg_mode (UINT64_C(1) << 29) /* emergency mode (early boot usb shell) */ #define palerain_option_jbinit_log_to_file (UINT64_C(1) << 30) /* deprecated (kept for compatibility) */ #define palerain_option_cli (UINT64_C(1) << 31) /* CLI mode */ +#define palerain_option_telnetd (UINT64_C(1) << 32) /* Enable TELNET daemon */ #define palerain_option_flower_chain (UINT64_C(1) << 61) /* Flower chain */ #define palerain_option_test1 (UINT64_C(1) << 62) /* Developer test option 1 */ diff --git a/src/optparse.c b/src/optparse.c index 12c9762..386e544 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -39,6 +39,7 @@ static struct option longopts[] = { {"force-revert", no_argument, NULL, palerain_option_case_force_revert}, {"no-colors", no_argument, NULL, 'S'}, {"safe-mode", no_argument, NULL, 's'}, + {"telnetd", no_argument, NULL, 'T'}, {"version", no_argument, NULL, palerain_option_case_version}, {"override-libcheckra1nhelper", required_argument, NULL, palerain_option_case_libcheckra1nhelper_path}, {"override-pongo", required_argument, NULL, 'k'}, @@ -65,7 +66,7 @@ static int usage(int e, char* prog_name) { fprintf(stderr, "Usage: %s [-" - "DEhpvVldsSLRnPI" + "DEhpvVldsSTLRnPI" #ifdef DEV_BUILD "12" #endif @@ -113,6 +114,7 @@ static int usage(int e, char* prog_name) "\t-R, --reboot-device\t\t\tReboot connected device in normal mode\n" "\t-s, --safe-mode\t\t\t\tEnter safe mode\n" "\t-S, --no-colors\t\t\t\tDisable colors on the command line\n" + "\t-T, --telnetd\t\t\t\tEnable TELNET daemon on port 46 (insecure)\n" "\t-v, --debug-logging\t\t\tEnable debug logging\n" "\t\tThis option can be repeated for extra verbosity.\n" "\t-V, --verbose-boot\t\t\tVerbose boot\n" @@ -132,7 +134,7 @@ int optparse(int argc, char* argv[]) { int opt; int index; while ((opt = getopt_long(argc, argv, - "DEhpvVlLdsStRnPIe:o:r:K:k:i:" + "DEhpvVlLdsSTtRnPIe:o:r:K:k:i:" #ifdef DEV_BUILD "12" #endif @@ -216,6 +218,9 @@ int optparse(int argc, char* argv[]) { tui_options_safe_mode = true; #endif break; + case 'T': + palerain_flags |= palerain_option_telnetd; + break; case 'k': if (access(optarg, F_OK) != 0) { LOG(LOG_FATAL, "Cannot access pongo file at %s: %d (%s)", optarg, errno, strerror(errno)); @@ -360,6 +365,10 @@ int optparse(int argc, char* argv[]) { return 0; } + if (palerain_flags & palerain_option_telnetd) { + LOG(LOG_WARNING, "telnetd is enabled"); + } + if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && (palerain_flags & palerain_option_setup_rootful)) { palerain_flags &= ~palerain_option_verbose_boot; }