Created
January 5, 2020 05:49
-
-
Save sreehax/d46d0eb9f766184138b8324b9d2b6e45 to your computer and use it in GitHub Desktop.
This program allows you to run any glibc executable on a non-glibc system (such as musl) assuming you have a glibc root at /glibc with the necessary libraries.
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
#define _GNU_SOURCE | |
#include<stdio.h> | |
#include<sched.h> | |
#include<sys/mount.h> | |
#include<unistd.h> | |
#include<stdlib.h> | |
int main(int argc, char *argv[]) { | |
setenv("LC_ALL", "C", 0); | |
unshare(CLONE_NEWNS); | |
mount("/glibc/usr", "/usr", NULL, MS_BIND, NULL); | |
mount("/glibc/var/db/xbps", "/var/db/xbps", NULL, MS_BIND, NULL); | |
setreuid(getuid(), getuid()); | |
setregid(getgid(), getgid()); | |
argv++; | |
if(!argv[0]) { | |
argv = "/bin/bash"; | |
} | |
execvp(argv[0], argv); | |
fprintf(stderr, "Failed to execute program"); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment