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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_INPUT 4000
// Function to parse POST data
void parse_post(char* data, char* username, char* password) {
sscanf(data, "username=%[^&]&password=%s", username, password);
}
void mask_password(char *src, char *dest) {
size_t len = strlen(src);
for (size_t i = 0; i < len; i++) {
dest[i] = '*';
}
dest[len] = '\0';
}
int main() {
printf("Content-type: text/html\n\n");
printf("<!DOCTYPE html>\n");
printf("<html>\n");
printf("<head><style> .description {");
printf("text-align: justify; /* Make the text have even left and right edges */");
printf(" max-width: 700px; /* Example: Limit the width of the paragraph */ }");
printf(" </style>\n");
printf("<title>KILLSWITCH PUBLIC ACCESS</title>\n");
printf("<style>\n");
printf("a { text-decoration: none; }\n");
printf("a:hover { text-decoration: underline; }\n");
printf("a:link, a:visited, a:active { color: #999999; }\n");
printf(".plate {\n");
printf(" background: linear-gradient(rgba(0,0,0,0.75), rgba(0,0,0,0.2), rgba(0,0,0,0.0)), url(https://computerarson.neocities.org/PvnaJep.png);\n");
printf(" padding-left: 5px;\n");
printf(" padding-right: 5px;\n");
printf(" padding-bottom: 5px;\n");
printf("}\n");
printf(".form-td {\n");
printf(" background-color: #D3D3D3;\n");
printf(" color: white;\n");
printf("}\n");
printf("input {\n");
printf(" border-color: #800000;\n");
printf(" border-style: solid;\n");
printf(" border-width: 1px;\n");
printf(" font-family: verdana;\n");
printf(" font-size: 10px;\n");
printf("}\n");
printf(".submit-btn {\n");
printf(" border-color: #800000;\n");
printf(" border-style: solid;\n");
printf(" border-width: 1px;\n");
printf(" color: #800000;\n");
printf(" font-size: 15px;\n");
printf("}\n");
printf("</style>\n");
printf("</head>\n");
printf("<body bgcolor=\"black\" topmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"margin-top: 0px;\">\n");
printf("<table cellspacing=\"0\" cellpadding=\"0\" width=\"720\" align=\"center\">\n");
printf("<tr><td bgcolor=\"black\" valign=\"top\">\n");
printf("<div style=\"margin-top: 8px; margin-left: 15px; margin-right: 5px;\" align=\"right\" class=\"welcome\">\n");
printf("<b></b> <br><br>\n");
printf("</div>\n");
printf("</td></tr>\n");
printf("<tr style=\"border: 1px solid #800000;\"><td class=\"plate\" style=\"border: 1px solid #800000;\" valign=\"top\">\n");
printf("<div align=\"center\">\n");
printf("<table cellspacing=\"2\" cellpadding=\"10\" border=\"0\" width=\"97%%\">\n");
printf("<tr><td valign=\"top\">\n");
printf("<font face=\"verdana\" size=\"3\" color=\"#999999\" margin=\"1\">\n");
printf("KILLSWITCH PUBLIC ACCESS SYSTEM <br><br>\n");
printf("</font>\n");
printf("<font face=\"verdana\" size=\"2\" color=\"#999999\" margin=\"1\">\n");
printf("</font> <br>\n <font face=\"verdana\" size=\"3\" color=\"#999999\" margin=\"1\">");
char *content_length = getenv("CONTENT_LENGTH");
int len = content_length ? atoi(content_length) : 0;
char post_data[MAX_INPUT] = {0};
fread(post_data, 1, len, stdin);
char username[64] = {0}, password[3000] = {0};
parse_post(post_data, username, password);
if (strlen(username) == 0 || strlen(password) == 0) {
printf("<p>Invalid username or password.</p>");
return 1;
}
// Call external shell script to create jailed user
char cmd[MAX_INPUT];
snprintf(cmd, sizeof(cmd), "sudo /usr/local/bin/create_user.sh '%s' '%s' > /tmp/create_user_log.txt 2>&1", username, password);
int result = system(cmd);
if (WIFEXITED(result) && WEXITSTATUS(result) == 0) {
char masked[64];
mask_password(password, masked);
printf("<h1>Account Created Successfully</h1>\n");
printf("<p><b>Username:</b> %s</p>\n", username);
printf("<p class=\"description\"><b>Password:</b> %s</p>\n", masked);
} else {
printf("<h1>Failure</h1><p>Could not create user. Exit code: %d</p>", WEXITSTATUS(result));
}
return 0;
}
|