Skip to content

Commit

Permalink
implement plugin_unload function in all plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Koeppe authored and LocutusOfBorg committed Jan 26, 2023
1 parent bde91b9 commit e279cea
Show file tree
Hide file tree
Showing 34 changed files with 483 additions and 57 deletions.
20 changes: 20 additions & 0 deletions plug-ins/arp_cop/arp_cop.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
int plugin_load(void *);
static int arp_cop_init(void *);
static int arp_cop_fini(void *);
static int arp_cop_unload(void *);

static void parse_arp(struct packet_object *po);
static void arp_init_list(void);
Expand All @@ -53,6 +54,8 @@ struct plugin_ops arp_cop_ops = {
.init = &arp_cop_init,
/* deactivation function */
.fini = &arp_cop_fini,
/* clean-up function */
.unload = &arp_cop_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -94,6 +97,23 @@ static int arp_cop_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int arp_cop_unload(void *dummy)
{
struct hosts_list *h;

/* variable not used */
(void) dummy;

/* free dynamically allocated memory */
while (!LIST_EMPTY(&arp_cop_table)) {
h = LIST_FIRST(&arp_cop_table);
LIST_REMOVE(h, next);
SAFE_FREE(h);
}

return PLUGIN_UNLOADED;
}

/*********************************************************/

/* Parse the arp packets */
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/autoadd/autoadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
int plugin_load(void *);
static int autoadd_init(void *);
static int autoadd_fini(void *);
static int autoadd_unload(void *);

static void parse_arp(struct packet_object *po);
static int add_to_victims(void *group, struct packet_object *po);
Expand All @@ -49,6 +50,8 @@ struct plugin_ops autoadd_ops = {
.init = &autoadd_init,
/* deactivation function */
.fini = &autoadd_fini,
/* clean-up function */
.unload = &autoadd_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -85,6 +88,14 @@ static int autoadd_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int autoadd_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*********************************************************/

/* Parse the arp packets */
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/chk_poison/chk_poison.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static pthread_mutex_t poison_mutex = PTHREAD_MUTEX_INITIALIZER;
int plugin_load(void *);
static int chk_poison_init(void *);
static int chk_poison_fini(void *);
static int chk_poison_unload(void *);
static void parse_icmp(struct packet_object *po);

/* plugin operations */
Expand All @@ -68,6 +69,8 @@ struct plugin_ops chk_poison_ops = {
.init = &chk_poison_init,
/* deactivation function */
.fini = &chk_poison_fini,
/* clean-up function */
.unload = &chk_poison_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -183,6 +186,14 @@ static int chk_poison_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int chk_poison_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*********************************************************/

/* Check if it's the reply to our bougs request */
Expand Down
21 changes: 18 additions & 3 deletions plug-ins/dns_spoof/dns_spoof.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static SLIST_HEAD(, rr_entry) additional_list;
int plugin_load(void *);
static int dns_spoof_init(void *);
static int dns_spoof_fini(void *);
static int dns_spoof_unload(void *);
static int load_db(void);
static int parse_line(const char *str, int line, int *type_p, char **ip_p, u_int16 *port_p, char **name_p, u_int32 *ttl_p);
static void dns_spoof(struct packet_object *po);
Expand Down Expand Up @@ -124,6 +125,8 @@ struct plugin_ops dns_spoof_ops = {
.init = &dns_spoof_init,
/* deactivation function */
.fini = &dns_spoof_fini,
/* clean-up function */
.unload = &dns_spoof_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -160,14 +163,26 @@ static int dns_spoof_init(void *dummy)

static int dns_spoof_fini(void *dummy)
{
struct dns_spoof_entry *d;

/* variable not used */
(void) dummy;

/* remove the hook */
hook_del(HOOK_PROTO_DNS, &dns_spoof);

return PLUGIN_FINISHED;
}


/*
* unload database list
*/
static int dns_spoof_unload(void *dummy)
{
struct dns_spoof_entry *d;

/* variable not used */
(void) dummy;

/* Free dynamically allocated memory */
while (!SLIST_EMPTY(&dns_spoof_head)) {
d = SLIST_FIRST(&dns_spoof_head);
Expand All @@ -178,7 +193,7 @@ static int dns_spoof_fini(void *dummy)
}


return PLUGIN_FINISHED;
return PLUGIN_UNLOADED;
}


Expand Down
11 changes: 11 additions & 0 deletions plug-ins/dos_attack/dos_attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
int plugin_load(void *);
static int dos_attack_init(void *);
static int dos_attack_fini(void *);
static int dos_attack_unload(void *);
static void parse_arp(struct packet_object *po);

#ifdef WITH_IPV6
Expand Down Expand Up @@ -65,6 +66,8 @@ struct plugin_ops dos_attack_ops = {
.init = &dos_attack_init,
/* deactivation function */
.fini = &dos_attack_fini,
/* clean-up function */
.unload = &dos_attack_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -164,6 +167,14 @@ static int dos_attack_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int dos_attack_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*********************************************************/

/*
Expand Down
21 changes: 21 additions & 0 deletions plug-ins/dummy/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int plugin_load(void *);
/* additional functions */
static int dummy_init(void *);
static int dummy_fini(void *);
static int dummy_unload(void *);


/* plugin operations */
Expand All @@ -55,6 +56,8 @@ struct plugin_ops dummy_ops = {
.init = &dummy_init,
/* deactivation function */
.fini = &dummy_fini,
/* clean-up function */
.unload = &dummy_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -118,6 +121,24 @@ static int dummy_fini(void *dummy)
}


static int dummy_unload(void *dummy)
{
/* variable not used */
(void) dummy;

/*
* called during application shutdown.
* usually to free allocated memory during
* load function, init function or through
* the course of the plugin's lifetime
* but not free'd on purpose.
*/
USER_MSG("DUMMY: plugin clean-up\n");
return PLUGIN_UNLOADED;
}



/* EOF */

// vim:ts=3:expandtab
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/find_conn/find_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
int plugin_load(void *);
static int find_conn_init(void *);
static int find_conn_fini(void *);
static int find_conn_unload(void *);

static void parse_arp(struct packet_object *po);

Expand All @@ -47,6 +48,8 @@ struct plugin_ops find_conn_ops = {
.init = &find_conn_init,
/* deactivation function */
.fini = &find_conn_fini,
/* clean-up function */
.unload = &find_conn_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -82,6 +85,14 @@ static int find_conn_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int find_conn_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*********************************************************/

/* Parse the arp request */
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/find_ettercap/find_ettercap.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
int plugin_load(void *);
static int find_ettercap_init(void *);
static int find_ettercap_fini(void *);
static int find_ettercap_unload(void *);
static void parse_ip(struct packet_object *po);
static void parse_icmp(struct packet_object *po);
static void parse_tcp(struct packet_object *po);
Expand All @@ -54,6 +55,8 @@ struct plugin_ops find_ettercap_ops = {
.init = &find_ettercap_init,
/* deactivation function */
.fini = &find_ettercap_fini,
/* clean-up function */
.unload = &find_ettercap_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -93,6 +96,14 @@ static int find_ettercap_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int find_ettercap_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*
* parse the packet for ettercap traces
*/
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/find_ip/find_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
int plugin_load(void *);
static int find_ip_init(void *);
static int find_ip_fini(void *);
static int find_ip_unload(void *);
static int in_list(struct ip_addr *scanip);
static struct ip_addr *search_netmask(void);
static struct ip_addr *search_targets(void);
Expand All @@ -47,6 +48,8 @@ struct plugin_ops find_ip_ops = {
.init = &find_ip_init,
/* deactivation function */
.fini = &find_ip_fini,
/* clean-up function */
.unload = &find_ip_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -101,6 +104,14 @@ static int find_ip_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int find_ip_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*********************************************************/

/* Check if the IP is in the host list */
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/finger/finger.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static char fingerprint[FINGER_LEN + 1];
int plugin_load(void *);
static int finger_init(void *);
static int finger_fini(void *);
static int finger_unload(void *);

static void get_finger(struct packet_object *po);
static int good_target(struct ip_addr *ip, u_int16 *port);
Expand All @@ -64,6 +65,8 @@ struct plugin_ops finger_ops = {
.init = &finger_init,
/* deactivation function */
.fini = &finger_fini,
/* clean-up function */
.unload = &finger_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -132,6 +135,14 @@ static int finger_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int finger_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}

/*********************************************************/

/*
Expand Down
11 changes: 11 additions & 0 deletions plug-ins/finger_submit/finger_submit.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
int plugin_load(void *);
static int finger_submit_init(void *);
static int finger_submit_fini(void *);
static int finger_submit_unload(void *);


/* plugin operations */
Expand All @@ -51,6 +52,8 @@ struct plugin_ops finger_submit_ops = {
.init = &finger_submit_init,
/* deactivation function */
.fini = &finger_submit_fini,
/* clean-up function */
.unload = &finger_submit_unload,
};

/**********************************************************/
Expand Down Expand Up @@ -132,6 +135,14 @@ static int finger_submit_fini(void *dummy)
return PLUGIN_FINISHED;
}

static int finger_submit_unload(void *dummy)
{
/* variable not used */
(void) dummy;

return PLUGIN_UNLOADED;
}


/* EOF */

Expand Down
Loading

0 comments on commit e279cea

Please sign in to comment.