1
Fork 0
mirror of https://github.com/naehrwert/scetool.git synced 2025-04-25 06:07:47 +00:00

Added more info

Metadata section headers
Signature info
This commit is contained in:
Sorvigolova 2018-05-24 05:05:30 +04:00
parent c1a33d86d7
commit b22413fb94
8 changed files with 70 additions and 36 deletions

Binary file not shown.

View file

@ -9,4 +9,5 @@ void ecdsa_sign(u8 *hash, u8 *R, u8 *S);
void ec_priv_to_pub(u8 *k, u8 *Q);
void elt_inv(u8 *d, u8 *a);
void get_m (u8 *r, u8 *s, u8 *e, u8 *k, u8 *m);
int ecdsa_get_params(u32 type, u8 *p, u8 *a, u8 *b, u8 *N, u8 *Gx, u8 *Gy);
#endif

View file

@ -248,11 +248,11 @@ typedef struct
Elf32_Word sh_type; /* Section type */
Elf32_Word sh_flags; /* Section flags */
Elf32_Addr sh_addr; /* Section virtual addr at execution */
Elf32_Off sh_offset; /* Section file offset */
Elf32_Off sh_offset; /* Section file offset */
Elf32_Word sh_size; /* Section size in bytes */
Elf32_Word sh_link; /* Link to another section */
Elf32_Word sh_info; /* Additional section information */
Elf32_Word sh_addralign; /* Section alignment */
Elf32_Word sh_addralign; /* Section alignment */
Elf32_Word sh_entsize; /* Entry size if section holds table */
} Elf32_Shdr;
@ -262,11 +262,11 @@ typedef struct
Elf64_Word sh_type; /* Section type */
Elf64_Xword sh_flags; /* Section flags */
Elf64_Addr sh_addr; /* Section virtual addr at execution */
Elf64_Off sh_offset; /* Section file offset */
Elf64_Off sh_offset; /* Section file offset */
Elf64_Xword sh_size; /* Section size in bytes */
Elf64_Word sh_link; /* Link to another section */
Elf64_Word sh_info; /* Additional section information */
Elf64_Xword sh_addralign; /* Section alignment */
Elf64_Xword sh_addralign; /* Section alignment */
Elf64_Xword sh_entsize; /* Entry size if section holds table */
} Elf64_Shdr;
@ -502,7 +502,7 @@ typedef struct
typedef struct
{
Elf32_Word p_type; /* Segment type */
Elf32_Off p_offset; /* Segment file offset */
Elf32_Off p_offset; /* Segment file offset */
Elf32_Addr p_vaddr; /* Segment virtual address */
Elf32_Addr p_paddr; /* Segment physical address */
Elf32_Word p_filesz; /* Segment size in file */
@ -515,7 +515,7 @@ typedef struct
{
Elf64_Word p_type; /* Segment type */
Elf64_Word p_flags; /* Segment flags */
Elf64_Off p_offset; /* Segment file offset */
Elf64_Off p_offset; /* Segment file offset */
Elf64_Addr p_vaddr; /* Segment virtual address */
Elf64_Addr p_paddr; /* Segment physical address */
Elf64_Xword p_filesz; /* Segment size in file */

View file

@ -93,8 +93,11 @@ static void _print_metadata_section_header_header(FILE *fp)
void _print_metadata_section_header(FILE *fp, metadata_section_header_t *msh, u32 idx)
{
fprintf(fp, " %03d %08llX %08llX %02X %02X ",
idx, _ES64(msh->data_offset), _ES64(msh->data_size), _ES32(msh->type), _ES32(msh->index));
const s8 *name;
name = _get_name(_msh_types, _ES32(msh->type));
fprintf(fp, " %03d %08llX %08llX %s %02X ",
idx, _ES64(msh->data_offset), _ES64(msh->data_size), name, _ES32(msh->index));
if(_ES32(msh->hashed) == METADATA_SECTION_HASHED)
fprintf(fp, "[YES] %02X ", _ES32(msh->sha1_index));
@ -129,7 +132,7 @@ void _print_sce_file_keys(FILE *fp, sce_buffer_ctxt_t *ctxt)
void _print_sce_signature(FILE *fp, signature_t *sig)
{
fprintf(fp, "[*] Signature:\n");
fprintf(fp, "[*] Signature Info:\n");
_hexdump(fp, " R", 0, sig->r, SIGNATURE_R_SIZE, FALSE);
_hexdump(fp, " S", 0, sig->s, SIGNATURE_S_SIZE, FALSE);
}
@ -138,7 +141,7 @@ void _print_sce_signature_status(FILE *fp, sce_buffer_ctxt_t *ctxt, u8 *keyset)
{
u8 hash[0x14];
u8 Q[0x28];
u8 M[0x14];
u8 K[0x14];
u8 zero_buf[0x14];
keyset_t *ks;
@ -156,16 +159,34 @@ void _print_sce_signature_status(FILE *fp, sce_buffer_ctxt_t *ctxt, u8 *keyset)
//Generate header hash.
sha1(ctxt->scebuffer, _ES64(ctxt->metah->sig_input_length), hash);
_hexdump(fp, " E", 0, hash, 0x14, FALSE);
_hexdump(fp, " H", 0, hash, 0x14, FALSE);
//get curve params
u8 *ec_p = (u8 *)malloc(sizeof(u8) * 20);
u8 *ec_a = (u8 *)malloc(sizeof(u8) * 20);
u8 *ec_b = (u8 *)malloc(sizeof(u8) * 20);
u8 *ec_N = (u8 *)malloc(sizeof(u8) * 21);
u8 *ec_Gx = (u8 *)malloc(sizeof(u8) * 20);
u8 *ec_Gy = (u8 *)malloc(sizeof(u8) * 20);
memset(ec_p, 0, 20);
memset(ec_a, 0, 20);
memset(ec_b, 0, 20);
memset(ec_N, 0, 21);
memset(ec_Gx, 0, 20);
memset(ec_Gy, 0, 20);
//Print curve order N
if (ecdsa_get_params(ks->ctype, ec_p, ec_a, ec_b, ec_N, ec_Gx, ec_Gy) == 0)
_hexdump (fp, " N", 0, ec_N + 1, 20, FALSE);
//Set ecdsa params
ecdsa_set_curve(ks->ctype);
ecdsa_set_pub(ks->pub);
//validate private key and calculate M
//Validate private key and calculate K
ec_priv_to_pub(ks->priv, Q);
get_m(ctxt->sig->r, ctxt->sig->s, hash, ks->priv, M);
get_m(ctxt->sig->r, ctxt->sig->s, hash, ks->priv, K);
if (memcmp(ks->pub, Q, sizeof(Q)) == 0)
_hexdump (fp, " M", 0, M, 0x14, FALSE);
_hexdump (fp, " K", 0, K, 0x14, FALSE);
//Validate the signature.
memset(zero_buf, 0, sizeof(zero_buf));

View file

@ -96,8 +96,8 @@
#define METADATA_SECTION_TYPE_SHDR 1
/*! Program header. */
#define METADATA_SECTION_TYPE_PHDR 2
/*! Unknown header type 3. */
#define METADATA_SECTION_TYPE_UNK_3 3
/*! Sceversion section. */
#define METADATA_SECTION_TYPE_SCEV 3
/*! Section is hashed. */
#define METADATA_SECTION_HASHED 2
@ -432,10 +432,10 @@ typedef struct _opt_header
#define CAP_FLAG_1 0x01 //only seen in PPU selfs
#define CAP_FLAG_2 0x02 //only seen in PPU selfs
#define CAP_FLAG_4 0x04 //only seen in bdj PPU self
#define CAP_FLAG_DEH 0x08
#define CAP_FLAG_DEX 0x10
#define CAP_FLAG_CEX 0x20
#define CAP_FLAG_ARCADE 0x40
#define CAP_FLAG_DEH 0x08 //00001000b
#define CAP_FLAG_DEX 0x10 //00010000b
#define CAP_FLAG_CEX 0x20 //00100000b
#define CAP_FLAG_ARCADE 0x40 //01000000b
#define UNK7_2000 0x2000 //hddbind?
#define UNK7_20000 0x20000 //flashbind?

View file

@ -50,32 +50,32 @@ void _print_self_header(FILE *fp, self_header_t *h)
{
fprintf(fp, "[*] Extended Header:\n");
fprintf(fp, "[*] Signed Elf Header:\n");
fprintf(fp, " Version 0x%016llX\n", _ES64(h->header_type));
fprintf(fp, " Program Info Offset 0x%016llX\n", _ES64(h->app_info_offset));
fprintf(fp, " ELF Offset 0x%016llX\n", _ES64(h->elf_offset));
fprintf(fp, " PH Offset 0x%016llX\n", _ES64(h->phdr_offset));
fprintf(fp, " Version 0x%016llX\n", _ES64(h->header_type));
fprintf(fp, " Prog Ident Header Offset 0x%016llX\n", _ES64(h->app_info_offset));
fprintf(fp, " ELF Header Offset 0x%016llX\n", _ES64(h->elf_offset));
fprintf(fp, " ELF Program Headers Offset 0x%016llX\n", _ES64(h->phdr_offset));
if ((_ES64(h->shdr_offset)) != 0)
fprintf(fp, " SH Offset 0x%016llX\n", _ES64(h->shdr_offset));
fprintf(fp, " ELF Section Headers Offset 0x%016llX\n", _ES64(h->shdr_offset));
else
fprintf(fp, " SH Offset N\\A\n");
fprintf(fp, " ELF Section Headers Offset N\\A\n");
fprintf(fp, " Segment Info Offset 0x%016llX\n", _ES64(h->segment_info_offset));
fprintf(fp, " Segment Info Offset 0x%016llX\n", _ES64(h->segment_info_offset));
if ((_ES64(h->sce_version_offset)) != 0)
fprintf(fp, " SCE Version Offset 0x%016llX\n", _ES64(h->sce_version_offset));
fprintf(fp, " SCE Version Offset 0x%016llX\n", _ES64(h->sce_version_offset));
else
fprintf(fp, " SCE Version Offset N\\A\n");
fprintf(fp, " SCE Version Offset N\\A\n");
if ((_ES64(h->control_info_offset)) != 0)
{
fprintf(fp, " Control Info Offset 0x%016llX\n", _ES64(h->control_info_offset));
fprintf(fp, " Control Info Size 0x%016llX\n", _ES64(h->control_info_size));
fprintf(fp, " Supplemental Header Offset 0x%016llX\n", _ES64(h->control_info_offset));
fprintf(fp, " Supplemental Header Size 0x%016llX\n", _ES64(h->control_info_size));
}
else
{
fprintf(fp, " Control Info Offset N\\A\n");
fprintf(fp, " Control Info Size N\\A\n");
fprintf(fp, " Supplemental Header Offset N\\A\n");
fprintf(fp, " Supplemental Header Size N\\A\n");
}
//fprintf(fp, " padding 0x%016llX\n", _ES64(h->padding));
}
@ -84,7 +84,7 @@ void _print_app_info(FILE *fp, app_info_t *ai)
{
const s8 *name;
fprintf(fp, "[*] Program Ident Header:\n");
fprintf(fp, "[*] Program Identification Header:\n");
name = _get_name(_auth_ids, _ES64(ai->auth_id));
if(name != NULL)
@ -167,7 +167,7 @@ void _print_control_info(FILE *fp, control_info_t *ci)
time_t t;
tm* aTm;
fprintf(fp, "[*] Control Info\n");
fprintf(fp, "[*] Supplemental Header\n");
name = _get_name(_control_info_types, _ES32(ci->type));
if(name != NULL)

View file

@ -221,6 +221,15 @@ id_to_name_t _ph_types[] =
{0, NULL}
};
/*! Metadata section header types. */
id_to_name_t _msh_types[] =
{
{METADATA_SECTION_TYPE_SHDR, "SHDR"},
{METADATA_SECTION_TYPE_PHDR, "PHDR"},
{METADATA_SECTION_TYPE_SCEV, "SCEV"},
{0, NULL}
};
/*! Key types. */
id_to_name_t _key_categories[] =
{

View file

@ -45,6 +45,9 @@ extern id_to_name_t _sh_types[];
/*! Program header types. */
extern id_to_name_t _ph_types[];
/*! Metadata section header types. */
extern id_to_name_t _msh_types[];
/*! Key types. */
extern id_to_name_t _key_categories[];