fix set callback usage
This commit is contained in:
parent
e5033c980e
commit
5ba155387f
3 changed files with 48 additions and 30 deletions
38
opsb.c
38
opsb.c
|
@ -45,6 +45,7 @@ static int opsb_cmd_del( const CmdParams *cmdparams );
|
|||
static int opsb_cmd_check( const CmdParams *cmdparams );
|
||||
static int opsb_cmd_remove( const CmdParams *cmdparams );
|
||||
static int opsb_set_cb( const CmdParams *cmdparams, SET_REASON reason );
|
||||
static int opsb_set_target_cb( const CmdParams *cmdparams, SET_REASON reason );
|
||||
static int opsb_set_exclusions_cb( const CmdParams *cmdparams, SET_REASON reason );
|
||||
|
||||
Bot *opsb_bot;
|
||||
|
@ -71,23 +72,24 @@ ModuleInfo module_info = {
|
|||
__TIME__,
|
||||
MODULE_FLAG_LOCAL_EXCLUDES,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
static bot_cmd opsb_commands[]=
|
||||
{
|
||||
{"STATUS", opsb_cmd_status, 0, NS_ULEVEL_OPER, opsb_help_status},
|
||||
{"REMOVE", opsb_cmd_remove, 1, NS_ULEVEL_OPER, opsb_help_remove},
|
||||
{"CHECK", opsb_cmd_check, 1, NS_ULEVEL_OPER, opsb_help_check},
|
||||
{"ADD", opsb_cmd_add, 2, NS_ULEVEL_ADMIN, opsb_help_add},
|
||||
{"DEL", opsb_cmd_del, 1, NS_ULEVEL_ADMIN, opsb_help_del},
|
||||
{"LIST", opsb_cmd_list, 0, NS_ULEVEL_ADMIN, opsb_help_list},
|
||||
{"STATUS", opsb_cmd_status, 0, NS_ULEVEL_OPER, opsb_help_status, 0, NULL, NULL},
|
||||
{"REMOVE", opsb_cmd_remove, 1, NS_ULEVEL_OPER, opsb_help_remove, 0, NULL, NULL},
|
||||
{"CHECK", opsb_cmd_check, 1, NS_ULEVEL_OPER, opsb_help_check, 0, NULL, NULL},
|
||||
{"ADD", opsb_cmd_add, 2, NS_ULEVEL_ADMIN, opsb_help_add, 0, NULL, NULL},
|
||||
{"DEL", opsb_cmd_del, 1, NS_ULEVEL_ADMIN, opsb_help_del, 0, NULL, NULL},
|
||||
{"LIST", opsb_cmd_list, 0, NS_ULEVEL_ADMIN, opsb_help_list, 0, NULL, NULL},
|
||||
NS_CMD_END()
|
||||
};
|
||||
|
||||
static bot_setting opsb_settings[]=
|
||||
{
|
||||
{"TARGETIP", opsb.targetip, SET_TYPE_IPV4, 0, MAXHOST,NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetip, opsb_set_cb, (void*)0 },
|
||||
{"TARGETPORT", &opsb.targetport, SET_TYPE_INT, 0, 65535, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetport, opsb_set_cb, (void*)6667 },
|
||||
{"TARGETIP", opsb.targetip, SET_TYPE_IPV4, 0, MAXHOST,NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetip, opsb_set_target_cb, (void*)0 },
|
||||
{"TARGETPORT", &opsb.targetport, SET_TYPE_INT, 0, 65535, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetport, opsb_set_target_cb, (void*)6667 },
|
||||
{"AKILL", &opsb.doakill, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_akill, opsb_set_cb, (void*)1 },
|
||||
{"AKILLTIME", &opsb.akilltime, SET_TYPE_INT, 0, 20736000,NS_ULEVEL_ADMIN, NULL, opsb_help_set_akilltime, opsb_set_cb, (void*)TS_ONE_DAY },
|
||||
{"MAXBYTES", &opsb.maxbytes, SET_TYPE_INT, 0, 100000, NS_ULEVEL_ADMIN, NULL, opsb_help_set_maxbytes, opsb_set_cb, (void*)500 },
|
||||
|
@ -383,6 +385,26 @@ int opsb_set_cb( const CmdParams *cmdparams, SET_REASON reason )
|
|||
opsb.confed = 1;
|
||||
DBAStoreConfigInt ("Confed", &opsb.confed);
|
||||
DelTimer("unconf");
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/** @brief opsb_set_cb
|
||||
*
|
||||
* Set callback
|
||||
* Remove unconfigured warning if needed
|
||||
*
|
||||
* @cmdparams pointer to commands param struct
|
||||
* @cmdparams reason for SET
|
||||
*
|
||||
* @return NS_SUCCESS if suceeds else NS_FAILURE
|
||||
*/
|
||||
|
||||
int opsb_set_target_cb( const CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
if( reason == SET_CHANGE )
|
||||
{
|
||||
opsb_set_cb( cmdparams, reason );
|
||||
init_scanengine();
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
|
|
17
opsb.h
17
opsb.h
|
@ -38,7 +38,7 @@ extern Bot *opsb_bot;
|
|||
/* max scans in the max concurrent scans at any one time */
|
||||
#define MAX_SCANS 100
|
||||
/* max queue is the max amount of scans that may be concurrent and queued. */
|
||||
#define MAX_QUEUE MAX_SCANS * 100
|
||||
#define MAX_QUEUE ( MAX_SCANS * 100 )
|
||||
/* max no of ports to scan */
|
||||
#define MAX_PORTS 50
|
||||
|
||||
|
@ -113,15 +113,14 @@ int findscan(const void *key1, const void *key2);
|
|||
void checkqueue();
|
||||
void addtocache(unsigned long ip);
|
||||
|
||||
|
||||
/* proxy.c */
|
||||
void start_proxy_scan(scaninfo *scandata);
|
||||
int opsb_cmd_status (const CmdParams *cmdparams) ;
|
||||
void check_scan_free(scaninfo *scandata);
|
||||
int init_scanengine();
|
||||
char *type_of_proxy(int type);
|
||||
int get_proxy_by_name(const char *name);
|
||||
int load_ports();
|
||||
void start_proxy_scan( scaninfo *scandata );
|
||||
int opsb_cmd_status( const CmdParams *cmdparams );
|
||||
void check_scan_free( scaninfo *scandata );
|
||||
int init_scanengine( void );
|
||||
char *type_of_proxy( int type );
|
||||
int get_proxy_by_name( const char *name );
|
||||
int load_ports( void );
|
||||
void save_ports( void );
|
||||
|
||||
/* help text */
|
||||
|
|
23
proxy.c
23
proxy.c
|
@ -266,27 +266,24 @@ int init_scanengine( void )
|
|||
router_send_buf_len = ircsnprintf(router_send_buf, BUFSIZE, "cisco\r\ntelnet %s %d\r\n", opsb.targetip, opsb.targetport);
|
||||
wingate_send_buf_len = ircsnprintf(wingate_send_buf, BUFSIZE, "%s:%d\r\n", opsb.targetip, opsb.targetport);
|
||||
|
||||
if (inet_aton(opsb.targetip, &addr) != 0) {
|
||||
laddr = htonl(addr.s_addr);
|
||||
} else {
|
||||
if (inet_aton(opsb.targetip, &addr) == 0)
|
||||
{
|
||||
nlog(LOG_ERROR, "Couldn't Setup connect address for init_scan_engine: %s", opsb.targetip);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
laddr = htonl(addr.s_addr);
|
||||
/* taken from libopm */
|
||||
socks4_send_buf_len = ircsnprintf(socks4_send_buf, BUFSIZE, "%c%c%c%c%c%c%c%c%c", 4, 1,
|
||||
(((unsigned short) opsb.targetport) >> 8) & 0xFF,
|
||||
(((unsigned short) opsb.targetport) & 0xFF),
|
||||
(char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
|
||||
(char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF, 0);
|
||||
|
||||
(((unsigned short) opsb.targetport) & 0xFF),
|
||||
(char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
|
||||
(char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF, 0);
|
||||
socks5_send_buf_len = ircsnprintf(socks5_send_buf, BUFSIZE, "%c%c%c%c%c%c%c%c%c%c%c%c%c", 5, 1, 0, 5, 1, 0, 1,
|
||||
(char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
|
||||
(char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF,
|
||||
(((unsigned short) opsb.targetport) >> 8) & 0xFF,
|
||||
(((unsigned short) opsb.targetport) & 0xFF));
|
||||
|
||||
(char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
|
||||
(char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF,
|
||||
(((unsigned short) opsb.targetport) >> 8) & 0xFF,
|
||||
(((unsigned short) opsb.targetport) & 0xFF));
|
||||
return NS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/** @brief start_proxy_scan
|
||||
|
|
Reference in a new issue