Beispiel #1
0
void help(char *app_name)
{
	app_title();
	printf("Usage: %s [options]\n", app_name);
	putchar('\n');
	printf("OPTIONS                 Possible Values       Explanation\n");
	printf(" -i, --image=           File-in               Specify input Extdata\n");
	printf(" -x, --extract=         File-out              Extract data from image\n");
	printf(" -a, --forcedifi=       '0'/'1'               Force reading Primary (0) or Secondary (1) DIFI\n");
	printf(" -p, --info                                   Print info\n");
	printf(" -v, --verbose                                Enable verbose output.\n");
	printf("Extdata (VSXE) File System Options:\n");
	printf(" -d, --FSdir=           Dir-in                Specify Extdata FS Directory\n");
	printf(" -x, --extractFS=       Dir-out               Extract VSXE File System\n");
	printf(" -s, --showFS                                 Display VSXE Extdata FS w/ Mount Points\n");
	printf(" -f, --FStable                                Display VSXE Folder and File Tables\n");
	printf("Extdata Title Database (BDRI) Options:\n");
	printf(" -l, --listDB                                 List the Titles in DB\n");
	printf(" -0, --listTID                                List the Title IDs of the titles in DB\n");
	printf("Extdata Creation Options:\n");
	printf(" -g, --genextdata=      File-in               Create an extdata image for a given image\n");
	printf(" -o, --outimage=        File-out              Output Extdata image\n");
	printf(" -t, --type=            DATA/FS/TDB/IDB       Specify Extdata Type\n");  
	printf(" -u, --uniqueID=        Value                 Specify Extdata Unique ID (16 hex characters)\n");
	printf(" -a, --activedifi=      '0'/'1'               Specify Active DIFI Partition\n");
	printf("AES MAC Options:\n");
	printf(" -1, --keyX=            Value                 Specify KeyX for MAC (32 hex characters)\n");
	printf(" -2, --keyY=            Value                 Specify KeyY for MAC (32 hex characters)\n");
	printf(" -3, --SubDirID=        Value                 Specify Extdata Sub directory ID (8 hex characters)\n");
	printf(" -4, --ImageID=         Value                 Specify Extdata Image ID (8 hex characters)\n");
	printf(" -5, --IsQuotaDat                             Specify if extdata will be Quota.dat?\n");
}
Beispiel #2
0
void help(char *app_name)
{
	app_title();
	printf("Usage: %s [options] <cci filepath>\n", app_name);
	printf("OPTIONS            Possible Values         Explanation\n");
	printf(" -h, --help                                Print this help.\n");
	printf(" -i, --info                                Display CCI info\n");
	printf(" -p, --partition_info                      Display CCI partitions\n");
	printf(" -r, --restore                             Restore unused bytes to CCI file.\n");
	printf(" -t, --trim                                Remove unused bytes from CCI file.\n");
	printf(" -u, --remove_update                       Remove update data\n");
	printf(" -x, --extract=    Dir-out                 Extract CCI partitions to directory\n");
}
Beispiel #3
0
void help(char *app_name)
{
    app_title();
    printf("Usage: %s [options]\n", app_name);
    putchar('\n');
    printf("OPTIONS                 Possible Values       Explanation\n");
    printf(" -i, --decdata=         Directory             Specify Plaintext Icon Data directory\n");
    printf(" -x, --xorpaddir=       Directory             Specify XOR pad directory\n");
    printf(" -c, --iconcache=       File-in               Specify Encrypted Icon Cache\n");
    printf(" -0, --unused_slots=    Decimal Value         Specify Number of icons that exist before the one you want to decrypt\n");
    printf(" -1, --num_decrypt=     Decimal Value         Specify Number of icons to decrypt\n");
    printf(" -g, --genxor                                 Generate XOR pad(s)\n");
    printf(" -d, --decrypt                                Decrypt Icon Data using XOR pad(s)\n");
    printf("'Cache.dat' (image 00000004) Options:\n");
    printf(" -t, --disp_tid                               Display the Title IDs of the icons in the list\n");
    printf(" -b, --empty_image=     File-in               Specify Empty Encrypted 00000004 image\n");
    printf(" -u, --used_image=      File-in               Specify Used Encrypted 00000004 image\n");
    printf(" -o, --dec_list=        File-out              Decrypt Icon cache list from 00000004 image to file\n");

}
Beispiel #4
0
int main(int argc, char *argv[])
{
	app_title();
	
	//Argument Checks
	if(argc < 3){
		printf("[!] Not Enough Arguments\n");
		help(argv[0]);
		return 1;
	}
	if(argc > 3){
		printf("[!] Too Many Arguments\n");
		help(argv[0]);
		return 1;
	}
	
	//Storing Current Working Directory
	char cwd[1024];
	if (getcwdir(cwd, sizeof(cwd)) == NULL){
		printf("[!] Could not store Current Working Directory\n");
		return IO_FAIL;
	}
	
	//Changing to CDN Content Directory
	chdir(argv[1]);
	
	//Processing TIK
	FILE *tik = fopen("cetk","rb");
	if(tik == NULL){
		printf("[!] Could not open 'tik'\n");
		return IO_FAIL;
	}
	TIK_CONTEXT tik_context = process_tik(tik);
	
	//Processing TMD
	FILE *tmd = fopen("tmd","rb");
	if(tmd == NULL){
		printf("[!] Could not open 'tmd'\n");
		return IO_FAIL;
	}
	TMD_CONTEXT tmd_context = process_tmd(tmd);
	
	//Error Checking
	if(tik_context.result != 0 || tmd_context.result != 0){
		printf("[!] Input files could not be processed successfully\n");
		free(tmd_context.content_struct);
		free(tmd_context.content);
		fclose(tik);
		fclose(tmd);
		return FILE_PROCESS_FAIL;
	}
	//TID comparison check
	if(check_tid(tik_context.title_id,tmd_context.title_id) != TRUE){
		printf("[!] Caution, Ticket and TMD Title IDs do not match\n");
		printf("[!] CETK Title ID:  "); u8_hex_print_be(tik_context.title_id,0x8); printf("\n");
		printf("[!] TMD Title ID:   "); u8_hex_print_be(tmd_context.title_id,0x8); printf("\n");
	}
	//Title Version comparison
	if(tik_context.title_version != tmd_context.title_version){
		printf("[!] Caution, Ticket and TMD Title Versions do not match\n");
		printf("[!] CETK Title Ver: %d\n",tik_context.title_version);
		printf("[!] TMD Title Ver:  %d\n",tmd_context.title_version);
	}
	
	//Returning to Original Working Directory
	chdir(cwd);
	
	//Opening Output file
	FILE *output = fopen(argv[2],"wb");
	if(output == NULL){
		printf("[!] Could not create '%s'\n",argv[2]);
		return IO_FAIL;
	}
	
	int result = generate_cia(tmd_context,tik_context,output);
	if(result != 0){
		printf("[!] Failed to Generate %s\n",argv[2]);
		remove(argv[2]);
	}
	else
		printf("[*] %s Generated Sucessfully\n",argv[2]);
	
	return 0;
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	app_title();
	if (argc < 2 || argc > 18){
		printf("\n[!] Must Specify Arguments\n");
		help(argv[0]);
		return ARGC_FAIL;
	}
	INPUT_CONTEXT ctx;
	memset(&ctx,0,sizeof(ctx));
	ctx.command_point = 20;
	//getting commands
	for(int i = (argc - 1); i > 0; i--){
		if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0){
			help(argv[0]);
			return ARGV_FAIL;
		}
		else if (strcmp(argv[i], "--makebnr") == 0){
			if(i < (argc - 1)){
				ctx.make_bnr = TRUE;
				ctx.output_bnr = argv[i+1];
				if (i < ctx.command_point)
					ctx.command_point = i;
			}
			else{
				printf("\n[!] Missing Parameter for '--makebnr'\n");
				return ARGV_FAIL;
			}
		} 
		else if (strcmp(argv[i], "--makeicn") == 0){
			if(i < (argc - 1)){
				ctx.make_icn = TRUE;
				ctx.output_icn = argv[i+1];
				if (i < ctx.command_point)
					ctx.command_point = i;
			}
			else{
				printf("\n[!] Missing Parameter for '--makeicn'\n");
				return ARGV_FAIL;
			}
		}
		else if (strcmp(argv[i], "--readicn") == 0){
			if(i < (argc - 1)){
				ctx.read_icn = TRUE;
				ctx.input_icn = argv[i+1];
				if (i < ctx.command_point)
					ctx.command_point = i;
			}
			else{
				printf("\n[!] Missing Parameter for '--readicn'\n");
				return ARGV_FAIL;
			}
		}
	}
	//Collecting options
	u8 option_count;
	u8 bool_input[3];
	//Make ICN
	memset(&bool_input,FALSE,sizeof(bool_input));
	if(ctx.make_icn == TRUE){
		for(int i = 1; i < (ctx.command_point - 1); i++){
			if(strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--bsf") == 0){
				bool_input[0] = TRUE;
				ctx.input_bsf = argv[i+1];
			}
			else if(strcmp(argv[i], "-s") == 0 || strcmp(argv[i], "--small_icon") == 0){
				bool_input[1] = TRUE;
				ctx.input_small_icon = argv[i+1];
			}
			else if(strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "--large_icon") == 0){
				bool_input[2] = TRUE;
				ctx.input_large_icon = argv[i+1];
			}
		}
		option_count = bool_input[0] + bool_input[1] + bool_input[2];
		if(option_count != 3){
			printf("\n[!] Incorrect Options for command '--makeicn'\n");
			help(argv[0]);
			return 1;
		}
	}
	//Make BNR
	memset(&bool_input,FALSE,sizeof(bool_input));
	if(ctx.make_bnr == TRUE){
		for(int i = 1; i < (ctx.command_point - 1); i++){
			if(strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--cwav") == 0){
				bool_input[0] = TRUE;
				ctx.input_cwav = argv[i+1];
			}
			else if(strcmp(argv[i], "-g") == 0 || strcmp(argv[i], "--cbmd") == 0){
				bool_input[1] = TRUE;
				ctx.input_cbmd = argv[i+1];
			}
		}
		option_count = bool_input[0] + bool_input[1];
		if(option_count != 2){
			printf("\n[!] Incorrect Options for command '--makebnr'\n");
			help(argv[0]);
			return 1;
		}
	}
	//Verbose?
	for(int i = 1; i < ctx.command_point; i++){
		if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0){
			ctx.verbose_bool = TRUE;
		}
	}
	
	//Performing commands
	int result;
	if(ctx.make_icn == TRUE){
		result = icn_process(ctx);
		printf("\n");
		if(result != 0)
			printf("[!] ICN File Failed to Build. Error code: %d\n", result);
		else
			printf("[*] ICN File Built Successfully\n");
	}
	if(ctx.make_bnr == TRUE){
		result = bnr_process(ctx);
		printf("\n");
		if(result != 0)
			printf("[!] BNR File Failed to Build. Error code: %d\n", result);
		else
			printf("[*] BNR File Built Successfully\n");
	}
	if(ctx.read_icn == TRUE){
		result = read_icn_process(ctx);
		printf("\n");
		if(result != 0)
			printf("[!] ICN File Could not be Parsed. Error code: %d\n", result);
		else
			printf("[*] ICN File Parsed Successfully\n");
	}
	return 0;
}