5454#include "recovery.h"
5555#include "idevicerestore.h"
5656
57+ #ifdef HAVE_LIMERA1N
5758#include "limera1n.h"
59+ #endif
5860
5961#include "locking.h"
6062
6163#define VERSION_XML "version.xml"
6264
63- #ifndef IDEVICERESTORE_NOMAIN
65+ #ifndef IDEVICERESTORE_NOMAIN
6466static struct option longopts [] = {
6567 { "ecid" , required_argument , NULL , 'i' },
6668 { "udid" , required_argument , NULL , 'u' },
@@ -73,7 +75,9 @@ static struct option longopts[] = {
7375 { "exclude" , no_argument , NULL , 'x' },
7476 { "shsh" , no_argument , NULL , 't' },
7577 { "keep-pers" , no_argument , NULL , 'k' },
78+ #ifdef HAVE_LIMERA1N
7679 { "pwn" , no_argument , NULL , 'p' },
80+ #endif
7781 { "no-action" , no_argument , NULL , 'n' },
7882 { "cache-path" , required_argument , NULL , 'C' },
7983 { "no-input" , no_argument , NULL , 'y' },
@@ -90,6 +94,11 @@ static struct option longopts[] = {
9094
9195static void usage (int argc , char * argv [], int err )
9296{
97+ #ifdef HAVE_LIMERA1N
98+ #define PWN_FLAG_LINE " -p, --pwn Put device in pwned DFU mode and exit (limera1n devices)\n"
99+ #else
100+ #define PWN_FLAG_LINE ""
101+ #endif
93102 char * name = strrchr (argv [0 ], '/' );
94103 fprintf ((err ) ? stderr : stdout ,
95104 "Usage: %s [OPTIONS] PATH\n" \
@@ -134,7 +143,7 @@ static void usage(int argc, char* argv[], int err)
134143 " -t, --shsh Fetch TSS record and save to .shsh file, then exit\n" \
135144 " -z, --no-restore Do not restore and end after booting to the ramdisk\n" \
136145 " -k, --keep-pers Write personalized components to files for debugging\n" \
137- " -p, --pwn Put device in pwned DFU mode and exit (limera1n devices)\n" \
146+ PWN_FLAG_LINE \
138147 " -P, --plain-progress Print progress as plain step and progress\n" \
139148 " -R, --restore-mode Allow restoring from Restore mode\n" \
140149 " -T, --ticket PATH Use file at PATH to send as AP ticket\n" \
@@ -501,6 +510,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
501510 info ("Device Product Build: %s\n" , (client -> device_build ) ? client -> device_build : "N/A" );
502511
503512 if (client -> flags & FLAG_PWN ) {
513+ #ifdef HAVE_LIMERA1N
504514 recovery_client_free (client );
505515
506516 if (client -> mode != MODE_DFU ) {
@@ -530,6 +540,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
530540 error ("ERROR: This device is not supported by the limera1n exploit" );
531541 return -1 ;
532542 }
543+ #endif
533544 }
534545
535546 if (client -> flags & FLAG_LATEST ) {
@@ -1392,6 +1403,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
13921403 // if the device is in DFU mode, place it into recovery mode
13931404 dfu_client_free (client );
13941405 recovery_client_free (client );
1406+ #ifdef HAVE_LIMERA1N
13951407 if ((client -> flags & FLAG_CUSTOM ) && limera1n_is_supported (client -> device )) {
13961408 info ("connecting to DFU\n" );
13971409 if (dfu_client_new (client ) < 0 ) {
@@ -1406,6 +1418,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
14061418 dfu_client_free (client );
14071419 info ("exploited\n" );
14081420 }
1421+ #endif
14091422 if (dfu_enter_recovery (client , build_identity ) < 0 ) {
14101423 error ("ERROR: Unable to place device into recovery mode from DFU mode\n" );
14111424 if (client -> tss )
@@ -1765,7 +1778,13 @@ int main(int argc, char* argv[]) {
17651778 client -> flags |= FLAG_INTERACTIVE ;
17661779 }
17671780
1768- while ((opt = getopt_long (argc , argv , "dhces:xtpli:u:nC:kyPRT:zv" , longopts , & optindex )) > 0 ) {
1781+ #ifdef HAVE_LIMERA1N
1782+ #define P_FLAG "p"
1783+ #else
1784+ #define P_FLAG ""
1785+ #endif
1786+
1787+ while ((opt = getopt_long (argc , argv , "dhces:xtli:u:nC:kyPRT:zv" P_FLAG , longopts , & optindex )) > 0 ) {
17691788 switch (opt ) {
17701789 case 'h' :
17711790 usage (argc , argv , 0 );
@@ -1855,9 +1874,11 @@ int main(int argc, char* argv[]) {
18551874 idevicerestore_keep_pers = 1 ;
18561875 break ;
18571876
1877+ #ifdef HAVE_LIMERA1N
18581878 case 'p' :
18591879 client -> flags |= FLAG_PWN ;
18601880 break ;
1881+ #endif
18611882
18621883 case 'n' :
18631884 client -> flags |= FLAG_NOACTION ;
0 commit comments