Last active
January 12, 2024 07:09
-
-
Save sunflsks/00fe7c740f3b1d9668f55dff80707d03 to your computer and use it in GitHub Desktop.
convert an x86 bin to an arm through oahd-helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
void help(char* curbin) { | |
fprintf(stderr, "%s x86_bin arm64_output\n", curbin); | |
} | |
int main(int argc, char** argv) { | |
printf("this will sigbus but the bin might be valid\n"); | |
if (argc < 3) { | |
help(argv[0]); | |
return 1; | |
} | |
int x86fd = open(argv[1], O_RDONLY); | |
if (x86fd < 0) { | |
perror("x86fd"); | |
return 2; | |
} | |
int armfd = open(argv[2], O_CREAT | O_WRONLY, 0755); | |
if (armfd < 0) { | |
perror("armfd"); | |
return 2; | |
} | |
char* x86fdstr = calloc(2048, 1); | |
char* armfdstr = calloc(2048, 1); | |
sprintf(x86fdstr, "%d", x86fd); | |
sprintf(armfdstr, "%d", armfd); | |
char* args[] = { | |
"oahd-helper", | |
x86fdstr, | |
armfdstr, | |
NULL, | |
}; | |
execv("/usr/libexec/rosetta/oahd-helper", args); | |
perror("execve"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nevermind, turns out my binary needed to be inside MyApp.app/Contents/MacOS/mybinary, not elsewhere.
My next question would be, can this converted binary be run in any way? Opening it will kill it immediately due to it having no signature, and trying to give it a signature results into the following error:
codesign -s "-" --verbose --force Downloads/MyApp.app/Contents/MacOS/mybinary-arm Downloads/MyApp.app/Contents/MacOS/mybinary-arm: main executable failed strict validation