forked from cSploit/daemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.c
More file actions
83 lines (72 loc) · 2.14 KB
/
Copy pathcontroller.c
File metadata and controls
83 lines (72 loc) · 2.14 KB
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
/* cSploit - a simple penetration testing suite
* Copyright (C) 2014 Massimo Dragano aka tux_mind <tux_mind@csploit.org>
*
* cSploit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cSploit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cSploit. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <csploit/message.h>
#include <csploit/logger.h>
#include <csploit/control_messages.h>
#include "connection.h"
#include "controller.h"
#include "authenticator.h"
#include "command.h"
#include "handler.h"
#include "cSploitd.h"
//TODO #incude "module.h"
//TODO
#define on_module_request(c, m) 0
/**
* @brief handle a daemon control request
* @param m the received control message
* @returns 0 on success, -1 on error.
*/
int on_daemon_request(conn_node *c, message *m) {
switch(m->data[0]) {
case DMON_STOP:
stop_daemon();
return 0;
default:
print( ERROR, "unkown daemon request code: %02hhX", m->data[0] );
return -1;
}
}
int on_control_request(conn_node *c, message *m) {
char logged;
if(m->data[0] == AUTH)
return on_auth_request(c, m);
pthread_mutex_lock(&(c->control.mutex));
logged = c->logged;
pthread_mutex_unlock(&(c->control.mutex));
if(!logged) {
return on_unathorized_request(c, m);
}
switch (m->data[0]) {
case CMD_START:
case CMD_SIGNAL:
return on_command_request(c, m);
case HNDL_LIST:
return on_handler_request(c, m);
case MOD_LIST:
case MOD_START:
case MOD_END:
return on_module_request(c, m);
case DMON_STOP:
return on_daemon_request(c, m);
default:
print( ERROR, "unkown control code: %02hhX", m->data[0] );
return -1;
}
}