From 8df1d35909ec2d57a6845f5b2c26ee1e83cfd032 Mon Sep 17 00:00:00 2001 From: Woodpecker CI Date: Tue, 3 Jun 2025 14:32:34 +0000 Subject: Woodpecker CI 5171f1fdd74e7137c305450dd69a29fa5be4143f [SKIP CI] --- busybox/busybox-suidwrapper.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 busybox/busybox-suidwrapper.c (limited to 'busybox/busybox-suidwrapper.c') diff --git a/busybox/busybox-suidwrapper.c b/busybox/busybox-suidwrapper.c new file mode 100644 index 00000000..e1f91069 --- /dev/null +++ b/busybox/busybox-suidwrapper.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + const char * cmds[] = { + "su", + "ping", + "ping6", + "traceroute", + "passwd", + "login", + "vlock", + "wall" + }; + + const char * baseexec = basename(argv[0]); + + if (!strcmp("busybox-suidwrapper", baseexec)) + { + if (argc > 1 && !strcmp("-l", argv[1])){ + for (int i = 0; i < sizeof(cmds) / sizeof(cmds[0]); ++i) + { + printf("%s ", cmds[i]); + } + printf("\n"); + } else { + printf("busybox SUID wrapper\n\nSupported commands:\n"); + printf("Usage:\n -l\tList available SUID commands\n"); + if (argc > 1) return 1; + } + return 0; + } + + for (int i = 0; i < sizeof(cmds) / sizeof(cmds[0]); ++i) + { + if (!strcmp(cmds[i], baseexec)) + { + char **newargv = malloc(sizeof(char *) * (argc + 2)); + newargv[0] = "/bin/busybox"; + newargv[1] = (char *)baseexec; + for (int i = 1; i < argc; i++) + newargv[i + 1] = argv[i]; + newargv[argc + 1] = NULL; + + int ret = execv("/bin/busybox", newargv); + free(newargv); + perror(argv[0]); + return ret; + } + } + fprintf(stderr, "%s","error: command not in suid whitelist!\n"); + return 1; +} -- cgit v1.2.3