Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added stub privilege checker part 3 #262

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ format).
```
usage: vita-elf-create [-v|vv|vvv] [-n] [-e config.yml] input.elf output.velf
-v,-vv,-vvv: logging verbosity (more v is more verbose)
-s : strip the output ELF
-n : allow empty imports
-e yml : optional config options
-g yml : generate an export config from ELF symbols
-m list : specify the list of module entrypoints
-l op name : long name option name
-p : skip stub privilege check
input.elf : input ARM ET_EXEC type ELF
output.velf: output ET_SCE_RELEXEC type ELF
```
Expand Down
18 changes: 3 additions & 15 deletions src/vita-elf-create/elf-create-argp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int parse_arguments(int argc, char *argv[], elf_create_args *arguments)
arguments->is_test_stripping = 0;
arguments->is_bypass_stub_privilege_check = 0;

while ((c = getopt(argc, argv, "vne:sg:m:l:")) != -1)
while ((c = getopt(argc, argv, "vne:sg:m:p")) != -1)
{
switch (c)
{
Expand All @@ -41,20 +41,8 @@ int parse_arguments(int argc, char *argv[], elf_create_args *arguments)
case 'm':
entrypoint_list = optarg;
break;
case 'l': // long name option

if (strlen(optarg) == 0) {
fprintf(stderr, "long name option lemgth is 0\n");
return -1;
}

if (strcmp(optarg, "skip_stub_privilege_check") == 0) {
arguments->is_bypass_stub_privilege_check = 1;
} else {
fprintf(stderr, "unknown long name option (%s)\n", optarg);
return -1;
}

case 'p':
arguments->is_bypass_stub_privilege_check = 1;
break;
case '?':
fprintf(stderr, "unknown option -%c\n", optopt);
Expand Down
6 changes: 3 additions & 3 deletions src/vita-elf-create/vita-elf-create.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static int usage(int argc, char *argv[])
"\t-e yml : optional config options\n"
"\t-g yml : generate an export config from ELF symbols\n"
"\t-m list : specify the list of module entrypoints\n"
"\t-l op name : long name option name\n"
"\t-p : skip stub privilege check\n"
"\tinput.elf : input ARM ET_EXEC type ELF\n"
"\toutput.velf: output ET_SCE_RELEXEC type ELF\n", argc > 0 ? argv[0] : "vita-elf-create");
return 0;
Expand Down Expand Up @@ -551,7 +551,7 @@ int main(int argc, char *argv[])

if (prev_privilege != ~0 && prev_privilege != (flags & VITA_STUB_GEN_2_FLAG_IS_KERNEL)) {
printf("Importing stubs with different privileges.\n");
printf("\tIf needed for exploit, add flag \"-l skip_stub_privilege_check\" and try again.\n");
printf("\tIf needed for exploit, add flag \"-p\" and try again.\n");
printf("\tIf not, check the stub you are importing to make sure there are no mistake regarding privileges.\n");
return EXIT_FAILURE;
}
Expand All @@ -571,7 +571,7 @@ int main(int argc, char *argv[])

if (prev_privilege != ~0 && prev_privilege != (flags & VITA_STUB_GEN_2_FLAG_IS_KERNEL)) {
printf("Importing stubs with different privileges.\n");
printf("\tIf needed for exploit, add flag \"-l skip_stub_privilege_check\" and try again.\n");
printf("\tIf needed for exploit, add flag \"-p\" and try again.\n");
printf("\tIf not, check the stub you are importing to make sure there are no mistake regarding privileges.\n");
return EXIT_FAILURE;
}
Expand Down