Last active 1697368462

Modified supersu from thebackupbox's supersu

Revision 64935edd94ef4c8d4b09afbda668bce57d632bbe

supersu.c Raw
1#include <stdio.h>
2
3int main(int argc,char *argv[]) {
4 int i;
5 if(argc < 4) {
6 fprintf(stderr,"usage: %s uid gid [secondary_gids] absolute-path-of-executable\n",argv[0]);
7 return 0;
8 }
9 if (getuid() != 30064) {
10 //fprintf(stderr,"supersu: uid: %d, euid: %d, uid supposed to be 30064\n",getuid(),geteuid());
11 fprintf(stderr,"supersu: Error security bypass attempt.\n");
12 return 0;
13 }
14 if(getuid() && geteuid()) {
15 fprintf(stderr,"supersu: uid: %d, euid: %d... I have no idea how this is supposed to work. oh well.\n",getuid(),geteuid());
16 }
17 int groups[argc-2];
18 int ngroups=0;
19 char **name;
20 int here=0;
21 for(i=2;i<argc;i++) {
22 if(argv[i][0]=='/') {
23 here=i;
24 break;
25 }
26 }
27 if(here == 0) {
28 fprintf(stderr,"%s: I didn't find an absolute-path in the argument list.\n",argv[0]);
29 return 0;
30 }
31 ngroups=argc-(argc-here)-2;
32 for(i=2;i<here;i++) {
33 groups[i-2]=atoi(argv[i]);
34 }
35 name=argv+i;
36 setgroups(ngroups,groups);
37 setgid(atoi(argv[2]));
38 setuid(atoi(argv[1]));
39 setegid(atoi(argv[2]));
40 seteuid(atoi(argv[1]));
41 execv(*name,name);
42}