-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
33 lines (31 loc) · 756 Bytes
/
main.c
File metadata and controls
33 lines (31 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#include <string.h>
#define DEFAULT_USER "root"
#define DEFAULT_SHELL "/bin/bash"
#define CREDITS "please - please don't take me too seriously.\nMade by Cynthia Revström <me@cynthia.re> - https://cynthia.re\n"
int main(int argc, char** argv)
{
if(argc < 2) {
printf("Please what?\n");
return 0;
}
if(strcmp(argv[1], "root")) {
printf(CREDITS);
printf("type root as the first argument to please\n");
return 0;
}
printf("No worries.\n");
struct passwd* pw;
struct passwd pw_copy;
pw = getpwnam(DEFAULT_USER);
pw_copy = *pw;
pw = &pw_copy;
setuid(pw->pw_uid);
setgid(pw->pw_gid);
char* args[] = { DEFAULT_SHELL, NULL };
execvp(args[0], args);
return 0;
}