-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunspp.c
58 lines (44 loc) · 983 Bytes
/
unspp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "tools.h"
#include "types.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
u8 *pkg = NULL;
static u64 header_size;
static u64 dec_size;
static void decrypt_spp(void)
{
u16 flags;
u16 type;
u32 hdr_len;
struct keylist *k;
flags = be16(pkg + 0x08);
type = be16(pkg + 0x0a);
hdr_len = be64(pkg + 0x10);
dec_size = be64(pkg + 0x18);
if (type != 4)
fail("no .spp file");
k = keys_get(KEY_SPP);
if (k == NULL)
fail("no key found");
if (sce_decrypt_header(pkg, k) < 0)
fail("header decryption failed");
if (sce_decrypt_data(pkg) < 0)
fail("data decryption failed");
header_size = be64(pkg + 0x10);
dec_size = be64(pkg + 0x18);
}
int main(int argc, char *argv[])
{
if (argc == 3) {
pkg = mmap_file(argv[1]);
decrypt_spp();
memcpy_to_file(argv[2], pkg + header_size, dec_size);
} else {
fail("usage: unspp default.spp target");
}
return 0;
}