supersu.c
· 1.0 KiB · C
Raw
#include <stdio.h>
int main(int argc,char *argv[]) {
int i;
if(argc < 4) {
fprintf(stderr,"usage: %s uid gid [secondary_gids] absolute-path-of-executable\n",argv[0]);
return 0;
}
if (getuid() != 30064) {
//fprintf(stderr,"supersu: uid: %d, euid: %d, uid supposed to be 30064\n",getuid(),geteuid());
fprintf(stderr,"supersu: Error security bypass attempt.\n");
return 0;
}
if(getuid() && geteuid()) {
fprintf(stderr,"supersu: uid: %d, euid: %d... I have no idea how this is supposed to work. oh well.\n",getuid(),geteuid());
}
int groups[argc-2];
int ngroups=0;
char **name;
int here=0;
for(i=2;i<argc;i++) {
if(argv[i][0]=='/') {
here=i;
break;
}
}
if(here == 0) {
fprintf(stderr,"%s: I didn't find an absolute-path in the argument list.\n",argv[0]);
return 0;
}
ngroups=argc-(argc-here)-2;
for(i=2;i<here;i++) {
groups[i-2]=atoi(argv[i]);
}
name=argv+i;
setgroups(ngroups,groups);
setgid(atoi(argv[2]));
setuid(atoi(argv[1]));
setegid(atoi(argv[2]));
seteuid(atoi(argv[1]));
execv(*name,name);
}
1 | #include <stdio.h> |
2 | |
3 | int 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 | } |