botnet.cpp File Reference


Detailed Description

Provides communication between bots linked into botnet.

Definition in file botnet.cpp.

#include <time.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "sock.h"
#include "md5.h"
#include "dcc.h"
#include "log.h"
#include "conf.h"
#include "rle.h"
#include "stats.h"
#include "ssl.h"
#include "lang.h"
#include "match.h"
#include "params.h"
#include "botnet.h"
#include "shared.h"

Include dependency graph for botnet.cpp:

Go to the source code of this file.

Classes

struct  s_bot
 Stores informations about remote bot. More...
struct  s_bot_command
 Stores command packet. More...
union  s_bot_command::u_commnd_data
 Data of command. More...
struct  s_bot_command::u_commnd_data::s__padding
 Padding. More...
struct  s_bot_command::u_commnd_data::s_bot_auth_1
 Authentication. More...
struct  s_bot_command::u_commnd_data::s_check_time_1
 Check for time. More...
struct  s_bot_command::u_commnd_data::s_cmd_partyline_1
 Partyline event. More...
struct  s_bot_command::u_commnd_data::s_cmd_partyline_user_1
 Partyline - user listing entry. More...
struct  s_bot_command::u_commnd_data::s_cmd_proc_1
 Replication of procedure. More...
struct  s_bot_command::u_commnd_data::s_cmd_proc_end_1
 Replication of procedure - the end - commit. More...
struct  s_bot_command::u_commnd_data::s_cmd_push_1
 Push of object. More...
struct  s_bot_command::u_commnd_data::s_cmd_remote_procedure_call_3
 Remote procedure call. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1
 Channel definitions - part 1. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1
 Channel definitions - part 2. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1
 Channel definitions - part 3. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1
 Channel definitions - part 4. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1
 Channel definitions - part 5. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8
 Channel definition - part 06. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_chdef_99_1
 Channel definitions - end - commit. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_01_1
 Private query definition - part 01. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_02_1
 Private query definition - part 02. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1
 Private query definition - part 03. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7
 Private query definition - part 04. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8
 Private query definition - part 05. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_06_11
 Private query definition - part 06. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_prv_99_1
 Private query definition - end - commit. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_01_1
 Replication of user part 01. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_02_1
 Replication of user part 02. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_03_1
 Replication of user part 03. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_04_1
 Replication of user part 04. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_05_1
 Replication of user part 05. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_06_1
 Replication of user part 06. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_07_1
 Replication of user part 07. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_08_1
 Replication of user part 08. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_09_1
 Replication of user part 09. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_10_1
 Replication of user part 10. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_11_1
 Replication of user part 11. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_12_1
 Replication of user part 12. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_13_1
 Replication of user part 13. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_14_1
 Replication of user part 14. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_15_1
 Replication of user part 15. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_16_5
 Replication of user part 16. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_17_9
 Replication of user part 17. More...
struct  s_bot_command::u_commnd_data::s_cmd_repl_user_99_1
 Replication of user - commit. More...
struct  s_bot_command::u_commnd_data::s_no_repl_1
 No replication. More...
struct  s_bot_control
 Stores control packet. More...
union  s_bot_control::u_control_data
 Data of control. More...
struct  s_botnet_channel
 Stores informations about partyline channel. More...
struct  s_chan_def_to_pull
 Stores channel definition to pull from remote bot. More...
struct  s_chan_def_to_push
 Stores channel definition to push to remote bot. More...
struct  s_msg_id
 Stores informations about message. More...
struct  s_partyline_member
 Stores informations about partyline users. More...
struct  s_proc_to_pull
 Stores procedure data to pull from remote bot. More...
struct  s_proc_to_push
 Stores procedure data to push to remote bot. More...
struct  s_user_to_pull
 Stores user data to pull from remote bot. More...
struct  s_user_to_push
 Stores user data to push to remote bot. More...

Defines

#define CMD_AUTH_1   10001L
 Command: authentication.
#define CMD_CHECK_TIME_1   10002L
 Command: check for object's time.
#define CMD_NO_REPL_1   10003L
 Command: No replication for this object, please.
#define CMD_PARTYLINE_1   10023L
 Command: partyline event.
#define CMD_PARTYLINE_USER_1   10024L
 Command: Partyline user listing.
#define CMD_PROC_1   10021L
 Command: Push of procedure.
#define CMD_PROC_END_1   10022L
 Command: Commit the procedure.
#define CMD_PUSH_1   10020L
 Command: push of object.
#define CMD_REMOTE_PROCEDURE_CALL_3   30001L
 Command: Remote procedure call.
#define CMD_REPL_CHDEF_01_1   10025L
 Command: Channel definiotions - part 1.
#define CMD_REPL_CHDEF_02_1   10026L
 Command: Channel definiotions - part 2.
#define CMD_REPL_CHDEF_03_1   10027L
 Command: Channel definiotions - part 3.
#define CMD_REPL_CHDEF_04_1   10028L
 Command: Channel definiotions - part 4.
#define CMD_REPL_CHDEF_05_1   10029L
 Command: Channel definiotions - part 5.
#define CMD_REPL_CHDEF_06_8   80002L
 Command: Channel definition - part 06.
#define CMD_REPL_CHDEF_99_1   10030L
 Command: Channel definiotions - end.
#define CMD_REPL_PRV_01_1   10031L
 Command: Private query definition - part 01.
#define CMD_REPL_PRV_02_1   10032L
 Command: Private query definition - part 02.
#define CMD_REPL_PRV_03_1   10033L
 Command: Private query definition - part 03.
#define CMD_REPL_PRV_04_7   70001L
 Command: Private query definition - part 04.
#define CMD_REPL_PRV_05_8   80001L
 Command: Private query definition - part 05.
#define CMD_REPL_PRV_06_11   110001L
 Command: Private query definition - part 06.
#define CMD_REPL_PRV_99_1   10034L
 Command: Private query definition - end.
#define CMD_REPL_USER_01_1   10004L
 Command: Replication of user part 01.
#define CMD_REPL_USER_02_1   10005L
 Command: Replication of user part 02.
#define CMD_REPL_USER_03_1   10006L
 Command: Replication of user part 03.
#define CMD_REPL_USER_04_1   10007L
 Command:Replication of user part 04.
#define CMD_REPL_USER_05_1   10008L
 Command: Replication of user part 05.
#define CMD_REPL_USER_06_1   10009L
 Command: Replication of user part 02.
#define CMD_REPL_USER_07_1   10010L
 Command: Replication of user part 07.
#define CMD_REPL_USER_08_1   10011L
 Command: Replication of user part 08.
#define CMD_REPL_USER_09_1   10012L
 Command: Replication of user part 09.
#define CMD_REPL_USER_10_1   10013L
 Command: Replication of user part 10.
#define CMD_REPL_USER_11_1   10014L
 Command: Replication of user part 11.
#define CMD_REPL_USER_12_1   10015L
 Command: Replication of user part 12.
#define CMD_REPL_USER_13_1   10016L
 Command: Replication of user part 13.
#define CMD_REPL_USER_14_1   10017L
 Command: Replication of user part 14.
#define CMD_REPL_USER_15_1   10018L
 Command: Replication of user part 15.
#define CMD_REPL_USER_16_5   50001L
 Command: Replication of user part 16.
#define CMD_REPL_USER_17_9   90001L
 Command: Replication of user part 17.
#define CMD_REPL_USER_99_1   10019L
 Command: Replication of user - commit.
#define CTRL_ERROR_001   1L
 Remote bot is using greater protocol version than me!
#define CTRL_ERROR_002   2L
 Bad password - closing connection.
#define CTRL_LINKED   3L
 Okay, password is okay.
#define CTRL_PING   4L
 Ping.
#define CTRL_PONG   5L
 Pong.
#define PACKET_TYPE_COMMAND   2
 Type of packet is: COMMAND.
#define PACKET_TYPE_CONTROL   1
 Type of packet is: CONTROL.
#define REASON_NO_REPL_1_ACCESS_DENIED   2
 Reason: Access denied.
#define REASON_NO_REPL_1_UP_TO_DATE   1
 Reason: Object is up to date.
#define SUPPORTED_PROTO_VERSION   11
 Version of current (maximum) protocol.

Typedefs

typedef unsigned char my_bool
typedef uint32 my_time_t
typedef unsigned long uint32

Functions

void botnet_admin_msg (string user_mask, string bot_mask, string msg)
 Sends admin message (for command "admin_msg" in file "logic.txt").
void botnet_backup (string botname)
 Causes bot to schedule backup.
bool botnet_check_for_buffer_overflow (s_bot_command &cmd)
 Checks for possibly buffre overflow.
bool botnet_check_string_size (char *str, size_t max_size)
 Checks for possibly buffre overflow - string size in packet.
void botnet_cleanup_ids ()
 Cleans up message ID's.
uint32 botnet_get_unique_id ()
 Creates new unique ID for new message.
bool botnet_has_grant (s_user &bot, string proc_name)
 Check wheter user (bot) can un/assign procedure for event (has access_usage_procedure right).
void botnet_link (string botname, string localip, string botip, unsigned short botport, string remote_MD5_password, string bot_link_type, string unlink_proc, map< string, string > vars)
 Links to new bot.
void botnet_loop ()
 Process the communication with other bots, this should be called in loop.
void botnet_on_unlink (string botname, string from_bot, int id)
 Called on unlink of bot.
void botnet_partyline_event (string origin_bot, s_bot_command *cmd)
 Generates the partyline output message.
string botnet_partyline_join_channel (string user, string channel)
 Called from partyline, when user connected to this bot is joining partline channel.
void botnet_partyline_leave_channel (string user, string channel)
 Called from partyline, when user connected to this bot is leaving partline channel.
void botnet_partyline_message (string user, string channel, string msg, uint32 id)
 Called from partyline, when user connected to this bot is writing a message to partline channel.
void botnet_push_chan (s_bot *bot, s_channel_def &chd)
 Pushes channel definition to the remote bot.
void botnet_push_proc (s_bot *bot, s_procedure &p)
 Pushes the procedure to remote bot.
void botnet_push_prv (s_bot *bot, s_private &prv)
 Pushes the private query definition to remote bot.
void botnet_push_user (s_bot *bot, s_user &u)
 Pushes the user to remote bot.
bool botnet_query_disp_id (uint32 id)
 Checks whether we have message ID in vector already (we already displayed this message).
int botnet_receive (s_bot *bot, int &packet_type, s_bot_command *cmd, s_bot_control *control)
 Receives command or control packet.
void botnet_received_data_from_telnet (s_socket &socket, string botname, char *buff, size_t buff_size, SSL *ssl, string remote_ip)
 Called when remote bot connects via telnet.
void botnet_rehash (s_bot *bot, string botname)
 Causes bot to schedule rehash.
string botnet_remote_procedure_call (string botname, string proc_name_only, list< string > &args)
 Sends to other bot remote procedure call request.
bool botnet_send_command (s_bot *bot, s_bot_command *cmd)
 Sends command to linked bot.
bool botnet_send_control (s_bot *bot, s_bot_control *ctrl)
 Sends control packet to linked bot.
string botnet_showbots (string lang, string eol)
 Used for partyline to show connected bots (.showbots).
bool logic_botnet_get_channel_def (string channel_name, s_channel_def &chd)
 Gets channel definition.
bool logic_botnet_get_proc (string name, s_procedure &proc)
 Gets procedure.
bool logic_botnet_get_user (string name, s_user &user)
 Gets user definition.
bool logic_botnet_get_user_channels (string name, vector< s_channel > &channels)
 Gets channels that user has defined properties to.
void logic_botnet_remove_channel_def (string channel_name)
 Removes channel definition.
void logic_get_pull_chan_defs (string botname, vector< s_channel_def > &chans)
 Gets channel definition list to pull.
void logic_get_pull_procs (string botname, vector< s_procedure > &procs)
 Gets procedure list to pull.
void logic_get_pull_users (string botname, vector< s_user > &users)
 Gets user list to pull.
void logic_get_push_chan_defs (string botname, vector< s_channel_def > &chans)
 Gets channel definition list to push.
void logic_get_push_procs (string botname, vector< s_procedure > &procs)
 Gets procedure list to push.
void logic_get_push_users (string botname, vector< s_user > &users)
 Gets user list to push.
char * ltoa (long value, char *buffer, int radix)
 ltoa() emulation for compiler which doesn't have it
void sleep (int ms)
 Sleeps.

Variables

char botnet_botname [256]
 Name of this bot.
vector< s_botnet_channelbotnet_channels
 List of partyline channels.
time_t botnet_last_rehash_request = 0
 Timestamp of the last rehash request from other bot.
int botnet_penalty = -1
 There will be penalty (in seconds) from configuration file.
vector< s_bot * > bots
 List of connected bots.
vector< s_msg_idmsg_disp_ids
 List of displayed messages ID's.
vector< s_msg_idmsg_ids
 List of message ID's.
MSVC_ALIGN1 struct s_bot_control PACK_STRUCT
 Stores control packet.
int ping_time = 30
 Number of seconds between two pings.
vector< s_channel_defr_channel_defs
 List of real channel definitions (not temporary / compilation!).
vector< s_channelr_channel_templates
 List of channel templates for real usage (not temporary / compilation!).
vector< s_channelr_channel_terminators
 List of channel terminators for real usage (not temporary / compilation!).
vector< s_channelr_channels
 List of channels for real usage (not temporary / compilation!).
s_private r_private
 Informations about procedures when someone sends query message (not temporary / compilation!).
vector< s_procedurer_procedures
 List of procedures for real usage (not temporary / compilation!).
vector< s_userr_terminators
 List of terminated users for real usage (not temporary / compilation!).
vector< s_userr_user_templates
 List of users templates for real usage (not temporary / compilation!).
vector< s_userr_users
 List of users for real usage (not temporary / compilation!).
s_ssl_conf ssl_conf
 Configuration of SSL.


Define Documentation

#define CMD_AUTH_1   10001L
 

Command: authentication.

Definition at line 367 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), and s_bot_command::flip().

#define CMD_CHECK_TIME_1   10002L
 

Command: check for object's time.

Definition at line 382 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), and s_bot_command::flip().

#define CMD_NO_REPL_1   10003L
 

Command: No replication for this object, please.

Definition at line 402 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), and s_bot_command::flip().

#define CMD_PARTYLINE_1   10023L
 

Command: partyline event.

Definition at line 820 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_partyline_event(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), botnet_partyline_message(), and s_bot_command::flip().

#define CMD_PARTYLINE_USER_1   10024L
 

Command: Partyline user listing.

Definition at line 841 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_partyline_event(), and s_bot_command::flip().

#define CMD_PROC_1   10021L
 

Command: Push of procedure.

Definition at line 789 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_proc(), and s_bot_command::flip().

#define CMD_PROC_END_1   10022L
 

Command: Commit the procedure.

Definition at line 806 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_proc(), and s_bot_command::flip().

#define CMD_PUSH_1   10020L
 

Command: push of object.

Definition at line 769 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), and s_bot_command::flip().

#define CMD_REMOTE_PROCEDURE_CALL_3   30001L
 

Command: Remote procedure call.

Definition at line 1087 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_remote_procedure_call(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_01_1   10025L
 

Command: Channel definiotions - part 1.

Definition at line 858 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_02_1   10026L
 

Command: Channel definiotions - part 2.

Definition at line 885 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_03_1   10027L
 

Command: Channel definiotions - part 3.

Definition at line 900 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_04_1   10028L
 

Command: Channel definiotions - part 4.

Definition at line 917 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_05_1   10029L
 

Command: Channel definiotions - part 5.

Definition at line 933 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_06_8   80002L
 

Command: Channel definition - part 06.

Warning:
BOTNET protocol 8 or above!

Definition at line 949 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_CHDEF_99_1   10030L
 

Command: Channel definiotions - end.

Definition at line 965 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_chan(), and s_bot_command::flip().

#define CMD_REPL_PRV_01_1   10031L
 

Command: Private query definition - part 01.

Definition at line 979 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_PRV_02_1   10032L
 

Command: Private query definition - part 02.

Definition at line 993 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_PRV_03_1   10033L
 

Command: Private query definition - part 03.

Definition at line 1007 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_PRV_04_7   70001L
 

Command: Private query definition - part 04.

Warning:
BOTNET protocol 7 or above!

Definition at line 1024 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_PRV_05_8   80001L
 

Command: Private query definition - part 05.

Warning:
BOTNET protocol 8 or above!

Definition at line 1041 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_PRV_06_11   110001L
 

Command: Private query definition - part 06.

Warning:
BOTNET protocol 11 or above!

Definition at line 1058 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_PRV_99_1   10034L
 

Command: Private query definition - end.

Definition at line 1073 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_prv(), and s_bot_command::flip().

#define CMD_REPL_USER_01_1   10004L
 

Command: Replication of user part 01.

Definition at line 432 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_02_1   10005L
 

Command: Replication of user part 02.

Definition at line 466 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_03_1   10006L
 

Command: Replication of user part 03.

Definition at line 481 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_04_1   10007L
 

Command:Replication of user part 04.

Definition at line 496 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_05_1   10008L
 

Command: Replication of user part 05.

Definition at line 511 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_06_1   10009L
 

Command: Replication of user part 02.

Definition at line 526 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_07_1   10010L
 

Command: Replication of user part 07.

Definition at line 541 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_08_1   10011L
 

Command: Replication of user part 08.

Definition at line 556 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_09_1   10012L
 

Command: Replication of user part 09.

Definition at line 571 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_10_1   10013L
 

Command: Replication of user part 10.

Definition at line 586 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_11_1   10014L
 

Command: Replication of user part 11.

Definition at line 601 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_12_1   10015L
 

Command: Replication of user part 12.

Definition at line 617 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_13_1   10016L
 

Command: Replication of user part 13.

Definition at line 670 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_14_1   10017L
 

Command: Replication of user part 14.

Definition at line 688 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_15_1   10018L
 

Command: Replication of user part 15.

Definition at line 704 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_16_5   50001L
 

Command: Replication of user part 16.

Warning:
BOTNET protocol 5 or above!

Definition at line 720 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_17_9   90001L
 

Command: Replication of user part 17.

Warning:
BOTNET protocol 9 or above!

Definition at line 738 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CMD_REPL_USER_99_1   10019L
 

Command: Replication of user - commit.

Definition at line 755 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_push_user(), and s_bot_command::flip().

#define CTRL_ERROR_001   1L
 

Remote bot is using greater protocol version than me!

Definition at line 279 of file botnet.cpp.

Referenced by botnet_loop().

#define CTRL_ERROR_002   2L
 

Bad password - closing connection.

Definition at line 285 of file botnet.cpp.

Referenced by botnet_loop().

#define CTRL_LINKED   3L
 

Okay, password is okay.

Definition at line 291 of file botnet.cpp.

Referenced by botnet_loop().

#define CTRL_PING   4L
 

Ping.

Definition at line 297 of file botnet.cpp.

Referenced by botnet_loop().

#define CTRL_PONG   5L
 

Pong.

Definition at line 303 of file botnet.cpp.

Referenced by botnet_loop().

#define PACKET_TYPE_COMMAND   2
 

Type of packet is: COMMAND.

Definition at line 351 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), botnet_loop(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), botnet_partyline_message(), botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), botnet_receive(), botnet_remote_procedure_call(), and s_bot_command::flip().

#define PACKET_TYPE_CONTROL   1
 

Type of packet is: CONTROL.

Definition at line 269 of file botnet.cpp.

Referenced by botnet_loop(), and botnet_receive().

#define REASON_NO_REPL_1_ACCESS_DENIED   2
 

Reason: Access denied.

Definition at line 425 of file botnet.cpp.

Referenced by botnet_loop().

#define REASON_NO_REPL_1_UP_TO_DATE   1
 

Reason: Object is up to date.

Definition at line 419 of file botnet.cpp.

Referenced by botnet_loop().

#define SUPPORTED_PROTO_VERSION   11
 

Version of current (maximum) protocol.

Definition at line 247 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow(), and botnet_loop().


Typedef Documentation

typedef unsigned char my_bool
 

Definition at line 89 of file botnet.cpp.

typedef uint32 my_time_t
 

Definition at line 90 of file botnet.cpp.

typedef unsigned long uint32
 

Definition at line 86 of file botnet.cpp.


Function Documentation

void botnet_admin_msg string  user_mask,
string  bot_mask,
string  msg
 

Sends admin message (for command "admin_msg" in file "logic.txt").

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
user_mask Mask of users as in logic.txt to receive message
bot_mask Mask of names of bots to receive message
msg Message

Definition at line 8909 of file botnet.cpp.

References botnet_botname, and botnet_partyline_message().

Referenced by logic_exec().

08910 {
08911     string c="\x01" "BROADCAST_ADMIN_MESSAGE\x01 * * ";
08912     c+=bot_mask;
08913     c+=" ";
08914     c+=user_mask;
08915     c+=" ";
08916     c+=msg;
08917 
08918     botnet_partyline_message(botnet_botname,"",c);
08919 }

Here is the call graph for this function:

void botnet_backup string  botname  ) 
 

Causes bot to schedule backup.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of the remote bot

Definition at line 1599 of file botnet.cpp.

References botnet_last_rehash_request.

Referenced by botnet_loop().

01600 {
01601     botnet_last_rehash_request=time(NULL);
01602 }

bool botnet_check_for_buffer_overflow s_bot_command cmd  ) 
 

Checks for possibly buffre overflow.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
cmd Received command
Return values:
false Okay
true Possibly buffer overflow

Definition at line 1918 of file botnet.cpp.

References s_bot_command::u_commnd_data::s_cmd_repl_user_09_1::access_grant_channel, s_bot_command::u_commnd_data::s_cmd_repl_user_07_1::access_grant_group, s_bot_command::u_commnd_data::s_cmd_repl_user_06_1::access_grant_proc, s_bot_command::u_commnd_data::s_cmd_repl_user_08_1::access_to_channel, s_bot_command::u_commnd_data::s_cmd_repl_user_04_1::access_to_group, s_bot_command::u_commnd_data::s_cmd_repl_user_05_1::access_to_proc, s_bot_command::u_commnd_data::s_cmd_repl_user_15_1::access_usage_proc, s_bot_command::u_commnd_data::bot_auth_1, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::botname, s_bot_command::u_commnd_data::s_cmd_partyline_1::botname, s_bot_command::u_commnd_data::s_bot_auth_1::botname, botnet_check_string_size(), s_bot_command::u_commnd_data::s_cmd_partyline_user_1::channel, s_bot_command::u_commnd_data::s_cmd_partyline_1::channel, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::channel, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::channel, s_bot_command::u_commnd_data::check_time_1, CMD_AUTH_1, CMD_CHECK_TIME_1, CMD_NO_REPL_1, s_bot_command::u_commnd_data::cmd_partyline_1, CMD_PARTYLINE_1, s_bot_command::u_commnd_data::cmd_partyline_user_1, CMD_PARTYLINE_USER_1, s_bot_command::u_commnd_data::cmd_proc_1, CMD_PROC_1, s_bot_command::u_commnd_data::cmd_proc_end_1, CMD_PROC_END_1, s_bot_command::u_commnd_data::cmd_push_1, CMD_PUSH_1, CMD_REMOTE_PROCEDURE_CALL_3, s_bot_command::u_commnd_data::cmd_repl_chdef_01_1, CMD_REPL_CHDEF_01_1, s_bot_command::u_commnd_data::cmd_repl_chdef_02_1, CMD_REPL_CHDEF_02_1, s_bot_command::u_commnd_data::cmd_repl_chdef_03_1, CMD_REPL_CHDEF_03_1, s_bot_command::u_commnd_data::cmd_repl_chdef_04_1, CMD_REPL_CHDEF_04_1, s_bot_command::u_commnd_data::cmd_repl_chdef_05_1, CMD_REPL_CHDEF_05_1, s_bot_command::u_commnd_data::cmd_repl_chdef_06_8, CMD_REPL_CHDEF_06_8, s_bot_command::u_commnd_data::cmd_repl_chdef_99_1, CMD_REPL_CHDEF_99_1, CMD_REPL_PRV_01_1, s_bot_command::u_commnd_data::cmd_repl_prv_02_1, CMD_REPL_PRV_02_1, s_bot_command::u_commnd_data::cmd_repl_prv_03_1, CMD_REPL_PRV_03_1, s_bot_command::u_commnd_data::cmd_repl_prv_04_7, CMD_REPL_PRV_04_7, s_bot_command::u_commnd_data::cmd_repl_prv_05_8, CMD_REPL_PRV_05_8, s_bot_command::u_commnd_data::cmd_repl_prv_06_11, CMD_REPL_PRV_06_11, CMD_REPL_PRV_99_1, s_bot_command::u_commnd_data::cmd_repl_user_01_1, CMD_REPL_USER_01_1, s_bot_command::u_commnd_data::cmd_repl_user_02_1, CMD_REPL_USER_02_1, s_bot_command::u_commnd_data::cmd_repl_user_03_1, CMD_REPL_USER_03_1, s_bot_command::u_commnd_data::cmd_repl_user_04_1, CMD_REPL_USER_04_1, s_bot_command::u_commnd_data::cmd_repl_user_05_1, CMD_REPL_USER_05_1, s_bot_command::u_commnd_data::cmd_repl_user_06_1, CMD_REPL_USER_06_1, s_bot_command::u_commnd_data::cmd_repl_user_07_1, CMD_REPL_USER_07_1, s_bot_command::u_commnd_data::cmd_repl_user_08_1, CMD_REPL_USER_08_1, s_bot_command::u_commnd_data::cmd_repl_user_09_1, CMD_REPL_USER_09_1, s_bot_command::u_commnd_data::cmd_repl_user_10_1, CMD_REPL_USER_10_1, s_bot_command::u_commnd_data::cmd_repl_user_11_1, CMD_REPL_USER_11_1, s_bot_command::u_commnd_data::cmd_repl_user_12_1, CMD_REPL_USER_12_1, s_bot_command::u_commnd_data::cmd_repl_user_13_1, CMD_REPL_USER_13_1, s_bot_command::u_commnd_data::cmd_repl_user_14_1, CMD_REPL_USER_14_1, s_bot_command::u_commnd_data::cmd_repl_user_15_1, CMD_REPL_USER_15_1, s_bot_command::u_commnd_data::cmd_repl_user_16_5, CMD_REPL_USER_16_5, s_bot_command::u_commnd_data::cmd_repl_user_17_9, CMD_REPL_USER_17_9, s_bot_command::u_commnd_data::cmd_repl_user_99_1, CMD_REPL_USER_99_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::dcc_host, s_bot_command::u_commnd_data::s_bot_auth_1::digest, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::dynamic_minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::dynamic_minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::dynamic_plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::dynamic_plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_03_1::fullname, s_bot_command::u_commnd_data::s_cmd_repl_prv_02_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1::group, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::group, s_bot_command::u_commnd_data::s_cmd_repl_user_10_1::group, s_bot_command::u_commnd_data::s_cmd_repl_user_02_1::hostmask, s_bot_command::u_commnd_data::s_cmd_proc_1::line, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::mask, s_bot_command::u_commnd_data::s_cmd_partyline_1::message, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::meta_key, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::meta_val, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_99_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::name, s_bot_command::u_commnd_data::s_cmd_proc_end_1::name, s_bot_command::u_commnd_data::s_cmd_proc_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_99_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::name, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::name, s_bot_command::u_commnd_data::s_cmd_repl_user_15_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_10_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_09_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_08_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_07_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_06_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_05_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_04_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_03_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_02_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::name, s_bot_command::u_commnd_data::no_repl_1, s_bot_command::u_commnd_data::s_cmd_push_1::object_name, s_bot_command::u_commnd_data::s_no_repl_1::object_name, s_bot_command::u_commnd_data::s_check_time_1::object_name, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_ban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_banned, s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8::on_broadcast, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_creator, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_ctcp, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_ctcp, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_decreator, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_deop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_devoice, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_dynamic_ban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_except, s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7::on_filesys_got_new, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_flood, s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7::on_fnc, s_bot_command::u_commnd_data::s_cmd_repl_prv_06_11::on_internal_event, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_invite, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_ircop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_join, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_key, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_kick, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_limit, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_mode, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_not_in_reop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_not_invited, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_op, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_part, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_reop, s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8::on_server_msg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8::on_server_msg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_topic, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_unban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_unexcept, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_uninvite, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_voice, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::reason, SUPPORTED_PROTO_VERSION, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::user, s_bot_command::u_commnd_data::s_cmd_partyline_1::user, and s_bot_command::version.

Referenced by botnet_receive().

01919 {
01920     if(cmd.packet_type!=PACKET_TYPE_COMMAND)
01921         return true;
01922 
01923     if(cmd.version>SUPPORTED_PROTO_VERSION)
01924         return true;
01925 
01926     switch(cmd.command) {
01927         case CMD_AUTH_1:
01928             if(botnet_check_string_size(cmd.command_data.bot_auth_1.botname,sizeof(cmd.command_data.bot_auth_1.botname)))
01929                 return true;
01930             if(botnet_check_string_size((char*)cmd.command_data.bot_auth_1.digest,sizeof(cmd.command_data.bot_auth_1.digest)))
01931                 return true;
01932             break;
01933         case CMD_CHECK_TIME_1:
01934             if(botnet_check_string_size(cmd.command_data.check_time_1.object_name,sizeof(cmd.command_data.check_time_1.object_name)))
01935                 return true;
01936             break;
01937         case CMD_NO_REPL_1:
01938             if(botnet_check_string_size(cmd.command_data.no_repl_1.object_name,sizeof(cmd.command_data.no_repl_1.object_name)))
01939                 return true;
01940             break;
01941         case CMD_REPL_USER_01_1:
01942             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_01_1.name,sizeof(cmd.command_data.cmd_repl_user_01_1.name)))
01943                 return true;
01944             break;
01945         case CMD_REPL_USER_02_1:
01946             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_02_1.name,sizeof(cmd.command_data.cmd_repl_user_02_1.name)))
01947                 return true;
01948             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_02_1.hostmask,sizeof(cmd.command_data.cmd_repl_user_02_1.hostmask)))
01949                 return true;
01950             break;
01951         case CMD_REPL_USER_03_1:
01952             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_03_1.name,sizeof(cmd.command_data.cmd_repl_user_03_1.name)))
01953                 return true;
01954             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_03_1.fullname,sizeof(cmd.command_data.cmd_repl_user_03_1.fullname)))
01955                 return true;
01956             break;
01957         case CMD_REPL_USER_04_1:
01958             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_04_1.name,sizeof(cmd.command_data.cmd_repl_user_04_1.name)))
01959                 return true;
01960             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_04_1.access_to_group,sizeof(cmd.command_data.cmd_repl_user_04_1.access_to_group)))
01961                 return true;
01962             break;
01963         case CMD_REPL_USER_05_1:
01964             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_05_1.name,sizeof(cmd.command_data.cmd_repl_user_05_1.name)))
01965                 return true;
01966             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_05_1.access_to_proc,sizeof(cmd.command_data.cmd_repl_user_05_1.access_to_proc)))
01967                 return true;
01968             break;
01969         case CMD_REPL_USER_06_1:
01970             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_06_1.name,sizeof(cmd.command_data.cmd_repl_user_06_1.name)))
01971                 return true;
01972             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_06_1.access_grant_proc,sizeof(cmd.command_data.cmd_repl_user_06_1.access_grant_proc)))
01973                 return true;
01974             break;
01975         case CMD_REPL_USER_07_1:
01976             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_07_1.name,sizeof(cmd.command_data.cmd_repl_user_07_1.name)))
01977                 return true;
01978             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_07_1.access_grant_group,sizeof(cmd.command_data.cmd_repl_user_07_1.access_grant_group)))
01979                 return true;
01980             break;
01981         case CMD_REPL_USER_08_1:
01982             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_08_1.name,sizeof(cmd.command_data.cmd_repl_user_08_1.name)))
01983                 return true;
01984             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_08_1.access_to_channel,sizeof(cmd.command_data.cmd_repl_user_08_1.access_to_channel)))
01985                 return true;
01986             break;
01987         case CMD_REPL_USER_09_1:
01988             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_09_1.name,sizeof(cmd.command_data.cmd_repl_user_09_1.name)))
01989                 return true;
01990             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_09_1.access_grant_channel,sizeof(cmd.command_data.cmd_repl_user_09_1.access_grant_channel)))
01991                 return true;
01992             break;
01993         case CMD_REPL_USER_10_1:
01994             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_10_1.name,sizeof(cmd.command_data.cmd_repl_user_10_1.name)))
01995                 return true;
01996             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_10_1.group,sizeof(cmd.command_data.cmd_repl_user_10_1.group)))
01997                 return true;
01998             break;
01999         case CMD_REPL_USER_11_1:
02000             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_11_1.name,sizeof(cmd.command_data.cmd_repl_user_11_1.name)))
02001                 return true;
02002             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_11_1.dcc_host,sizeof(cmd.command_data.cmd_repl_user_11_1.dcc_host)))
02003                 return true;
02004             break;
02005         case CMD_REPL_USER_12_1:
02006             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.name,sizeof(cmd.command_data.cmd_repl_user_12_1.name)))
02007                 return true;
02008             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.channel,sizeof(cmd.command_data.cmd_repl_user_12_1.channel)))
02009                 return true;
02010             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_deop,sizeof(cmd.command_data.cmd_repl_user_12_1.on_deop)))
02011                 return true;
02012             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_ban,sizeof(cmd.command_data.cmd_repl_user_12_1.on_ban)))
02013                 return true;
02014             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_unban,sizeof(cmd.command_data.cmd_repl_user_12_1.on_unban)))
02015                 return true;
02016             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_kick,sizeof(cmd.command_data.cmd_repl_user_12_1.on_kick)))
02017                 return true;
02018             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_op,sizeof(cmd.command_data.cmd_repl_user_12_1.on_op)))
02019                 return true;
02020             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_voice,sizeof(cmd.command_data.cmd_repl_user_12_1.on_voice)))
02021                 return true;
02022             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_devoice,sizeof(cmd.command_data.cmd_repl_user_12_1.on_devoice)))
02023                 return true;
02024             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_creator,sizeof(cmd.command_data.cmd_repl_user_12_1.on_creator)))
02025                 return true;
02026             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_decreator,sizeof(cmd.command_data.cmd_repl_user_12_1.on_decreator)))
02027                 return true;
02028             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_join,sizeof(cmd.command_data.cmd_repl_user_12_1.on_join)))
02029                 return true;
02030             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_banned,sizeof(cmd.command_data.cmd_repl_user_12_1.on_banned)))
02031                 return true;
02032             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_flood,sizeof(cmd.command_data.cmd_repl_user_12_1.on_flood)))
02033                 return true;
02034             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_privmsg,sizeof(cmd.command_data.cmd_repl_user_12_1.on_privmsg)))
02035                 return true;
02036             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_notice,sizeof(cmd.command_data.cmd_repl_user_12_1.on_notice)))
02037                 return true;
02038             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_except,sizeof(cmd.command_data.cmd_repl_user_12_1.on_except)))
02039                 return true;
02040             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_unexcept,sizeof(cmd.command_data.cmd_repl_user_12_1.on_unexcept)))
02041                 return true;
02042             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_invite,sizeof(cmd.command_data.cmd_repl_user_12_1.on_invite)))
02043                 return true;
02044             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_uninvite,sizeof(cmd.command_data.cmd_repl_user_12_1.on_uninvite)))
02045                 return true;
02046             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_not_invited,sizeof(cmd.command_data.cmd_repl_user_12_1.on_not_invited)))
02047                 return true;
02048             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_not_in_reop,sizeof(cmd.command_data.cmd_repl_user_12_1.on_not_in_reop)))
02049                 return true;
02050             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.on_reop,sizeof(cmd.command_data.cmd_repl_user_12_1.on_reop)))
02051                 return true;
02052             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.dynamic_plus_modes,sizeof(cmd.command_data.cmd_repl_user_12_1.dynamic_plus_modes)))
02053                 return true;
02054             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_12_1.dynamic_minus_modes,sizeof(cmd.command_data.cmd_repl_user_12_1.dynamic_minus_modes)))
02055                 return true;
02056             break;
02057         case CMD_REPL_USER_13_1:
02058             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_13_1.name,sizeof(cmd.command_data.cmd_repl_user_13_1.name)))
02059                 return true;
02060             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_13_1.channel,sizeof(cmd.command_data.cmd_repl_user_13_1.channel)))
02061                 return true;
02062             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_13_1.group,sizeof(cmd.command_data.cmd_repl_user_13_1.group)))
02063                 return true;
02064             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_13_1.plus_modes,sizeof(cmd.command_data.cmd_repl_user_13_1.plus_modes)))
02065                 return true;
02066             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_13_1.minus_modes,sizeof(cmd.command_data.cmd_repl_user_13_1.minus_modes)))
02067                 return true;
02068             break;
02069         case CMD_REPL_USER_14_1:
02070             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_14_1.name,sizeof(cmd.command_data.cmd_repl_user_14_1.name)))
02071                 return true;
02072             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_14_1.meta_key,sizeof(cmd.command_data.cmd_repl_user_14_1.meta_key)))
02073                 return true;
02074             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_14_1.meta_val,sizeof(cmd.command_data.cmd_repl_user_14_1.meta_val)))
02075                 return true;
02076             break;
02077         case CMD_REPL_USER_15_1:
02078             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_15_1.name,sizeof(cmd.command_data.cmd_repl_user_15_1.name)))
02079                 return true;
02080             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_15_1.access_usage_proc,sizeof(cmd.command_data.cmd_repl_user_15_1.access_usage_proc)))
02081                 return true;
02082             break;
02083         case CMD_REPL_USER_16_5:
02084             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_16_5.name,sizeof(cmd.command_data.cmd_repl_user_16_5.name)))
02085                 return true;
02086             break;
02087         case CMD_REPL_USER_17_9:
02088             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_17_9.name,sizeof(cmd.command_data.cmd_repl_user_17_9.name)))
02089                 return true;
02090             break;
02091         case CMD_REPL_USER_99_1:
02092             if(botnet_check_string_size(cmd.command_data.cmd_repl_user_99_1.name,sizeof(cmd.command_data.cmd_repl_user_99_1.name)))
02093                 return true;
02094             break;
02095         case CMD_PUSH_1:
02096             if(botnet_check_string_size(cmd.command_data.cmd_push_1.object_name,sizeof(cmd.command_data.cmd_push_1.object_name)))
02097                 return true;
02098             break;
02099         case CMD_PROC_1:
02100             if(botnet_check_string_size(cmd.command_data.cmd_proc_1.name,sizeof(cmd.command_data.cmd_proc_1.name)))
02101                 return true;
02102             if(botnet_check_string_size(cmd.command_data.cmd_proc_1.line,sizeof(cmd.command_data.cmd_proc_1.line)))
02103                 return true;
02104             break;
02105         case CMD_PROC_END_1:
02106             if(botnet_check_string_size(cmd.command_data.cmd_proc_end_1.name,sizeof(cmd.command_data.cmd_proc_end_1.name)))
02107                 return true;
02108             break;
02109         case CMD_PARTYLINE_1:
02110             if(botnet_check_string_size(cmd.command_data.cmd_partyline_1.user,sizeof(cmd.command_data.cmd_partyline_1.user)))
02111                 return true;
02112             if(botnet_check_string_size(cmd.command_data.cmd_partyline_1.message,sizeof(cmd.command_data.cmd_partyline_1.message)))
02113                 return true;
02114             if(botnet_check_string_size(cmd.command_data.cmd_partyline_1.channel,sizeof(cmd.command_data.cmd_partyline_1.channel)))
02115                 return true;
02116             if(botnet_check_string_size(cmd.command_data.cmd_partyline_1.botname,sizeof(cmd.command_data.cmd_partyline_1.botname)))
02117                 return true;
02118             break;
02119         case CMD_PARTYLINE_USER_1:
02120             if(botnet_check_string_size(cmd.command_data.cmd_partyline_user_1.user,sizeof(cmd.command_data.cmd_partyline_user_1.user)))
02121                 return true;
02122             if(botnet_check_string_size(cmd.command_data.cmd_partyline_user_1.channel,sizeof(cmd.command_data.cmd_partyline_user_1.channel)))
02123                 return true;
02124             if(botnet_check_string_size(cmd.command_data.cmd_partyline_user_1.botname,sizeof(cmd.command_data.cmd_partyline_user_1.botname)))
02125                 return true;
02126             break;
02127         case CMD_REPL_CHDEF_01_1:
02128             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.name,sizeof(cmd.command_data.cmd_repl_chdef_01_1.name)))
02129                 return true;
02130             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_mode,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_mode)))
02131                 return true;
02132             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_key,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_key)))
02133                 return true;
02134             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_limit,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_limit)))
02135                 return true;
02136             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_topic,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_topic)))
02137                 return true;
02138             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_ircop,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_ircop)))
02139                 return true;
02140             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_ctcp,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_ctcp)))
02141                 return true;
02142             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_privmsg,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_privmsg)))
02143                 return true;
02144             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_notice,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_notice)))
02145                 return true;
02146             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_part,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_part)))
02147                 return true;
02148             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.on_dynamic_ban,sizeof(cmd.command_data.cmd_repl_chdef_01_1.on_dynamic_ban)))
02149                 return true;
02150             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.dynamic_plus_modes,sizeof(cmd.command_data.cmd_repl_chdef_01_1.dynamic_plus_modes)))
02151                 return true;
02152             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_01_1.dynamic_minus_modes,sizeof(cmd.command_data.cmd_repl_chdef_01_1.dynamic_minus_modes)))
02153                 return true;
02154             break;
02155         case CMD_REPL_CHDEF_02_1:
02156             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_02_1.name,sizeof(cmd.command_data.cmd_repl_chdef_02_1.name)))
02157                 return true;
02158             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_02_1.group,sizeof(cmd.command_data.cmd_repl_chdef_02_1.group)))
02159                 return true;
02160             break;
02161         case CMD_REPL_CHDEF_03_1:
02162             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_03_1.name,sizeof(cmd.command_data.cmd_repl_chdef_03_1.name)))
02163                 return true;
02164             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_03_1.group,sizeof(cmd.command_data.cmd_repl_chdef_03_1.group)))
02165                 return true;
02166             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_03_1.plus_modes,sizeof(cmd.command_data.cmd_repl_chdef_03_1.plus_modes)))
02167                 return true;
02168             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_03_1.minus_modes,sizeof(cmd.command_data.cmd_repl_chdef_03_1.minus_modes)))
02169                 return true;
02170             break;
02171         case CMD_REPL_CHDEF_04_1:
02172             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_04_1.name,sizeof(cmd.command_data.cmd_repl_chdef_04_1.name)))
02173                 return true;
02174             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_04_1.mask,sizeof(cmd.command_data.cmd_repl_chdef_04_1.mask)))
02175                 return true;
02176             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_04_1.reason,sizeof(cmd.command_data.cmd_repl_chdef_04_1.reason)))
02177                 return true;
02178             break;
02179         case CMD_REPL_CHDEF_05_1:
02180             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_05_1.name,sizeof(cmd.command_data.cmd_repl_chdef_05_1.name)))
02181                 return true;
02182             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_05_1.group,sizeof(cmd.command_data.cmd_repl_chdef_05_1.group)))
02183                 return true;
02184             break;
02185         case CMD_REPL_CHDEF_06_8:
02186             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_06_8.name,sizeof(cmd.command_data.cmd_repl_chdef_06_8.name)))
02187                 return true;
02188             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_06_8.on_server_msg,sizeof(cmd.command_data.cmd_repl_chdef_06_8.on_server_msg)))
02189                 return true;
02190         case CMD_REPL_CHDEF_99_1:
02191             if(botnet_check_string_size(cmd.command_data.cmd_repl_chdef_99_1.name,sizeof(cmd.command_data.cmd_repl_chdef_99_1.name)))
02192                 return true;
02193             break;
02194         case CMD_REPL_PRV_01_1:
02195             break;
02196         case CMD_REPL_PRV_02_1:
02197             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_02_1.group,sizeof(cmd.command_data.cmd_repl_prv_02_1.group)))
02198                 return true;
02199             break;
02200         case CMD_REPL_PRV_03_1:
02201             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_03_1.on_privmsg,sizeof(cmd.command_data.cmd_repl_prv_03_1.on_privmsg)))
02202                 return true;
02203             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_03_1.on_notice,sizeof(cmd.command_data.cmd_repl_prv_03_1.on_notice)))
02204                 return true;
02205             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_03_1.on_ctcp,sizeof(cmd.command_data.cmd_repl_prv_03_1.on_ctcp)))
02206                 return true;
02207             break;
02208         case CMD_REPL_PRV_04_7:
02209             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_04_7.on_filesys_got_new,sizeof(cmd.command_data.cmd_repl_prv_04_7.on_filesys_got_new)))
02210                 return true;
02211             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_04_7.on_fnc,sizeof(cmd.command_data.cmd_repl_prv_04_7.on_fnc)))
02212                 return true;
02213             break;
02214         case CMD_REPL_PRV_05_8:
02215             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_05_8.on_broadcast,sizeof(cmd.command_data.cmd_repl_prv_05_8.on_broadcast)))
02216                 return true;
02217             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_05_8.on_server_msg,sizeof(cmd.command_data.cmd_repl_prv_05_8.on_server_msg)))
02218                 return true;
02219             break;
02220         case CMD_REPL_PRV_06_11:
02221             if(botnet_check_string_size(cmd.command_data.cmd_repl_prv_06_11.on_internal_event,sizeof(cmd.command_data.cmd_repl_prv_06_11.on_internal_event)))
02222                 return true;
02223             break;
02224         case CMD_REPL_PRV_99_1:
02225             break;
02226         case CMD_REMOTE_PROCEDURE_CALL_3:
02227             // nothing do be done (arguments are in binary field, actually not text)
02228             break;
02229         default:
02230             return true;
02231     }
02232     return false;
02233 }

Here is the call graph for this function:

bool botnet_check_string_size char *  str,
size_t  max_size
 

Checks for possibly buffre overflow - string size in packet.

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
str String
max_size Maximum size of string
Return values:
false Okay
true Possibly buffer overflow

Definition at line 1897 of file botnet.cpp.

Referenced by botnet_check_for_buffer_overflow().

01898 {
01899     bool ok=false;
01900     for(size_t i1=0; i1<max_size; i1++) {
01901         if(str[i1]==0) {
01902             ok=true;
01903             break;
01904         }
01905     }
01906     return !ok;
01907 }

void botnet_cleanup_ids  ) 
 

Cleans up message ID's.

Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 1517 of file botnet.cpp.

References msg_disp_ids, and msg_ids.

Referenced by botnet_loop().

01518 {
01519     time_t now;
01520     time(&now);
01521 
01522     vector<s_msg_id>::iterator i1;
01523 
01524 again:
01525     for(i1=msg_ids.begin(); i1!=msg_ids.end(); i1++)
01526         if((time_t)(*i1).time+300<now) {
01527             msg_ids.erase(i1);
01528             goto again;
01529         }
01530 
01531 again2:
01532     for(i1=msg_disp_ids.begin(); i1!=msg_disp_ids.end(); i1++)
01533         if((time_t)(*i1).time+300<now) {
01534             msg_disp_ids.erase(i1);
01535             goto again2;
01536         }
01537 }

uint32 botnet_get_unique_id  ) 
 

Creates new unique ID for new message.

Author:
VooDooMan
Version:
1
Date:
2005
Return values:
Unique ID

Definition at line 1564 of file botnet.cpp.

References msg_disp_ids, and msg_ids.

Referenced by botnet_loop(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), and botnet_partyline_message().

01565 {
01566     uint32 id;
01567     for(;;) {
01568 again:
01569         id=(rand()%0xffff) | ( (rand()%0xffff) << 16 );
01570         vector<s_msg_id>::iterator i1;
01571 
01572         for(i1=msg_ids.begin(); i1!=msg_ids.end(); i1++) {
01573             if((*i1).id==id) {
01574                 goto again;
01575             }
01576         }
01577 
01578         for(i1=msg_disp_ids.begin(); i1!=msg_disp_ids.end(); i1++) {
01579             if((*i1).id==id) {
01580                 goto again;
01581             }
01582         }
01583 
01584         break;
01585     }
01586 
01587     return id;
01588 }

bool botnet_has_grant s_user bot,
string  proc_name
 

Check wheter user (bot) can un/assign procedure for event (has access_usage_procedure right).

Author:
VooDooMan
Version:
2
Date:
2005
Parameters:
bot Bot rights
proc_name Name of procedure
Returns:
Returns true if can unassign

Definition at line 3862 of file botnet.cpp.

References s_user::access_usage_procedure.

Referenced by botnet_loop().

03863 {
03864     if(proc_name.empty())
03865         return true;
03866 
03867     if(proc_name.find("(",0)!=string::npos)
03868         proc_name.erase(proc_name.find("(",0),proc_name.length()-proc_name.find("(",0));
03869 
03870     vector<string>::iterator i1;
03871     for(i1=bot.access_usage_procedure.begin(); i1!=bot.access_usage_procedure.end(); i1++) {
03872         if(!(*i1).compare("*"))
03873             return true;
03874 
03875         string name_only=*i1;
03876         if(name_only.find("(",0)!=string::npos)
03877             name_only.erase(name_only.find("(",0),name_only.length()-name_only.find("(",0));
03878 
03879         if(!name_only.compare(proc_name))
03880             return true;
03881     }
03882 
03883     return false;
03884 }

void botnet_link string  botname,
string  localip,
string  botip,
unsigned short  botport,
string  remote_MD5_password,
string  bot_link_type,
string  unlink_proc,
map< string, string >  vars
 

Links to new bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
localip Local IPv4 address
botip Remote IPv4 address
botport Port of remote bot
remote_MD5_password Password as MD5
bot_link_type Must be "telnet"
unlink_proc Unlink procedure to call on unlink
vars Variables to unlink procedure

Definition at line 1698 of file botnet.cpp.

References s_bot::auth_ok, s_bot::botip, s_bot::botname, s_bot::botport, bots, s_bot::buff_size_from_dcc, s_bot::clear(), s_socket::clear(), s_bot::command_receive_buffer, s_bot::control_receive_buffer, s_bot::got_bytes, s_bot_command::hard_clear(), s_bot_control::hard_clear(), s_bot::invoked_from_telnet, s_bot::last_try, s_bot::localip, log_debug(), s_bot::receive_buffer_pos, s_bot::received_bot_auth_1, s_bot::remote_MD5_password, s_bot::remote_pswd_ok, s_bot::sent_bot_auth_1, s_bot::socket, s_bot::ssl, ssl_close(), s_bot::ssl_connection, s_bot::unlink_proc, s_bot::unlink_proc_called, s_bot::vars, and s_bot::was_linked.

Referenced by logic_exec().

01699 {
01700     if(bot_link_type.compare("telnet") && bot_link_type.compare("telnet_ssl")) {
01701         log_debug("in file " __FILE__ " in function " __FUNC__ " occurred error: Unknown link type (PANIC!) - assuming \"telnet\"");
01702     }
01703 
01704     bool got=false;
01705     bool got_one=false;
01706     vector<s_bot*>::iterator i1;
01707 label:
01708     for(i1=bots.begin(); i1!=bots.end(); i1++)
01709         if(!(*i1)->botname.compare(botname)) {
01710             // we already got link bot in the vector
01711             got_one=true;
01712             if((*i1)->socket.cmp()==false && !(*i1)->waiting) {
01713                 if((*i1)->ssl_connection) {
01714                     ssl_close((*i1)->ssl,&((*i1)->socket));
01715                 }
01716                 delete *i1;
01717                 bots.erase(i1);
01718                 goto label;
01719             }
01720             got=true;
01721             //(*i1)->unlink_proc_called=false;
01722         }
01723     if(got || got_one)
01724         return;
01725 
01726     s_bot* s=new s_bot;
01727     s->clear();
01728     s->botname="";
01729     s->localip="";
01730     s->botip="";
01731     s->botport=0;
01732     s->socket.clear();
01733     s->remote_MD5_password="";
01734     s->sent_bot_auth_1=false;
01735     s->received_bot_auth_1=false;
01736     s->receive_buffer_pos=0;
01737 
01738     s->buff_size_from_dcc=0;
01739 
01740     s->botname=botname;
01741     s->localip=localip;
01742     s->botip=botip;
01743     s->botport=botport;
01744     s->socket.clear();
01745     s->remote_MD5_password=remote_MD5_password;
01746 
01747     s->command_receive_buffer.hard_clear();
01748     s->control_receive_buffer.hard_clear();
01749     s->receive_buffer_pos=0;
01750 
01751     s->unlink_proc=unlink_proc;
01752     s->vars=vars;
01753     s->unlink_proc_called=false;
01754 
01755     s->got_bytes=0;
01756     s->auth_ok=false;
01757     s->remote_pswd_ok=false;
01758     s->was_linked=false;
01759     s->last_try=0x7FFFFFFF;
01760     s->invoked_from_telnet=false;
01761 
01762     s->ssl_connection=!bot_link_type.compare("telnet_ssl");
01763     s->ssl=NULL;
01764 
01765     bots.push_back(s);
01766 }

Here is the call graph for this function:

void botnet_loop  ) 
 

Process the communication with other bots, this should be called in loop.

Author:
VooDooMan
Version:
2
Date:
2005

Definition at line 3892 of file botnet.cpp.

References s_user::access_grant_apply, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::access_grant_apply, s_user::access_grant_backup, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_backup, s_user::access_grant_can_send_all_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_can_send_all_users, s_user::access_grant_can_send_unknown_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_can_send_unknown_users, s_user::access_grant_channel, s_bot_command::u_commnd_data::s_cmd_repl_user_09_1::access_grant_channel, s_user::access_grant_die, s_user::access_grant_filesystem, s_user::access_grant_group, s_bot_command::u_commnd_data::s_cmd_repl_user_07_1::access_grant_group, s_user::access_grant_partyline, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_partyline, s_user::access_grant_plusproc, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_plusproc, s_user::access_grant_plususer, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_plususer, s_user::access_grant_private, s_bot_command::u_commnd_data::s_cmd_repl_user_06_1::access_grant_proc, s_user::access_grant_procedure, s_user::access_grant_rehash, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_rehash, s_user::access_grant_replication, s_user::access_grant_restart, s_user::access_grant_upgrade, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::access_grant_upgrade, s_user::access_to_apply, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::access_to_apply, s_user::access_to_backup, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_backup, s_user::access_to_can_send_all_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_can_send_all_users, s_user::access_to_can_send_unknown_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_can_send_unknown_users, s_user::access_to_channel, s_bot_command::u_commnd_data::s_cmd_repl_user_08_1::access_to_channel, s_user::access_to_die, s_user::access_to_filesystem, s_user::access_to_group, s_bot_command::u_commnd_data::s_cmd_repl_user_04_1::access_to_group, s_user::access_to_partyline, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_partyline, s_user::access_to_plusproc, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_plusproc, s_user::access_to_plususer, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_plususer, s_user::access_to_private, s_user::access_to_proc, s_bot_command::u_commnd_data::s_cmd_repl_user_05_1::access_to_proc, s_user::access_to_rehash, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_rehash, s_user::access_to_replication, s_user::access_to_restart, s_user::access_to_upgrade, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::access_to_upgrade, s_bot_command::u_commnd_data::s_cmd_repl_user_15_1::access_usage_proc, s_user::access_usage_procedure, s_channel_def::allow_dynamic, s_bot_command::u_commnd_data::s_cmd_remote_procedure_call_3::args_array, s_bot_command::u_commnd_data::bot_auth_1, s_user_to_pull::botname, s_proc_to_pull::botname, s_bot_command::u_commnd_data::s_cmd_partyline_1::botname, s_partyline_member::botname, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::botname, s_chan_def_to_pull::botname, s_bot_command::u_commnd_data::s_bot_auth_1::botname, s_user_to_push::botname, s_proc_to_push::botname, s_chan_def_to_push::botname, botnet_backup(), botnet_botname, botnet_channels, botnet_cleanup_ids(), botnet_get_unique_id(), botnet_has_grant(), botnet_last_rehash_request, botnet_on_unlink(), botnet_partyline_event(), botnet_penalty, botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), botnet_receive(), botnet_rehash(), botnet_send_command(), botnet_send_control(), bots, s_channel::can_send_unknown_users, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::can_send_unknown_users, s_chan_def_to_pull::chan_name, s_chan_def_to_push::chan_name, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::channel, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::channel, s_bot_command::u_commnd_data::s_cmd_partyline_1::channel, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::channel, s_bot_command::u_commnd_data::s_no_repl_1::channel_def, s_bot_command::u_commnd_data::s_check_time_1::channel_def, s_bot_command::u_commnd_data::s_cmd_push_1::channel_def, s_channel_def::channel_name, s_channel::channel_name, s_botnet_channel::channel_name, s_chan_def_to_pull::chd, s_bot_command::u_commnd_data::check_time_1, s_channel::clear(), s_ssl_conf::client_cert, s_ssl_conf::client_key, CMD_AUTH_1, CMD_CHECK_TIME_1, CMD_NO_REPL_1, CMD_PARTYLINE_1, s_bot_command::u_commnd_data::cmd_partyline_1, CMD_PARTYLINE_USER_1, s_bot_command::u_commnd_data::cmd_partyline_user_1, CMD_PROC_1, s_bot_command::u_commnd_data::cmd_proc_1, CMD_PROC_END_1, s_bot_command::u_commnd_data::cmd_proc_end_1, CMD_PUSH_1, s_bot_command::u_commnd_data::cmd_push_1, CMD_REMOTE_PROCEDURE_CALL_3, s_bot_command::u_commnd_data::cmd_remote_procedure_call_3, CMD_REPL_CHDEF_01_1, s_bot_command::u_commnd_data::cmd_repl_chdef_01_1, CMD_REPL_CHDEF_02_1, s_bot_command::u_commnd_data::cmd_repl_chdef_02_1, CMD_REPL_CHDEF_03_1, s_bot_command::u_commnd_data::cmd_repl_chdef_03_1, CMD_REPL_CHDEF_04_1, s_bot_command::u_commnd_data::cmd_repl_chdef_04_1, CMD_REPL_CHDEF_05_1, s_bot_command::u_commnd_data::cmd_repl_chdef_05_1, CMD_REPL_CHDEF_06_8, s_bot_command::u_commnd_data::cmd_repl_chdef_06_8, CMD_REPL_CHDEF_99_1, s_bot_command::u_commnd_data::cmd_repl_chdef_99_1, CMD_REPL_PRV_01_1, s_bot_command::u_commnd_data::cmd_repl_prv_01_1, CMD_REPL_PRV_02_1, s_bot_command::u_commnd_data::cmd_repl_prv_02_1, CMD_REPL_PRV_03_1, s_bot_command::u_commnd_data::cmd_repl_prv_03_1, CMD_REPL_PRV_04_7, s_bot_command::u_commnd_data::cmd_repl_prv_04_7, CMD_REPL_PRV_05_8, s_bot_command::u_commnd_data::cmd_repl_prv_05_8, CMD_REPL_PRV_06_11, s_bot_command::u_commnd_data::cmd_repl_prv_06_11, CMD_REPL_PRV_99_1, CMD_REPL_USER_01_1, s_bot_command::u_commnd_data::cmd_repl_user_01_1, CMD_REPL_USER_02_1, s_bot_command::u_commnd_data::cmd_repl_user_02_1, CMD_REPL_USER_03_1, s_bot_command::u_commnd_data::cmd_repl_user_03_1, CMD_REPL_USER_04_1, s_bot_command::u_commnd_data::cmd_repl_user_04_1, CMD_REPL_USER_05_1, s_bot_command::u_commnd_data::cmd_repl_user_05_1, CMD_REPL_USER_06_1, s_bot_command::u_commnd_data::cmd_repl_user_06_1, CMD_REPL_USER_07_1, s_bot_command::u_commnd_data::cmd_repl_user_07_1, CMD_REPL_USER_08_1, s_bot_command::u_commnd_data::cmd_repl_user_08_1, CMD_REPL_USER_09_1, s_bot_command::u_commnd_data::cmd_repl_user_09_1, CMD_REPL_USER_10_1, s_bot_command::u_commnd_data::cmd_repl_user_10_1, CMD_REPL_USER_11_1, s_bot_command::u_commnd_data::cmd_repl_user_11_1, CMD_REPL_USER_12_1, s_bot_command::u_commnd_data::cmd_repl_user_12_1, CMD_REPL_USER_13_1, s_bot_command::u_commnd_data::cmd_repl_user_13_1, CMD_REPL_USER_14_1, s_bot_command::u_commnd_data::cmd_repl_user_14_1, CMD_REPL_USER_15_1, s_bot_command::u_commnd_data::cmd_repl_user_15_1, CMD_REPL_USER_16_5, s_bot_command::u_commnd_data::cmd_repl_user_16_5, CMD_REPL_USER_17_9, s_bot_command::u_commnd_data::cmd_repl_user_17_9, CMD_REPL_USER_99_1, s_bot_command::u_commnd_data::cmd_repl_user_99_1, s_bot_command::command, s_bot_command::command_data, conf_getvar(), s_bot_control::control, s_channel::ctcp_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::ctcp_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::ctcp_flood_s, CTRL_ERROR_001, CTRL_ERROR_002, CTRL_LINKED, CTRL_PING, CTRL_PONG, dcc_get_password(), s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::dcc_group, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::dcc_host, s_user::dcc_hosts, dcc_users_to_lock_out, s_bot_command::u_commnd_data::s_bot_auth_1::digest, s_channel_def::dynamic_bans, s_channel::dynamic_minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::dynamic_minus_modes, s_channel_def::dynamic_minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::dynamic_minus_modes, s_channel::dynamic_plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::dynamic_plus_modes, s_channel_def::dynamic_plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::dynamic_plus_modes, s_channel_def::dynbans_editors, s_user::fullname, s_bot_command::u_commnd_data::s_cmd_repl_user_03_1::fullname, s_bot_command::u_commnd_data::s_cmd_repl_user_10_1::group, s_dcc_host::group, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::group, s_dynamic_rule::group, s_bot_command::u_commnd_data::s_cmd_repl_prv_02_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1::group, s_user::groups, s_channel_def::groups, s_bot_command::hard_clear(), s_bot_control::hard_clear(), s_dcc_host::host, s_user::host_bot, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::host_bot, s_user::host_unknown, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::host_unknown, s_channel::host_unknown, s_user::hostmask, s_bot_command::u_commnd_data::s_cmd_repl_user_02_1::hostmask, s_bot_command::u_commnd_data::s_cmd_partyline_1::id, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::id, s_bot_command::u_commnd_data::s_cmd_proc_1::init, s_user::is_template, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::is_template, s_channel::is_template, s_channel::join_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::join_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::join_flood_s, s_user::last_changed, s_procedure::last_changed, s_channel_def::last_changed, s_private::last_changed, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::last_changed, s_bot_command::u_commnd_data::s_cmd_repl_prv_01_1::last_changed, s_proc_to_pull::last_changed, s_bot_command::u_commnd_data::s_cmd_proc_1::last_changed, s_chan_def_to_pull::last_changed, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::last_changed, s_proc_to_push::last_changed, s_chan_def_to_push::last_changed, s_bot_command::u_commnd_data::s_cmd_proc_1::line, s_flood::lines, s_proc_to_pull::lines, log_botnet(), log_botnet_debug(), log_socket(), logic_botnet_backup(), logic_botnet_get_channel_def(), logic_botnet_get_proc(), logic_botnet_get_user(), logic_botnet_rehash(), logic_botnet_remove_channel_def(), logic_botnet_remove_user(), logic_call_proc_ex2(), logic_eval(), logic_find_proc_by_name(), logic_get_push_chan_defs(), logic_get_push_procs(), logic_get_push_users(), logic_on_internal_event(), logic_parse_proc(), logic_partyline_get_user(), logic_partyline_get_user_template(), ltoa(), s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::mask, MD5Final(), MD5Init(), MD5Update(), s_user::meta, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::meta_key, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::meta_val, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::minus_modes, s_dynamic_rule::minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::minus_modes, s_channel::mode_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::mode_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::mode_flood_s, s_channel::msg_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::msg_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::msg_flood_s, msg_ids, s_user::name, s_procedure::name, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_02_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_03_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_04_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_05_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_06_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_07_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_08_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_09_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_10_1::name, s_group::name, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_15_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::name, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::name, s_bot_command::u_commnd_data::s_cmd_repl_user_99_1::name, s_bot_command::u_commnd_data::s_cmd_proc_1::name, s_bot_command::u_commnd_data::s_cmd_proc_end_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_99_1::name, s_channel::nick_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::nick_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::nick_flood_s, s_bot_command::u_commnd_data::no_repl_1, s_channel::notice_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::notice_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::notice_flood_s, s_bot_command::u_commnd_data::s_check_time_1::now, s_bot_command::u_commnd_data::s_cmd_remote_procedure_call_3::num_args, s_bot_command::u_commnd_data::s_check_time_1::object_name, s_bot_command::u_commnd_data::s_no_repl_1::object_name, s_bot_command::u_commnd_data::s_cmd_push_1::object_name, s_channel::on_ban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_ban, s_channel::on_banned, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_banned, s_private::on_broadcast, s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8::on_broadcast, s_channel::on_creator, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_creator, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_ctcp, s_channel_def::on_ctcp, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_ctcp, s_channel::on_decreator, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_decreator, s_channel::on_deop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_deop, s_channel::on_devoice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_devoice, s_channel_def::on_dynamic_ban, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_dynamic_ban, s_channel::on_except, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_except, s_private::on_filesys_got_new, s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7::on_filesys_got_new, s_channel::on_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_flood, s_private::on_fnc, s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7::on_fnc, s_bot_command::u_commnd_data::s_cmd_repl_prv_06_11::on_internal_event, s_channel::on_invite, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_invite, s_channel_def::on_ircop, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_ircop, s_channel::on_join, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_join, s_channel_def::on_key, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_key, s_channel::on_kick, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_kick, s_channel_def::on_limit, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_limit, s_channel_def::on_mode, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_mode, s_channel::on_not_in_reop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_not_in_reop, s_channel::on_not_invited, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_not_invited, s_channel::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_notice, s_channel_def::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_notice, s_channel::on_op, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_op, s_channel_def::on_part, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_part, s_channel::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_privmsg, s_channel_def::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_privmsg, s_channel::on_reop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_reop, s_private::on_server_msg, s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8::on_server_msg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8::on_server_msg, s_channel_def::on_server_msg, s_channel_def::on_topic, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_topic, s_channel::on_unban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_unban, s_channel::on_unexcept, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_unexcept, s_channel::on_uninvite, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_uninvite, s_channel::on_voice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_voice, s_proc_to_pull::orig_groups, s_bot_command::u_commnd_data::s_check_time_1::original_time, s_bot_command::u_commnd_data::s_cmd_push_1::original_time, s_bot_control::packet_type, s_bot_command::packet_type, PACKET_TYPE_COMMAND, PACKET_TYPE_CONTROL, s_replication::partner, s_user::partyline_msg_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::partyline_msg_flood, ping_time, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::plus_modes, s_dynamic_rule::plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::plus_modes, PRIVATE_EVENT_SEVERITY_CODE_CRITICAL_ERROR, PRIVATE_EVENT_SEVERITY_CODE_ERROR, PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, PRIVATE_EVENT_SEVERITY_CODE_WARNING, s_proc_to_pull::proc_name, s_proc_to_push::proc_name, s_bot_command::u_commnd_data::s_no_repl_1::procedure, s_bot_command::u_commnd_data::s_check_time_1::procedure, s_bot_command::u_commnd_data::s_cmd_push_1::procedure, s_bot_command::u_commnd_data::s_no_repl_1::prv, s_bot_command::u_commnd_data::s_check_time_1::prv, s_bot_command::u_commnd_data::s_cmd_push_1::prv, r_channel_defs, r_channel_templates, r_channel_terminators, r_channels, r_procedures, r_terminators, r_user_templates, r_users, s_bot_command::u_commnd_data::s_no_repl_1::reason, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::reason, REASON_NO_REPL_1_ACCESS_DENIED, REASON_NO_REPL_1_UP_TO_DATE, s_user_to_lock_out::remote, s_channel::repeat_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::repeat_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::repeat_flood_s, REPL_PULL, REPL_PUSH, REPL_PUSHPULL, s_user::replication, s_procedure::replication, s_channel_def::replication, s_private::replication, s_proc_to_pull::replication, s_user::replication_partner, s_flood::seconds, s_bot_command::size, sleep(), sock_close(), sock_connect(), sock_error(), sock_read(), sock_send(), sock_set_blocking(), ssl_client_connection(), ssl_close(), ssl_do_read_write(), stats_botnet_auth_error(), stats_botnet_auth_ok(), stats_botnet_auth_proto_error(), stats_botnet_bytes_received(), stats_botnet_bytes_sent(), stats_botnet_chandef_pulled(), stats_botnet_new_connection(), stats_botnet_partyline_event(), stats_botnet_private_pulled(), stats_botnet_proc_pulled(), stats_botnet_user_pulled(), s_bot_control::supported_proto_version, SUPPORTED_PROTO_VERSION, s_user::terminator, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::terminator, s_user_to_lock_out::timestamp, s_replication::type, s_bot_command::u_commnd_data::s_check_time_1::user, s_bot_command::u_commnd_data::s_no_repl_1::user, s_bot_command::u_commnd_data::s_cmd_push_1::user, s_user_to_pull::user, s_bot_command::u_commnd_data::s_cmd_partyline_1::user, s_partyline_member::user, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::user, s_user_to_push::user, s_channel::username, and s_bot_command::version.

Referenced by main().

03893 {
03894     if(botnet_last_rehash_request && botnet_last_rehash_request+120<time(NULL)) {
03895         botnet_last_rehash_request=0;
03896         logic_botnet_backup("BOTNET");
03897         logic_botnet_rehash("BOTNET");
03898     }
03899 
03900     if(botnet_penalty==-1)
03901         botnet_penalty=atol(conf_getvar("botnet_penalty").c_str());
03902 
03903     vector<s_bot*>::iterator i1;
03904 
03905     vector<string> bots_;
03906 label:
03907     for(i1=bots.begin(); i1!=bots.end(); i1++) {
03908         vector<string>::iterator i2;
03909         for(i2=bots_.begin(); i2!=bots_.end(); i2++) {
03910             if(!(*i2).compare((*i1)->botname)) {
03911                 if((*i1)->ssl_connection) {
03912                     ssl_close((*i1)->ssl,&((*i1)->socket));
03913                 }
03914                 delete *i1;
03915                 bots.erase(i1);
03916                 goto label;
03917             }
03918         }
03919         bots_.push_back((*i1)->botname);
03920     }
03921 
03922     static s_bot_command* cmd=new s_bot_command;
03923     static s_bot_control* ctrl=new s_bot_control;
03924 
03925     // receive
03926     for(i1=bots.begin(); i1!=bots.end(); i1++) {
03927         if((*i1)->ssl)
03928             ssl_do_read_write((*i1)->ssl);
03929         if((*i1)->socket.cmp()==false)
03930             continue;
03931 
03932         cmd->hard_clear();
03933         ctrl->hard_clear();
03934 
03935 // returns 0 for empty buffer
03936 // returns 1 for got data
03937 // returns 3 for got data, but connection closed
03938 // returns 4 for don't have data, and connection closed
03939 // returns 5 connection should be closed for error
03940 //int botnet_receive(s_bot& bot, int& packet_type, s_bot_command& cmd, s_bot_control& control)
03941 
03942         int packet_type;
03943         int result=botnet_receive(*i1,packet_type,cmd,ctrl);
03944         if(result==0)
03945             continue;
03946         if(result==5) {
03947             (*i1)->receive_buffer_pos=0;
03948             if((*i1)->rle_buffer) {
03949                 free((*i1)->rle_buffer);
03950                 (*i1)->rle_buffer=NULL;
03951                 (*i1)->rle_buffer_len=0;
03952             }
03953             string log1="connection forced to close because of serious errors - in file " __FILE__ " in function " __FUNC__;
03954             string log2="closing LINK connection (error)";
03955 
03956             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,log1.c_str());
03957             log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
03958 
03959             logic_on_internal_event("@botnet_link@",(*i1)->botname,"DELINKED","","",PRIVATE_EVENT_SEVERITY_CODE_ERROR,log2+(string)"; "+log1,"");
03960 
03961             if((*i1)->ssl) {
03962                 ssl_close((*i1)->ssl,&((*i1)->socket));
03963                 (*i1)->ssl=NULL;
03964             }
03965             sock_close((*i1)->socket);
03966             (*i1)->socket.clear();
03967             continue;
03968         }
03969         if(result==4) {
03970             (*i1)->receive_buffer_pos=0;
03971             if((*i1)->rle_buffer) {
03972                 free((*i1)->rle_buffer);
03973                 (*i1)->rle_buffer=NULL;
03974                 (*i1)->rle_buffer_len=0;
03975             }
03976             string log1="connection closed before all data had been received - in file " __FILE__ " in function " __FUNC__;
03977             string log2="closing LINK connection (error)";
03978 
03979             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,log1.c_str());
03980             log_botnet(botnet_botname,(*i1)->botname.c_str(),log1.c_str());
03981 
03982             logic_on_internal_event("@botnet_link@",(*i1)->botname,"DELINKED","","",PRIVATE_EVENT_SEVERITY_CODE_ERROR,log2+(string)"; "+log1,"");
03983 
03984             if((*i1)->ssl) {
03985                 ssl_close((*i1)->ssl,&((*i1)->socket));
03986                 (*i1)->ssl=NULL;
03987             }
03988             sock_close((*i1)->socket);
03989             (*i1)->socket.clear();
03990             continue;
03991         }
03992         if(result==3) {
03993             // log
03994             if((*i1)->ssl) {
03995                 ssl_close((*i1)->ssl,&((*i1)->socket));
03996                 (*i1)->ssl=NULL;
03997             }
03998             sock_close((*i1)->socket);
03999             (*i1)->socket.clear();
04000         }
04001         if(result==1 || result==3) {
04002             // if we got at least one PONG already, we have received packet, so waiting for PONG is not required (coz we got packet! thus we know that connection is alive!)
04003             if((*i1)->got_at_least_one_pong)
04004                 (*i1)->start_awaiting_pong=0;
04005 
04006             (*i1)->receive_buffer_pos=0;
04007             if((*i1)->rle_buffer) {
04008                 free((*i1)->rle_buffer);
04009                 (*i1)->rle_buffer=NULL;
04010                 (*i1)->rle_buffer_len=0;
04011             }
04012 
04013             if(packet_type==PACKET_TYPE_CONTROL) {
04014                 (*i1)->supported_proto_version=ctrl->supported_proto_version;
04015                 switch(ctrl->control) {
04016                     case CTRL_ERROR_001:        // remote is using greater protocol version than me!
04017                         stats_botnet_auth_proto_error();
04018                         if((*i1)->ssl) {
04019                             ssl_close((*i1)->ssl,&((*i1)->socket));
04020                             (*i1)->ssl=NULL;
04021                         }
04022                         sock_close((*i1)->socket);
04023                         (*i1)->socket.clear();
04024 
04025                         {
04026                             string log1="connection closed: remote bot is using newer unsupported protocol - in file " __FILE__ " in function " __FUNC__;
04027                             string log2="closing LINK connection (unsupported protocol)";
04028                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),packet_type,ctrl->control,log1.c_str());
04029                             log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04030 
04031                             logic_on_internal_event("@botnet_link@",(*i1)->botname,"DELINKED","","",PRIVATE_EVENT_SEVERITY_CODE_ERROR,log2+(string)"; "+log1,"");
04032                         }
04033 
04034                         break;
04035                     case CTRL_ERROR_002:
04036                         stats_botnet_auth_error();
04037                         if((*i1)->ssl) {
04038                             ssl_close((*i1)->ssl,&((*i1)->socket));
04039                             (*i1)->ssl=NULL;
04040                         }
04041                         sock_close((*i1)->socket);
04042                         (*i1)->socket.clear();
04043 
04044                         {
04045                             string log1="connection closed: bad password - in file " __FILE__ " in function " __FUNC__;
04046                             string log2="BAD PASSWORD on my side";
04047 
04048                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),packet_type,ctrl->control,log1.c_str());
04049                             log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04050 
04051                             logic_on_internal_event("@botnet_link@",(*i1)->botname,"BAD_PASSWORD_HERE","","",PRIVATE_EVENT_SEVERITY_CODE_CRITICAL_ERROR,log2+(string)"; "+log1,"");
04052                         }
04053                         break;
04054                     case CTRL_LINKED:
04055                         (*i1)->remote_pswd_ok=true;
04056                         if((*i1)->auth_ok && (*i1)->remote_pswd_ok) {
04057                             vector<s_bot*>::iterator i2;
04058                         label_2:
04059                             for(i2=bots.begin(); i2!=bots.end(); i2++)
04060                                 if(!(*i2)->botname.compare((*i1)->botname) && (*i2)->socket.handle!=(*i1)->socket.handle) {
04061                                     bots.erase(i2);
04062                                     goto label_2;
04063                                 }
04064 
04065                             stats_botnet_auth_ok();
04066                             (*i1)->was_linked=true;
04067 
04068                             {
04069                                 string log1="LINKED";
04070                                 string log2="LINK connection established";
04071 
04072                                 log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,log1.c_str());
04073                                 log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04074 
04075                                 logic_on_internal_event("@botnet_link@",(*i1)->botname,"LINKED","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,log2+(string)"; "+log1,"");
04076                             }
04077                         }
04078                         break;
04079                     case CTRL_PING:
04080                         {
04081                             s_bot_control* c=new s_bot_control;
04082                             c->hard_clear();
04083                             c->packet_type=PACKET_TYPE_CONTROL;
04084                             c->supported_proto_version=SUPPORTED_PROTO_VERSION;
04085                             c->control=CTRL_PONG;
04086                             botnet_send_control(*i1,c);
04087                             delete c;
04088                         }
04089                         break;
04090                     case CTRL_PONG:
04091                         (*i1)->start_awaiting_pong=0;
04092                         (*i1)->got_at_least_one_pong=true;
04093                         break;
04094                     default:
04095                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,ctrl->control,"unknown PACKET_TYPE_CONTROL from remote bot - in file " __FILE__ " in function " __FUNC__);
04096                         break;
04097                 }
04098                 /*delete cmd;
04099                 delete ctrl;*/
04100                 return;
04101             }
04102             if(packet_type==PACKET_TYPE_COMMAND) {
04103                 if(cmd->version>SUPPORTED_PROTO_VERSION) {
04104                     s_bot_control* c=new s_bot_control;
04105                     c->hard_clear();
04106 
04107                     c->packet_type=PACKET_TYPE_CONTROL;
04108                     c->supported_proto_version=SUPPORTED_PROTO_VERSION;
04109                     c->control=CTRL_ERROR_001;
04110 
04111                     if(botnet_send_control(*i1,c)) {
04112                         string log1="unable to send PACKET_TYPE_CONTROL to remote bot - in file " __FILE__ " in function " __FUNC__;
04113                         string log2="closing LINK connection (error)";
04114 
04115                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->control,log1.c_str());
04116                         log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04117 
04118                         logic_on_internal_event("@botnet_link@",(*i1)->botname,"DELINKED","","",PRIVATE_EVENT_SEVERITY_CODE_ERROR,log2+(string)"; "+log1,"");
04119 
04120                         if((*i1)->ssl) {
04121                             ssl_close((*i1)->ssl,&((*i1)->socket));
04122                             (*i1)->ssl=NULL;
04123                         }
04124                         sock_close((*i1)->socket);
04125                         (*i1)->socket.clear();
04126 
04127                         delete c;
04128 
04129                         continue;
04130                     }
04131                     delete c;
04132                 }
04133                 if(cmd->version==1 || 1) { // always true
04134                     if((!(*i1)->auth_ok || !(*i1)->remote_pswd_ok) && cmd->command!=CMD_AUTH_1) {
04135                         s_bot_control* c=new s_bot_control;
04136                         c->hard_clear();
04137 
04138                         c->packet_type=PACKET_TYPE_CONTROL;
04139                         c->supported_proto_version=SUPPORTED_PROTO_VERSION;
04140                         c->control=CTRL_ERROR_002;
04141 
04142                         if(botnet_send_control(*i1,c)) {
04143                             string log1="unable to send PACKET_TYPE_CONTROL to remote bot - in file " __FILE__ " in function " __FUNC__;
04144                             string log2="closing LINK connection (error)";
04145 
04146                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->control,log1.c_str());
04147                             log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04148 
04149                             logic_on_internal_event("@botnet_link@",(*i1)->botname,"DELINKED","","",PRIVATE_EVENT_SEVERITY_CODE_ERROR,log2+(string)"; "+log1,"");
04150 
04151                             if((*i1)->ssl) {
04152                                 ssl_close((*i1)->ssl,&((*i1)->socket));
04153                                 (*i1)->ssl=NULL;
04154                             }
04155                             sock_close((*i1)->socket);
04156                             (*i1)->socket.clear();
04157                         }
04158 
04159                         if((*i1)->ssl) {
04160                             ssl_close((*i1)->ssl,&((*i1)->socket));
04161                             (*i1)->ssl=NULL;
04162                         }
04163                         sock_close((*i1)->socket);
04164                         (*i1)->socket.clear();
04165 
04166                         delete c;
04167                         continue;
04168                     }
04169                     switch(cmd->command) {
04170                         case CMD_AUTH_1:
04171                             {
04172                                 unsigned char signature[32+1];
04173                                 signature[32]=0;
04174 
04175                                 if((*i1)->remote_MD5_password.length()==sizeof(signature)-1)
04176                                     strcpy((char*)signature,(*i1)->remote_MD5_password.c_str());
04177 
04178                                 MD5Context md5c;
04179                                 MD5Init(&md5c);
04180                                 MD5Update(&md5c,signature,sizeof(signature)-1);
04181                                 MD5Final(signature,&md5c);
04182 
04183                                 char sig[128];
04184                                 sig[0]=0;
04185                                 for(int i1_=0; i1_<16; i1_++) {
04186                                     char tmp[16];
04187                                     sprintf(tmp,"%02X",signature[i1_]);
04188                                     strcat(sig,tmp);
04189                                 }
04190 
04191                                 bool equal=true;
04192                                 for(unsigned int i=0; i<sizeof(signature)-1; i++)
04193                                     if(cmd->command_data.bot_auth_1.digest[i]!=sig[i]) {
04194                                         equal=false;
04195                                         break;
04196                                     }
04197                                 if(!equal) {
04198                                     extern vector<s_user_to_lock_out> dcc_users_to_lock_out;
04199 
04200                                     s_user_to_lock_out u;
04201                                     u.timestamp=time(NULL);
04202                                     u.remote=(*i1)->botip;
04203                                     dcc_users_to_lock_out.push_back(u);
04204 
04205                                     string log1="incorrect password from remote bot - in file " __FILE__ " in function " __FUNC__;
04206                                     string log2="BAD PASSWORD on the other side";
04207 
04208                                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,log1.c_str());
04209                                     log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04210 
04211                                     logic_on_internal_event("@botnet_link@",(*i1)->botname,"BAD_PASSWORD_THERE","","",PRIVATE_EVENT_SEVERITY_CODE_CRITICAL_ERROR,log2+(string)"; "+log1,"");
04212 
04213                                     if(result==1) {
04214                                         s_bot_control* c=new s_bot_control;
04215                                         c->hard_clear();
04216 
04217                                         c->packet_type=PACKET_TYPE_CONTROL;
04218                                         c->supported_proto_version=SUPPORTED_PROTO_VERSION;
04219                                         c->control=CTRL_ERROR_002;
04220 
04221                                         if(botnet_send_control(*i1,c)) {
04222                                             string log1="unable to send PACKET_TYPE_CONTROL to remote bot - in file " __FILE__ " in function " __FUNC__;
04223                                             string log2="closing LINK connection (error)";
04224 
04225                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->control,log1.c_str());
04226                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04227 
04228                                             logic_on_internal_event("@botnet_link@",(*i1)->botname,"DELINKED","","",PRIVATE_EVENT_SEVERITY_CODE_ERROR,log2+(string)"; "+log1,"");
04229 
04230                                             if((*i1)->ssl) {
04231                                                 ssl_close((*i1)->ssl,&((*i1)->socket));
04232                                                 (*i1)->ssl=NULL;
04233                                             }
04234                                             sock_close((*i1)->socket);
04235                                             (*i1)->socket.clear();
04236                                         }
04237 
04238                                         if((*i1)->ssl) {
04239                                             ssl_close((*i1)->ssl,&((*i1)->socket));
04240                                             (*i1)->ssl=NULL;
04241                                         }
04242                                         sock_close((*i1)->socket);
04243                                         (*i1)->socket.clear();
04244 
04245                                         delete c;
04246                                     }
04247                                     //result==3 : connection already closed, so do nothing
04248                                     continue;
04249                                 } else {
04250                                     (*i1)->auth_ok=true;
04251 
04252                                     s_bot_control* c=new s_bot_control;
04253                                     c->hard_clear();
04254                                     c->packet_type=PACKET_TYPE_CONTROL;
04255                                     c->supported_proto_version=SUPPORTED_PROTO_VERSION;
04256                                     c->control=CTRL_LINKED;
04257                                     botnet_send_control(*i1,c);
04258 
04259                                     if((*i1)->auth_ok && (*i1)->remote_pswd_ok) {
04260                                         (*i1)->was_linked=true;
04261 
04262                                         string log1="LINKED";
04263                                         string log2="LINK connection established";
04264 
04265                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,log1.c_str());
04266                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),log2.c_str());
04267 
04268                                         logic_on_internal_event("@botnet_link@",(*i1)->botname,"LINKED","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,log2+(string)"; "+log1,"");
04269                                     }
04270                                     delete c;
04271                                 }
04272                             }
04273                             break;
04274                         case CMD_REMOTE_PROCEDURE_CALL_3:
04275                             {
04276                                 //string call_string;
04277                                 string proc_name_only;
04278                                 list<string> params;
04279 
04280                                 int num_args=cmd->command_data.cmd_remote_procedure_call_3.num_args;
04281                                 int curr_arg=0;
04282                                 string arg;
04283                                 for(int i2=0; i2<sizeof(cmd->command_data.cmd_remote_procedure_call_3.args_array); i2++) {
04284                                     if(curr_arg>=num_args)
04285                                         break;
04286                                     if(cmd->command_data.cmd_remote_procedure_call_3.args_array[i2]==0) {
04287                                         if(curr_arg==0) {
04288                                             //call_string=arg+"(";
04289                                             proc_name_only=arg;
04290                                         } else {
04291                                             /*if(curr_arg!=1)
04292                                                 call_string+=",";
04293                                             call_string+=(string)"\""+arg+"\"";*/
04294                                             params.push_back(arg);
04295                                         }
04296                                         arg="";
04297                                         curr_arg++;
04298                                     } else {
04299                                         arg+=cmd->command_data.cmd_remote_procedure_call_3.args_array[i2];
04300                                     }
04301                                 }
04302                                 //call_string+=")";
04303 
04304                                 string call_string;
04305 
04306                                 bool got=false;
04307                                 vector<s_procedure>::iterator i3;
04308                                 for(i3=r_procedures.begin(); i3!=r_procedures.end(); i3++) {
04309                                     string s=(*i3).name;
04310                                     unsigned int i2;
04311                                     for(i2=0; i2<s.length(); i2++)
04312                                         if(s[i2]=='(')
04313                                             break;
04314                                     s.erase(i2,s.length()-i2); // erase everything after '('
04315                                     if(!s.compare(proc_name_only)) {
04316                                         vector<s_rproc>::iterator i4;
04317                                         for(i4=(*i3).rproc.begin(); i4!=(*i3).rproc.end(); i4++)
04318                                             if(!(*i4).remote_bot.compare((*i1)->botname)) {
04319                                                 got=true;
04320                                                 break;
04321                                             }
04322                                         call_string=(*i3).name;
04323                                         break;
04324                                     }
04325                                 }
04326 
04327                                 map<string,string> vars;
04328                                 if(got)
04329                                     logic_call_proc_ex2(call_string.c_str(),vars,params);
04330                                 else
04331                                     ; // access denied, or procedure not found = ignore!
04332                             }
04333                             break;
04334                         case CMD_CHECK_TIME_1:
04335                             {
04336                                 // remote is trying to PULL
04337                                 string obj=cmd->command_data.check_time_1.object_name;
04338                                 string remote=(*i1)->botname;
04339                                 if(cmd->command_data.check_time_1.user) {
04340                                     s_user u;
04341                                     bool got2=false;
04342                                     if(logic_botnet_get_user(obj,u))
04343                                         got2=true;
04344                                     bool got=false;
04345                                     if(got2) {
04346                                         vector<s_replication>::iterator i2;
04347                                         for(i2=u.replication.begin(); i2!=u.replication.end(); i2++)
04348                                             if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
04349                                                 got=true;
04350                                                 break;
04351                                             }
04352                                     }
04353                                     if(got2 && !got) {
04354                                         s_bot_command* c=new s_bot_command;
04355                                         c->hard_clear();
04356                                         c->packet_type=PACKET_TYPE_COMMAND;
04357                                         c->size=sizeof(c);
04358                                         c->version=1;
04359                                         c->command=CMD_NO_REPL_1;
04360                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
04361                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
04362                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
04363                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04364                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
04365                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04366                                         botnet_send_command(*i1,c);
04367 
04368                                         string d="I have rejected replication of object ";
04369                                         if(c->command_data.no_repl_1.user)
04370                                             d+="(user) ";
04371                                         if(c->command_data.no_repl_1.procedure)
04372                                             d+="(procedure) ";
04373                                         if(c->command_data.no_repl_1.channel_def)
04374                                             d+="(channel) ";
04375                                         if(c->command_data.no_repl_1.prv)
04376                                             d+="(private)"; // no trailing SPACE!!!
04377                                         d+=obj;
04378                                         d+=", reason: ";
04379                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04380                                             d+="up to date";
04381                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04382                                             d+="access denied";
04383                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04384                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04385 
04386                                         {
04387                                             string obj_type="?";
04388                                             if(c->command_data.no_repl_1.user)
04389                                                 obj_type="user";
04390                                             if(c->command_data.no_repl_1.procedure)
04391                                                 obj_type="procedure";
04392                                             if(c->command_data.no_repl_1.channel_def)
04393                                                 obj_type="channel";
04394                                             if(c->command_data.no_repl_1.prv)
04395                                                 obj_type="private";
04396 
04397                                             string reason="?";
04398                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04399                                                 reason="up to date";
04400                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04401                                                 reason="access denied";
04402 
04403                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04404                                         }
04405 
04406                                         delete c;
04407 
04408                                         break;
04409                                     }
04410                                     time_t now;
04411                                     time(&now);
04412                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
04413                                     time_t obj_diff=u.last_changed-(cmd->command_data.check_time_1.original_time-diff);
04414                                     if(got2 && ((signed)obj_diff>60 || cmd->command_data.check_time_1.original_time==0)) {
04415                                         botnet_push_user(*i1,u);
04416                                     }
04417                                 }
04418                                 if(cmd->command_data.check_time_1.procedure) {
04419                                     s_procedure p;
04420                                     bool got2=false;
04421                                     if(logic_botnet_get_proc(obj,p))
04422                                         got2=true;
04423                                     bool got=false;
04424                                     if(got2) {
04425                                         vector<s_replication>::iterator i2;
04426                                         for(i2=p.replication.begin(); i2!=p.replication.end(); i2++)
04427                                             if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
04428                                                 got=true;
04429                                                 break;
04430                                             }
04431                                     }
04432                                     if(got2 && !got) {
04433                                         s_bot_command* c=new s_bot_command;
04434                                         c->hard_clear();
04435                                         c->packet_type=PACKET_TYPE_COMMAND;
04436                                         c->size=sizeof(c);
04437                                         c->version=1;
04438                                         c->command=CMD_NO_REPL_1;
04439                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
04440                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
04441                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
04442                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04443                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
04444                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04445                                         botnet_send_command(*i1,c);
04446 
04447                                         string d="I have rejected replication of object ";
04448                                         if(c->command_data.no_repl_1.user)
04449                                             d+="(user) ";
04450                                         if(c->command_data.no_repl_1.procedure)
04451                                             d+="(procedure) ";
04452                                         if(c->command_data.no_repl_1.channel_def)
04453                                             d+="(channel) ";
04454                                         if(c->command_data.no_repl_1.prv)
04455                                             d+="(private)"; // no trailing SPACE!!!
04456                                         d+=obj;
04457                                         d+=", reason: ";
04458                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04459                                             d+="up to date";
04460                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04461                                             d+="access denied";
04462                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04463                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04464 
04465                                         {
04466                                             string obj_type="?";
04467                                             if(c->command_data.no_repl_1.user)
04468                                                 obj_type="user";
04469                                             if(c->command_data.no_repl_1.procedure)
04470                                                 obj_type="procedure";
04471                                             if(c->command_data.no_repl_1.channel_def)
04472                                                 obj_type="channel";
04473                                             if(c->command_data.no_repl_1.prv)
04474                                                 obj_type="private";
04475 
04476                                             string reason="?";
04477                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04478                                                 reason="up to date";
04479                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04480                                                 reason="access denied";
04481 
04482                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04483                                         }
04484 
04485                                         delete c;
04486 
04487                                         break;
04488                                     }
04489                                     time_t now;
04490                                     time(&now);
04491                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
04492                                     time_t obj_diff=p.last_changed-(cmd->command_data.check_time_1.original_time-diff);
04493                                     if(got2 && ((signed)obj_diff>60 || cmd->command_data.check_time_1.original_time==0)) {
04494                                         botnet_push_proc(*i1,p);
04495                                     }
04496                                 }
04497                                 if(cmd->command_data.check_time_1.channel_def) {
04498                                     s_channel_def chd;
04499                                     bool got2=false;
04500                                     if(logic_botnet_get_channel_def(obj,chd))
04501                                         got2=true;
04502                                     bool got=false;
04503                                     if(got2) {
04504                                         vector<s_replication>::iterator i2;
04505                                         for(i2=chd.replication.begin(); i2!=chd.replication.end(); i2++)
04506                                             if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
04507                                                 got=true;
04508                                                 break;
04509                                             }
04510                                     }
04511                                     if(got2 && !got) {
04512                                         s_bot_command* c=new s_bot_command;
04513                                         c->hard_clear();
04514                                         c->packet_type=PACKET_TYPE_COMMAND;
04515                                         c->size=sizeof(c);
04516                                         c->version=1;
04517                                         c->command=CMD_NO_REPL_1;
04518                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
04519                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
04520                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
04521                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04522                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
04523                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04524                                         botnet_send_command(*i1,c);
04525 
04526                                         string d="I have rejected replication of object ";
04527                                         if(c->command_data.no_repl_1.user)
04528                                             d+="(user) ";
04529                                         if(c->command_data.no_repl_1.procedure)
04530                                             d+="(procedure) ";
04531                                         if(c->command_data.no_repl_1.channel_def)
04532                                             d+="(channel) ";
04533                                         if(c->command_data.no_repl_1.prv)
04534                                             d+="(private)"; // no trailing SPACE!!!
04535                                         d+=obj;
04536                                         d+=", reason: ";
04537                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04538                                             d+="up to date";
04539                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04540                                             d+="access denied";
04541                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04542                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04543 
04544                                         {
04545                                             string obj_type="?";
04546                                             if(c->command_data.no_repl_1.user)
04547                                                 obj_type="user";
04548                                             if(c->command_data.no_repl_1.procedure)
04549                                                 obj_type="procedure";
04550                                             if(c->command_data.no_repl_1.channel_def)
04551                                                 obj_type="channel";
04552                                             if(c->command_data.no_repl_1.prv)
04553                                                 obj_type="private";
04554 
04555                                             string reason="?";
04556                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04557                                                 reason="up to date";
04558                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04559                                                 reason="access denied";
04560 
04561                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04562                                         }
04563 
04564                                         delete c;
04565 
04566                                         break;
04567                                     }
04568                                     time_t now;
04569                                     time(&now);
04570                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
04571                                     time_t obj_diff=chd.last_changed-(cmd->command_data.check_time_1.original_time-diff);
04572                                     if(got2 && ((signed)obj_diff>60 || cmd->command_data.check_time_1.original_time==0)) {
04573                                         botnet_push_chan(*i1,chd);
04574                                     } else {
04575                                         s_bot_command* c=new s_bot_command;
04576                                         c->hard_clear();
04577                                         c->packet_type=PACKET_TYPE_COMMAND;
04578                                         c->size=sizeof(c);
04579                                         c->version=1;
04580                                         c->command=CMD_NO_REPL_1;
04581                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
04582                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
04583                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
04584                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04585                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_UP_TO_DATE;
04586                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04587                                         botnet_send_command(*i1,c);
04588 
04589                                         string d="I have rejected replication of object ";
04590                                         if(c->command_data.no_repl_1.user)
04591                                             d+="(user)";
04592                                         if(c->command_data.no_repl_1.procedure)
04593                                             d+="(procedure)";
04594                                         if(c->command_data.no_repl_1.channel_def)
04595                                             d+="(channel)";
04596                                         if(c->command_data.no_repl_1.prv)
04597                                             d+="(private)"; // no trailing SPACE!!!
04598                                         d+=", reason: ";
04599                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04600                                             d+="up to date";
04601                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04602                                             d+="access denied";
04603                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04604                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04605 
04606                                         {
04607                                             string obj_type="channel";
04608 
04609                                             string reason="?";
04610                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04611                                                 reason="up to date";
04612                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04613                                                 reason="access denied";
04614 
04615                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04616                                         }
04617 
04618                                         delete c;
04619                                     }
04620                                 }
04621                                 if(cmd->command_data.check_time_1.prv) {
04622                                     bool got=false;
04623                                     vector<s_replication>::iterator i2;
04624                                     for(i2=r_private.replication.begin(); i2!=r_private.replication.end(); i2++)
04625                                         if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
04626                                             got=true;
04627                                             break;
04628                                         }
04629                                     s_user bot;
04630                                     logic_botnet_get_user((*i1)->botname,bot);
04631                                     if(!got) {
04632                                         s_bot_command* c=new s_bot_command;
04633                                         c->hard_clear();
04634                                         c->packet_type=PACKET_TYPE_COMMAND;
04635                                         c->size=sizeof(c);
04636                                         c->version=1;
04637                                         c->command=CMD_NO_REPL_1;
04638                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
04639                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
04640                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
04641                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04642                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
04643                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04644                                         botnet_send_command(*i1,c);
04645 
04646                                         string d="I have rejected replication of object ";
04647                                         if(c->command_data.no_repl_1.user)
04648                                             d+="(user)";
04649                                         if(c->command_data.no_repl_1.procedure)
04650                                             d+="(procedure)";
04651                                         if(c->command_data.no_repl_1.channel_def)
04652                                             d+="(channel)";
04653                                         if(c->command_data.no_repl_1.prv)
04654                                             d+="(private)"; // no trailing SPACE!!!
04655                                         d+=", reason: ";
04656                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04657                                             d+="up to date";
04658                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04659                                             d+="access denied";
04660                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04661                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04662 
04663                                         {
04664                                             string obj_type="private";
04665 
04666                                             string reason="?";
04667                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04668                                                 reason="up to date";
04669                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04670                                                 reason="access denied";
04671 
04672                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04673                                         }
04674 
04675                                         delete c;
04676 
04677                                         break;
04678                                     }
04679                                     time_t now;
04680                                     time(&now);
04681                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
04682                                     time_t obj_diff=r_private.last_changed-(cmd->command_data.check_time_1.original_time-diff);
04683                                     if(((signed)obj_diff>60 || cmd->command_data.check_time_1.original_time==0)) {
04684                                         botnet_push_prv(*i1,r_private);
04685                                     } else {
04686                                         s_bot_command* c=new s_bot_command;
04687                                         c->hard_clear();
04688                                         c->packet_type=PACKET_TYPE_COMMAND;
04689                                         c->size=sizeof(c);
04690                                         c->version=1;
04691                                         c->command=CMD_NO_REPL_1;
04692                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
04693                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
04694                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
04695                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04696                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_UP_TO_DATE;
04697                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04698                                         botnet_send_command(*i1,c);
04699 
04700                                         string d="I have rejected replication of object ";
04701                                         if(c->command_data.no_repl_1.user)
04702                                             d+="(user)";
04703                                         if(c->command_data.no_repl_1.procedure)
04704                                             d+="(procedure)";
04705                                         if(c->command_data.no_repl_1.channel_def)
04706                                             d+="(channel)";
04707                                         if(c->command_data.no_repl_1.prv)
04708                                             d+="(private)"; // no trailing SPACE!!!
04709                                         d+=", reason: ";
04710                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04711                                             d+="up to date";
04712                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04713                                             d+="access denied";
04714                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04715                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04716 
04717                                         {
04718                                             string obj_type="private";
04719 
04720                                             string reason="?";
04721                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04722                                                 reason="up to date";
04723                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04724                                                 reason="access denied";
04725 
04726                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04727                                         }
04728 
04729                                         delete c;
04730                                     }
04731                                 }
04732                             }
04733                             break;
04734                         case CMD_NO_REPL_1:
04735                             {
04736                                 char* obj=new char[sizeof(cmd->command_data.no_repl_1.object_name)+1];
04737                                 obj[sizeof(cmd->command_data.no_repl_1.object_name)]=0;
04738                                 memcpy(obj,cmd->command_data.no_repl_1.object_name,sizeof(cmd->command_data.no_repl_1.object_name));
04739                                 string d="remote bot rejected replication of object ";
04740 
04741                                 string obj_type="?";
04742 
04743                                 if(cmd->command_data.no_repl_1.user) {
04744                                     obj_type="user";
04745                                     d+="(user) ";
04746                                     (*i1)->rejected_objects.push_back((string)"USER "+obj);
04747                                 }
04748                                 if(cmd->command_data.no_repl_1.procedure) {
04749                                     obj_type="procedure";
04750                                     d+="(procedure) ";
04751                                     (*i1)->rejected_objects.push_back((string)"PROC "+obj);
04752                                 }
04753                                 if(cmd->command_data.no_repl_1.channel_def) {
04754                                     obj_type="channel";
04755                                     d+="(channel) ";
04756                                     (*i1)->rejected_objects.push_back((string)"CHAN "+obj);
04757                                 }
04758                                 if(cmd->command_data.no_repl_1.prv) {
04759                                     obj_type="private";
04760                                     d+="(private)"; // no trailing SPACE!!!
04761                                     (*i1)->rejected_objects.push_back((string)"PRIV");
04762                                 }
04763 
04764                                 if(!cmd->command_data.no_repl_1.prv)
04765                                     d+=obj;
04766                                 d+=", reason: ";
04767                                 if(cmd->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04768                                     d+="up to date";
04769                                 if(cmd->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04770                                     d+="access denied";
04771                                 log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,d.c_str());
04772                                 log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04773 
04774                                 {
04775                                     string reason="?";
04776                                     if(cmd->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04777                                         reason="up to date";
04778                                     if(cmd->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04779                                         reason="access denied";
04780 
04781                                     logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"REMOTE");
04782                                 }
04783 
04784                                 delete[] obj;
04785                             }
04786                             break;
04787                         case CMD_PUSH_1:
04788                             {
04789                                 // remote is trying to PUSH
04790                                 string obj=cmd->command_data.cmd_push_1.object_name;
04791                                 string remote=(*i1)->botname;
04792                                 if(cmd->command_data.cmd_push_1.user) {
04793                                     s_user us;
04794                                     bool got2=false;
04795                                     if(logic_botnet_get_user(obj,us))
04796                                         got2=true;
04797                                     bool got=false;
04798                                     if(got2) {
04799                                         vector<s_replication>::iterator i2;
04800                                         for(i2=us.replication.begin(); i2!=us.replication.end(); i2++)
04801                                             if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
04802                                                 got=true;
04803                                                 break;
04804                                             }
04805                                     }
04806                                     if(got2 && !got) {
04807                                         s_bot_command* c=new s_bot_command;
04808                                         c->hard_clear();
04809                                         c->packet_type=PACKET_TYPE_COMMAND;
04810                                         c->size=sizeof(c);
04811                                         c->version=1;
04812                                         c->command=CMD_NO_REPL_1;
04813                                         c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
04814                                         c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
04815                                         c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
04816                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04817                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
04818                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04819                                         botnet_send_command(*i1,c);
04820 
04821                                         string d="I have rejected replication of object ";
04822                                         if(c->command_data.no_repl_1.user)
04823                                             d+="(user) ";
04824                                         if(c->command_data.no_repl_1.procedure)
04825                                             d+="(procedure) ";
04826                                         if(c->command_data.no_repl_1.channel_def)
04827                                             d+="(channel) ";
04828                                         if(c->command_data.no_repl_1.prv)
04829                                             d+="(private)"; // no trailing SPACE!!!
04830                                         d+=obj;
04831                                         d+=", reason: ";
04832                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04833                                             d+="up to date";
04834                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04835                                             d+="access denied";
04836                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04837                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04838 
04839                                         {
04840                                             string obj_type="?";
04841                                             if(c->command_data.no_repl_1.user)
04842                                                 obj_type="user";
04843                                             if(c->command_data.no_repl_1.procedure)
04844                                                 obj_type="procedure";
04845                                             if(c->command_data.no_repl_1.channel_def)
04846                                                 obj_type="channel";
04847                                             if(c->command_data.no_repl_1.prv)
04848                                                 obj_type="private";
04849 
04850                                             string reason="?";
04851                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04852                                                 reason="up to date";
04853                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04854                                                 reason="access denied";
04855 
04856                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04857                                         }
04858 
04859                                         delete c;
04860 
04861                                         break;
04862                                     }
04863                                     time_t now;
04864                                     time(&now);
04865                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
04866                                     time_t obj_diff=us.last_changed-(cmd->command_data.cmd_push_1.original_time-diff);
04867                                     if(!got2) {
04868                                         s_user bot;
04869                                         logic_botnet_get_user((*i1)->botname,bot);
04870                                         if((cmd->command_data.cmd_push_1.user && bot.access_to_plususer) || (cmd->command_data.cmd_push_1.procedure && bot.access_to_plusproc)) {
04871                                             s_bot_command* c=new s_bot_command;
04872                                             c->hard_clear();
04873                                             c->packet_type=PACKET_TYPE_COMMAND;
04874                                             c->size=sizeof(c);
04875                                             c->version=1;
04876                                             c->command=CMD_CHECK_TIME_1;
04877                                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
04878                                             c->command_data.check_time_1.user=true;
04879                                             c->command_data.check_time_1.procedure=false;
04880                                             c->command_data.check_time_1.channel_def=false;
04881                                             c->command_data.check_time_1.prv=false;
04882                                             char* user=c->command_data.cmd_push_1.object_name;
04883                                             memset(user,0,sizeof(c->command_data.cmd_push_1.object_name));
04884                                             strncpy(user,obj.c_str(),sizeof(c->command_data.check_time_1.object_name));
04885                                             c->command_data.check_time_1.original_time=0;
04886                                             botnet_send_command(*i1,c);
04887 
04888                                             string d="replication: sent PULL request for object ";
04889                                             if(c->command_data.check_time_1.user)
04890                                                 d+="(user) ";
04891                                             if(c->command_data.check_time_1.procedure)
04892                                                 d+="(procedure) ";
04893                                             if(c->command_data.check_time_1.channel_def)
04894                                                 d+="(channel) ";
04895                                             if(c->command_data.check_time_1.prv)
04896                                                 d+="(private)"; // no trailing SPACE!!!
04897                                             d+=obj;
04898                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
04899                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04900 
04901                                             {
04902                                                 string obj_type="?";
04903                                                 if(c->command_data.check_time_1.user)
04904                                                     obj_type="user";
04905                                                 if(c->command_data.check_time_1.procedure)
04906                                                     obj_type="procedure";
04907                                                 if(c->command_data.check_time_1.channel_def)
04908                                                     obj_type="channel";
04909                                                 if(c->command_data.check_time_1.prv)
04910                                                     obj_type="private";
04911 
04912                                                 string reason="OK";
04913 
04914                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
04915                                             }
04916 
04917                                             delete c;
04918                                         } else {
04919                                             s_bot_command* c=new s_bot_command;
04920                                             c->hard_clear();
04921                                             c->packet_type=PACKET_TYPE_COMMAND;
04922                                             c->size=sizeof(c);
04923                                             c->version=1;
04924                                             c->command=CMD_NO_REPL_1;
04925                                             c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
04926                                             c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
04927                                             c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
04928                                             c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
04929                                             c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
04930                                             memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
04931                                             botnet_send_command(*i1,c);
04932 
04933                                             string d="I have rejected replication of object ";
04934                                             if(c->command_data.no_repl_1.user)
04935                                                 d+="(user) ";
04936                                             if(c->command_data.no_repl_1.procedure)
04937                                                 d+="(procedure) ";
04938                                             if(c->command_data.no_repl_1.channel_def)
04939                                                 d+="(channel) ";
04940                                             if(c->command_data.no_repl_1.prv)
04941                                                 d+="(private)"; // no trailing SPACE!!!
04942                                             d+=obj;
04943                                             d+=", reason: ";
04944                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04945                                                 d+="up to date";
04946                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04947                                                 d+="access denied";
04948                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
04949                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
04950 
04951                                             {
04952                                                 string obj_type="?";
04953                                                 if(c->command_data.no_repl_1.user)
04954                                                     obj_type="user";
04955                                                 if(c->command_data.no_repl_1.procedure)
04956                                                     obj_type="procedure";
04957                                                 if(c->command_data.no_repl_1.channel_def)
04958                                                     obj_type="channel";
04959                                                 if(c->command_data.no_repl_1.prv)
04960                                                     obj_type="private";
04961 
04962                                                 string reason="?";
04963                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
04964                                                     reason="up to date";
04965                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
04966                                                     reason="access denied";
04967 
04968                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
04969                                             }
04970 
04971                                             delete c;
04972 
04973                                             break;
04974                                         }
04975                                     } else
04976                                     if((signed)obj_diff>60) {
04977                                         s_bot_command* c=new s_bot_command;
04978                                         c->hard_clear();
04979                                         c->packet_type=PACKET_TYPE_COMMAND;
04980                                         c->size=sizeof(c);
04981                                         c->version=1;
04982                                         c->command=CMD_CHECK_TIME_1;
04983                                         c->command_data.check_time_1.now=(my_time_t)time(NULL);
04984                                         c->command_data.check_time_1.user=true;
04985                                         c->command_data.check_time_1.procedure=false;
04986                                         c->command_data.check_time_1.channel_def=false;
04987                                         c->command_data.check_time_1.prv=false;
04988                                         char* user=c->command_data.cmd_push_1.object_name;
04989                                         memset(user,0,sizeof(c->command_data.cmd_push_1.object_name));
04990                                         strncpy(user,us.name.c_str(),sizeof(c->command_data.check_time_1.object_name));
04991                                         c->command_data.check_time_1.original_time=(my_time_t)us.last_changed;
04992                                         botnet_send_command(*i1,c);
04993 
04994                                         string d="replication: sent PULL request for object ";
04995                                         if(c->command_data.check_time_1.user)
04996                                             d+="(user) ";
04997                                         if(c->command_data.check_time_1.procedure)
04998                                             d+="(procedure) ";
04999                                         if(c->command_data.check_time_1.channel_def)
05000                                             d+="(channel) ";
05001                                         if(c->command_data.check_time_1.prv)
05002                                             d+="(private)"; // no trailing SPACE!!!
05003                                         d+=us.name;
05004                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
05005                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05006 
05007                                         {
05008                                                 string obj_type="?";
05009                                                 if(c->command_data.check_time_1.user)
05010                                                     obj_type="user";
05011                                                 if(c->command_data.check_time_1.procedure)
05012                                                     obj_type="procedure";
05013                                                 if(c->command_data.check_time_1.channel_def)
05014                                                     obj_type="channel";
05015                                                 if(c->command_data.check_time_1.prv)
05016                                                     obj_type="private";
05017 
05018                                                 string reason="OK";
05019 
05020                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
05021                                         }
05022 
05023                                         delete c;
05024                                     }
05025                                     if((signed)obj_diff<=60) {
05026                                         s_bot_command* c=new s_bot_command;
05027                                         c->hard_clear();
05028                                         c->packet_type=PACKET_TYPE_COMMAND;
05029                                         c->size=sizeof(c);
05030                                         c->version=1;
05031                                         c->command=CMD_NO_REPL_1;
05032                                         c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05033                                         c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05034                                         c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05035                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05036                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_UP_TO_DATE;
05037                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05038                                         botnet_send_command(*i1,c);
05039 
05040                                         string d="I have rejected replication of object ";
05041                                         if(c->command_data.no_repl_1.user)
05042                                             d+="(user) ";
05043                                         if(c->command_data.no_repl_1.procedure)
05044                                             d+="(procedure) ";
05045                                         if(c->command_data.no_repl_1.channel_def)
05046                                             d+="(channel) ";
05047                                         if(c->command_data.no_repl_1.prv)
05048                                             d+="(private)"; // no trailing SPACE!!!
05049                                         d+=obj;
05050                                         d+=", reason: ";
05051                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05052                                             d+="up to date";
05053                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05054                                             d+="access denied";
05055                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05056                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05057 
05058                                         {
05059                                                 string obj_type="?";
05060                                                 if(c->command_data.no_repl_1.user)
05061                                                     obj_type="user";
05062                                                 if(c->command_data.no_repl_1.procedure)
05063                                                     obj_type="procedure";
05064                                                 if(c->command_data.no_repl_1.channel_def)
05065                                                     obj_type="channel";
05066                                                 if(c->command_data.no_repl_1.prv)
05067                                                     obj_type="private";
05068 
05069                                                 string reason="?";
05070                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05071                                                     reason="up to date";
05072                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05073                                                     reason="access denied";
05074 
05075                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05076                                         }
05077 
05078                                         delete c;
05079                                     }
05080                                 }
05081                                 if(cmd->command_data.cmd_push_1.procedure) {
05082                                     s_procedure p;
05083                                     bool got2=false;
05084                                     if(logic_botnet_get_proc(obj,p))
05085                                         got2=true;
05086                                     bool got=false;
05087                                     if(got2) {
05088                                         vector<s_replication>::iterator i2;
05089                                         for(i2=p.replication.begin(); i2!=p.replication.end(); i2++)
05090                                             if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
05091                                                 got=true;
05092                                                 break;
05093                                             }
05094                                     }
05095                                     if(got2 && !got) {
05096                                         s_bot_command* c=new s_bot_command;
05097                                         c->hard_clear();
05098                                         c->packet_type=PACKET_TYPE_COMMAND;
05099                                         c->size=sizeof(c);
05100                                         c->version=1;
05101                                         c->command=CMD_NO_REPL_1;
05102                                         c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05103                                         c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05104                                         c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05105                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05106                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
05107                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05108                                         botnet_send_command(*i1,c);
05109 
05110                                         string d="I have rejected replication of object ";
05111                                         if(c->command_data.no_repl_1.user)
05112                                             d+="(user) ";
05113                                         if(c->command_data.no_repl_1.procedure)
05114                                             d+="(procedure) ";
05115                                         if(c->command_data.no_repl_1.channel_def)
05116                                             d+="(channel) ";
05117                                         if(c->command_data.no_repl_1.prv)
05118                                             d+="(private)"; // no trailing SPACE!!!
05119                                         d+=obj;
05120                                         d+=", reason: ";
05121                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05122                                             d+="up to date";
05123                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05124                                             d+="access denied";
05125                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05126                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05127 
05128                                         {
05129                                                 string obj_type="?";
05130                                                 if(c->command_data.no_repl_1.user)
05131                                                     obj_type="user";
05132                                                 if(c->command_data.no_repl_1.procedure)
05133                                                     obj_type="procedure";
05134                                                 if(c->command_data.no_repl_1.channel_def)
05135                                                     obj_type="channel";
05136                                                 if(c->command_data.no_repl_1.prv)
05137                                                     obj_type="private";
05138 
05139                                                 string reason="?";
05140                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05141                                                     reason="up to date";
05142                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05143                                                     reason="access denied";
05144 
05145                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05146                                         }
05147 
05148                                         delete c;
05149 
05150                                         break;
05151                                     }
05152                                     time_t now;
05153                                     time(&now);
05154                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
05155                                     time_t obj_diff=p.last_changed-(cmd->command_data.cmd_push_1.original_time-diff);
05156                                     if(!got2) {
05157                                         s_user bot;
05158                                         logic_botnet_get_user((*i1)->botname,bot);
05159                                         if(bot.access_to_plusproc) {
05160                                             s_bot_command* c=new s_bot_command;
05161                                             c->hard_clear();
05162                                             c->packet_type=PACKET_TYPE_COMMAND;
05163                                             c->size=sizeof(c);
05164                                             c->version=1;
05165                                             c->command=CMD_CHECK_TIME_1;
05166                                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
05167                                             c->command_data.check_time_1.user=false;
05168                                             c->command_data.check_time_1.procedure=true;
05169                                             c->command_data.check_time_1.channel_def=false;
05170                                             c->command_data.check_time_1.prv=false;
05171                                             char* proc=c->command_data.cmd_push_1.object_name;
05172                                             memset(proc,0,sizeof(c->command_data.cmd_push_1.object_name));
05173                                             strncpy(proc,obj.c_str(),sizeof(c->command_data.check_time_1.object_name));
05174                                             c->command_data.check_time_1.original_time=0;
05175                                             botnet_send_command(*i1,c);
05176 
05177                                             string d="replication: sent PULL request for object ";
05178                                             if(c->command_data.check_time_1.user)
05179                                                 d+="(user) ";
05180                                             if(c->command_data.check_time_1.procedure)
05181                                                 d+="(procedure) ";
05182                                             if(c->command_data.check_time_1.channel_def)
05183                                                 d+="(channel) ";
05184                                             if(c->command_data.check_time_1.prv)
05185                                                 d+="(private)"; // no trailing SPACE!!!
05186                                             d+=obj;
05187                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
05188                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05189 
05190                                             {
05191                                                 string obj_type="?";
05192                                                 if(c->command_data.check_time_1.user)
05193                                                     obj_type="user";
05194                                                 if(c->command_data.check_time_1.procedure)
05195                                                     obj_type="procedure";
05196                                                 if(c->command_data.check_time_1.channel_def)
05197                                                     obj_type="channel";
05198                                                 if(c->command_data.check_time_1.prv)
05199                                                     obj_type="private";
05200 
05201                                                 string reason="OK";
05202 
05203                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
05204                                             }
05205 
05206                                             delete c;
05207                                         } else {
05208                                             s_bot_command* c=new s_bot_command;
05209                                             c->hard_clear();
05210                                             c->packet_type=PACKET_TYPE_COMMAND;
05211                                             c->size=sizeof(c);
05212                                             c->version=1;
05213                                             c->command=CMD_NO_REPL_1;
05214                                             c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05215                                             c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05216                                             c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05217                                             c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05218                                             c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
05219                                             memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05220                                             botnet_send_command(*i1,c);
05221 
05222                                             string d="I have rejected replication of object ";
05223                                             if(c->command_data.no_repl_1.user)
05224                                                 d+="(user) ";
05225                                             if(c->command_data.no_repl_1.procedure)
05226                                                 d+="(procedure) ";
05227                                             if(c->command_data.no_repl_1.channel_def)
05228                                                 d+="(channel) ";
05229                                             if(c->command_data.no_repl_1.prv)
05230                                                 d+="(private)"; // no trailing SPACE!!!
05231                                             d+=obj;
05232                                             d+=", reason: ";
05233                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05234                                                 d+="up to date";
05235                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05236                                                 d+="access denied";
05237                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05238                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05239 
05240                                             {
05241                                                 string obj_type="?";
05242                                                 if(c->command_data.no_repl_1.user)
05243                                                     obj_type="user";
05244                                                 if(c->command_data.no_repl_1.procedure)
05245                                                     obj_type="procedure";
05246                                                 if(c->command_data.no_repl_1.channel_def)
05247                                                     obj_type="channel";
05248                                                 if(c->command_data.no_repl_1.prv)
05249                                                     obj_type="private";
05250 
05251                                                 string reason="?";
05252                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05253                                                     reason="up to date";
05254                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05255                                                     reason="access denied";
05256 
05257                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05258                                             }
05259 
05260                                             delete c;
05261 
05262                                             break;
05263                                         }
05264                                     } else
05265                                     if((signed)obj_diff>60) {
05266                                         s_bot_command* c=new s_bot_command;
05267                                         c->hard_clear();
05268                                         c->packet_type=PACKET_TYPE_COMMAND;
05269                                         c->size=sizeof(c);
05270                                         c->version=1;
05271                                         c->command=CMD_CHECK_TIME_1;
05272                                         c->command_data.check_time_1.now=(my_time_t)time(NULL);
05273                                         c->command_data.check_time_1.user=false;
05274                                         c->command_data.check_time_1.procedure=true;
05275                                         c->command_data.check_time_1.channel_def=false;
05276                                         c->command_data.check_time_1.prv=false;
05277                                         char* proc=c->command_data.cmd_push_1.object_name;
05278                                         memset(proc,0,sizeof(c->command_data.cmd_push_1.object_name));
05279                                         strncpy(proc,p.name.c_str(),sizeof(c->command_data.check_time_1.object_name));
05280                                         c->command_data.check_time_1.original_time=(my_time_t)p.last_changed;
05281                                         botnet_send_command(*i1,c);
05282 
05283                                         string d="replication: sent PULL request for object ";
05284                                         if(c->command_data.check_time_1.user)
05285                                             d+="(user) ";
05286                                         if(c->command_data.check_time_1.procedure)
05287                                             d+="(procedure) ";
05288                                         if(c->command_data.check_time_1.channel_def)
05289                                             d+="(channel) ";
05290                                         if(c->command_data.check_time_1.prv)
05291                                             d+="(private)"; // no trailing SPACE!!!
05292                                         d+=p.name;
05293                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
05294                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05295 
05296                                         {
05297                                                 string obj_type="?";
05298                                                 if(c->command_data.check_time_1.user)
05299                                                     obj_type="user";
05300                                                 if(c->command_data.check_time_1.procedure)
05301                                                     obj_type="procedure";
05302                                                 if(c->command_data.check_time_1.channel_def)
05303                                                     obj_type="channel";
05304                                                 if(c->command_data.check_time_1.prv)
05305                                                     obj_type="private";
05306 
05307                                                 string reason="OK";
05308 
05309                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
05310                                         }
05311 
05312                                         delete c;
05313                                     }
05314                                     if((signed)obj_diff<=60) {
05315                                         s_bot_command* c=new s_bot_command;
05316                                         c->hard_clear();
05317                                         c->packet_type=PACKET_TYPE_COMMAND;
05318                                         c->size=sizeof(c);
05319                                         c->version=1;
05320                                         c->command=CMD_NO_REPL_1;
05321                                         c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05322                                         c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05323                                         c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05324                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05325                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_UP_TO_DATE;
05326                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05327                                         botnet_send_command(*i1,c);
05328 
05329                                         string d="I have rejected replication of object ";
05330                                         if(c->command_data.no_repl_1.user)
05331                                             d+="(user) ";
05332                                         if(c->command_data.no_repl_1.procedure)
05333                                             d+="(procedure) ";
05334                                         if(c->command_data.no_repl_1.channel_def)
05335                                             d+="(channel) ";
05336                                         if(c->command_data.no_repl_1.prv)
05337                                             d+="(private)"; // no trailing SPACE!!!
05338                                         d+=obj;
05339                                         d+=", reason: ";
05340                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05341                                             d+="up to date";
05342                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05343                                             d+="access denied";
05344                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05345                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05346 
05347                                         {
05348                                                 string obj_type="?";
05349                                                 if(c->command_data.no_repl_1.user)
05350                                                     obj_type="user";
05351                                                 if(c->command_data.no_repl_1.procedure)
05352                                                     obj_type="procedure";
05353                                                 if(c->command_data.no_repl_1.channel_def)
05354                                                     obj_type="channel";
05355                                                 if(c->command_data.no_repl_1.prv)
05356                                                     obj_type="private";
05357 
05358                                                 string reason="?";
05359                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05360                                                     reason="up to date";
05361                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05362                                                     reason="access denied";
05363 
05364                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05365                                         }
05366 
05367                                         delete c;
05368                                     }
05369                                 }
05370                                 if(cmd->command_data.cmd_push_1.channel_def) {
05371                                     s_channel_def chd;
05372                                     bool got2=false;
05373                                     if(logic_botnet_get_channel_def(obj,chd))
05374                                         got2=true;
05375                                     bool got=false;
05376                                     if(got2) {
05377                                         vector<s_replication>::iterator i2;
05378                                         for(i2=chd.replication.begin(); i2!=chd.replication.end(); i2++)
05379                                             if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
05380                                                 got=true;
05381                                                 break;
05382                                             }
05383                                     }
05384                                     if(got2 && !got) {
05385                                         s_bot_command* c=new s_bot_command;
05386                                         c->hard_clear();
05387                                         c->packet_type=PACKET_TYPE_COMMAND;
05388                                         c->size=sizeof(c);
05389                                         c->version=1;
05390                                         c->command=CMD_NO_REPL_1;
05391                                         c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05392                                         c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05393                                         c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05394                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05395                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
05396                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05397                                         botnet_send_command(*i1,c);
05398 
05399                                         string d="I have rejected replication of object ";
05400                                         if(c->command_data.no_repl_1.user)
05401                                             d+="(user) ";
05402                                         if(c->command_data.no_repl_1.procedure)
05403                                             d+="(procedure) ";
05404                                         if(c->command_data.no_repl_1.channel_def)
05405                                             d+="(channel) ";
05406                                         if(c->command_data.no_repl_1.prv)
05407                                             d+="(private)"; // no trailing SPACE!!!
05408                                         d+=obj;
05409                                         d+=", reason: ";
05410                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05411                                             d+="up to date";
05412                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05413                                             d+="access denied";
05414                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05415                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05416 
05417                                         {
05418                                                 string obj_type="?";
05419                                                 if(c->command_data.no_repl_1.user)
05420                                                     obj_type="user";
05421                                                 if(c->command_data.no_repl_1.procedure)
05422                                                     obj_type="procedure";
05423                                                 if(c->command_data.no_repl_1.channel_def)
05424                                                     obj_type="channel";
05425                                                 if(c->command_data.no_repl_1.prv)
05426                                                     obj_type="private";
05427 
05428                                                 string reason="?";
05429                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05430                                                     reason="up to date";
05431                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05432                                                     reason="access denied";
05433 
05434                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05435                                         }
05436 
05437                                         delete c;
05438 
05439                                         break;
05440                                     }
05441                                     time_t now;
05442                                     time(&now);
05443                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
05444                                     time_t obj_diff=chd.last_changed-(cmd->command_data.cmd_push_1.original_time-diff);
05445                                     if(!got2) {
05446                                         s_user bot;
05447                                         logic_botnet_get_user((*i1)->botname,bot);
05448                                         vector<string>::iterator i2;
05449                                         bool access=false;
05450                                         map<string,string> vars;
05451                                         for(i2=bot.access_to_channel.begin(); i2!=bot.access_to_channel.end(); i2++)
05452                                             if(!(logic_eval(*i2,vars)).compare(obj) || !(*i2).compare("*")) {
05453                                                 access=true;
05454                                                 break;
05455                                             }
05456                                         if(access) {
05457                                             s_bot_command* c=new s_bot_command;
05458                                             c->hard_clear();
05459                                             c->packet_type=PACKET_TYPE_COMMAND;
05460                                             c->size=sizeof(c);
05461                                             c->version=1;
05462                                             c->command=CMD_CHECK_TIME_1;
05463                                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
05464                                             c->command_data.check_time_1.user=false;
05465                                             c->command_data.check_time_1.procedure=false;
05466                                             c->command_data.check_time_1.channel_def=true;
05467                                             c->command_data.check_time_1.prv=false;
05468                                             char* user=c->command_data.cmd_push_1.object_name;
05469                                             memset(user,0,sizeof(c->command_data.cmd_push_1.object_name));
05470                                             strncpy(user,obj.c_str(),sizeof(c->command_data.check_time_1.object_name));
05471                                             c->command_data.check_time_1.original_time=0;
05472                                             botnet_send_command(*i1,c);
05473 
05474                                             string d="replication: sent PULL request for object ";
05475                                             if(c->command_data.check_time_1.user)
05476                                                 d+="(user) ";
05477                                             if(c->command_data.check_time_1.procedure)
05478                                                 d+="(procedure) ";
05479                                             if(c->command_data.check_time_1.channel_def)
05480                                                 d+="(channel) ";
05481                                             if(c->command_data.check_time_1.prv)
05482                                                 d+="(private)"; // no trailing SPACE!!!
05483                                             d+=obj;
05484                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
05485                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05486 
05487                                             {
05488                                                 string obj_type="?";
05489                                                 if(c->command_data.check_time_1.user)
05490                                                     obj_type="user";
05491                                                 if(c->command_data.check_time_1.procedure)
05492                                                     obj_type="procedure";
05493                                                 if(c->command_data.check_time_1.channel_def)
05494                                                     obj_type="channel";
05495                                                 if(c->command_data.check_time_1.prv)
05496                                                     obj_type="private";
05497 
05498                                                 string reason="OK";
05499 
05500                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
05501                                             }
05502 
05503                                             delete c;
05504                                         } else {
05505                                             s_bot_command* c=new s_bot_command;
05506                                             c->hard_clear();
05507                                             c->packet_type=PACKET_TYPE_COMMAND;
05508                                             c->size=sizeof(c);
05509                                             c->version=1;
05510                                             c->command=CMD_NO_REPL_1;
05511                                             c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05512                                             c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05513                                             c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05514                                             c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05515                                             c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
05516                                             memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05517                                             botnet_send_command(*i1,c);
05518 
05519                                             string d="I have rejected replication of object ";
05520                                             if(c->command_data.no_repl_1.user)
05521                                                 d+="(user) ";
05522                                             if(c->command_data.no_repl_1.procedure)
05523                                                 d+="(procedure) ";
05524                                             if(c->command_data.no_repl_1.channel_def)
05525                                                 d+="(channel) ";
05526                                             if(c->command_data.no_repl_1.prv)
05527                                                 d+="(private)"; // no trailing SPACE!!!
05528                                             d+=obj;
05529                                             d+=", reason: ";
05530                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05531                                                 d+="up to date";
05532                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05533                                                 d+="access denied";
05534                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05535                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05536 
05537                                             {
05538                                                 string obj_type="?";
05539                                                 if(c->command_data.no_repl_1.user)
05540                                                     obj_type="user";
05541                                                 if(c->command_data.no_repl_1.procedure)
05542                                                     obj_type="procedure";
05543                                                 if(c->command_data.no_repl_1.channel_def)
05544                                                     obj_type="channel";
05545                                                 if(c->command_data.no_repl_1.prv)
05546                                                     obj_type="private";
05547 
05548                                                 string reason="?";
05549                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05550                                                     reason="up to date";
05551                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05552                                                     reason="access denied";
05553 
05554                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05555                                             }
05556 
05557                                             delete c;
05558 
05559                                             break;
05560                                         }
05561                                     } else
05562                                     if((signed)obj_diff>60) {
05563                                         s_bot_command* c=new s_bot_command;
05564                                         c->hard_clear();
05565                                         c->packet_type=PACKET_TYPE_COMMAND;
05566                                         c->size=sizeof(c);
05567                                         c->version=1;
05568                                         c->command=CMD_CHECK_TIME_1;
05569                                         c->command_data.check_time_1.now=(my_time_t)time(NULL);
05570                                         c->command_data.check_time_1.user=false;
05571                                         c->command_data.check_time_1.procedure=false;
05572                                         c->command_data.check_time_1.channel_def=true;
05573                                         c->command_data.check_time_1.prv=false;
05574                                         char* chan=c->command_data.cmd_push_1.object_name;
05575                                         memset(chan,0,sizeof(c->command_data.cmd_push_1.object_name));
05576                                         strncpy(chan,chd.channel_name.c_str(),sizeof(c->command_data.check_time_1.object_name));
05577                                         c->command_data.check_time_1.original_time=(my_time_t)chd.last_changed;
05578                                         botnet_send_command(*i1,c);
05579 
05580                                         string d="replication: sent PULL request for object ";
05581                                         if(c->command_data.check_time_1.user)
05582                                             d+="(user) ";
05583                                         if(c->command_data.check_time_1.procedure)
05584                                             d+="(procedure) ";
05585                                         if(c->command_data.check_time_1.channel_def)
05586                                             d+="(channel) ";
05587                                         if(c->command_data.check_time_1.prv)
05588                                             d+="(private)"; // no trailing SPACE!!!
05589                                         d+=chd.channel_name;
05590                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
05591                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05592 
05593                                         {
05594                                                 string obj_type="?";
05595                                                 if(c->command_data.check_time_1.user)
05596                                                     obj_type="user";
05597                                                 if(c->command_data.check_time_1.procedure)
05598                                                     obj_type="procedure";
05599                                                 if(c->command_data.check_time_1.channel_def)
05600                                                     obj_type="channel";
05601                                                 if(c->command_data.check_time_1.prv)
05602                                                     obj_type="private";
05603 
05604                                                 string reason="OK";
05605 
05606                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
05607                                         }
05608 
05609                                         delete c;
05610                                     }
05611                                     if((signed)obj_diff<=60) {
05612                                         s_bot_command* c=new s_bot_command;
05613                                         c->hard_clear();
05614                                         c->packet_type=PACKET_TYPE_COMMAND;
05615                                         c->size=sizeof(c);
05616                                         c->version=1;
05617                                         c->command=CMD_NO_REPL_1;
05618                                         c->command_data.no_repl_1.user=cmd->command_data.cmd_push_1.user;
05619                                         c->command_data.no_repl_1.procedure=cmd->command_data.cmd_push_1.procedure;
05620                                         c->command_data.no_repl_1.channel_def=cmd->command_data.cmd_push_1.channel_def;
05621                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05622                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_UP_TO_DATE;
05623                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05624                                         botnet_send_command(*i1,c);
05625 
05626                                         string d="I have rejected replication of object ";
05627                                         if(c->command_data.no_repl_1.user)
05628                                             d+="(user) ";
05629                                         if(c->command_data.no_repl_1.procedure)
05630                                             d+="(procedure) ";
05631                                         if(c->command_data.no_repl_1.channel_def)
05632                                             d+="(channel) ";
05633                                         if(c->command_data.no_repl_1.prv)
05634                                             d+="(private)"; // no trailing SPACE!!!
05635                                         d+=obj;
05636                                         d+=", reason: ";
05637                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05638                                             d+="up to date";
05639                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05640                                             d+="access denied";
05641                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05642                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05643 
05644                                         {
05645                                                 string obj_type="?";
05646                                                 if(c->command_data.no_repl_1.user)
05647                                                     obj_type="user";
05648                                                 if(c->command_data.no_repl_1.procedure)
05649                                                     obj_type="procedure";
05650                                                 if(c->command_data.no_repl_1.channel_def)
05651                                                     obj_type="channel";
05652                                                 if(c->command_data.no_repl_1.prv)
05653                                                     obj_type="private";
05654 
05655                                                 string reason="?";
05656                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05657                                                     reason="up to date";
05658                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05659                                                     reason="access denied";
05660 
05661                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05662                                         }
05663 
05664                                         delete c;
05665                                     }
05666                                 }
05667                                 if(cmd->command_data.cmd_push_1.prv) {
05668                                     bool got=false;
05669                                     vector<s_replication>::iterator i2;
05670                                     for(i2=r_private.replication.begin(); i2!=r_private.replication.end(); i2++)
05671                                         if(!(*i2).partner.compare(remote) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
05672                                             got=true;
05673                                             break;
05674                                         }
05675                                     if(!got) {
05676                                         s_bot_command* c=new s_bot_command;
05677                                         c->hard_clear();
05678                                         c->packet_type=PACKET_TYPE_COMMAND;
05679                                         c->size=sizeof(c);
05680                                         c->version=1;
05681                                         c->command=CMD_NO_REPL_1;
05682                                         c->command_data.no_repl_1.user=cmd->command_data.check_time_1.user;
05683                                         c->command_data.no_repl_1.procedure=cmd->command_data.check_time_1.procedure;
05684                                         c->command_data.no_repl_1.channel_def=cmd->command_data.check_time_1.channel_def;
05685                                         c->command_data.no_repl_1.prv=cmd->command_data.check_time_1.prv;
05686                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
05687                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.check_time_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05688                                         botnet_send_command(*i1,c);
05689 
05690                                         string d="I have rejected replication of object ";
05691                                         if(c->command_data.no_repl_1.user)
05692                                             d+="(user) ";
05693                                         if(c->command_data.no_repl_1.procedure)
05694                                             d+="(procedure) ";
05695                                         if(c->command_data.no_repl_1.channel_def)
05696                                             d+="(channel) ";
05697                                         if(c->command_data.no_repl_1.prv)
05698                                             d+="(private)"; // no trailing SPACE!!!
05699                                         d+=", reason: ";
05700                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05701                                             d+="up to date";
05702                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05703                                             d+="access denied";
05704                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05705                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05706 
05707                                         {
05708                                                 string obj_type="?";
05709                                                 if(c->command_data.no_repl_1.user)
05710                                                     obj_type="user";
05711                                                 if(c->command_data.no_repl_1.procedure)
05712                                                     obj_type="procedure";
05713                                                 if(c->command_data.no_repl_1.channel_def)
05714                                                     obj_type="channel";
05715                                                 if(c->command_data.no_repl_1.prv)
05716                                                     obj_type="private";
05717 
05718                                                 string reason="?";
05719                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05720                                                     reason="up to date";
05721                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05722                                                     reason="access denied";
05723 
05724                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05725                                         }
05726 
05727                                         delete c;
05728 
05729                                         break;
05730                                     }
05731                                     time_t now;
05732                                     time(&now);
05733                                     time_t diff=cmd->command_data.check_time_1.now-now; // -x == remote is older
05734                                     time_t obj_diff=r_private.last_changed-(cmd->command_data.cmd_push_1.original_time-diff);
05735                                     
05736                                     s_user bot;
05737                                     logic_botnet_get_user((*i1)->botname,bot);
05738                                     
05739                                     if(cmd->command_data.cmd_push_1.prv && bot.access_to_private) {
05740                                         if((signed)obj_diff>60) {
05741                                             s_bot_command* c=new s_bot_command;
05742                                             c->hard_clear();
05743                                             c->packet_type=PACKET_TYPE_COMMAND;
05744                                             c->size=sizeof(c);
05745                                             c->version=1;
05746                                             c->command=CMD_CHECK_TIME_1;
05747                                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
05748                                             c->command_data.check_time_1.user=false;
05749                                             c->command_data.check_time_1.procedure=false;
05750                                             c->command_data.check_time_1.channel_def=false;
05751                                             c->command_data.check_time_1.prv=true;
05752                                             c->command_data.check_time_1.original_time=(my_time_t)r_private.last_changed;
05753                                             botnet_send_command(*i1,c);
05754     
05755                                             string d="replication: sent PULL request for object ";
05756                                             d+="(private)"; // no trailing SPACE!!!
05757                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,d.c_str());
05758                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05759 
05760                                             (*i1)->prv_pulling=true;
05761 
05762                                             {
05763                                                 string obj_type="?";
05764                                                 if(c->command_data.check_time_1.user)
05765                                                     obj_type="user";
05766                                                 if(c->command_data.check_time_1.procedure)
05767                                                     obj_type="procedure";
05768                                                 if(c->command_data.check_time_1.channel_def)
05769                                                     obj_type="channel";
05770                                                 if(c->command_data.check_time_1.prv)
05771                                                     obj_type="private";
05772 
05773                                                 string reason="OK";
05774 
05775                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL_REQUEST");
05776                                             }
05777     
05778                                             delete c;
05779                                         }
05780                                         if((signed)obj_diff<=60) {
05781                                             s_bot_command* c=new s_bot_command;
05782                                             c->hard_clear();
05783                                             c->packet_type=PACKET_TYPE_COMMAND;
05784                                             c->size=sizeof(c);
05785                                             c->version=1;
05786                                             c->command=CMD_NO_REPL_1;
05787                                             c->command_data.check_time_1.user=false;
05788                                             c->command_data.no_repl_1.procedure=false;
05789                                             c->command_data.no_repl_1.channel_def=false;
05790                                             c->command_data.no_repl_1.prv=true;
05791                                             c->command_data.no_repl_1.reason=REASON_NO_REPL_1_UP_TO_DATE;
05792                                             memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05793                                             botnet_send_command(*i1,c);
05794 
05795                                             string d="I have rejected replication of object ";
05796                                             if(c->command_data.no_repl_1.user)
05797                                                 d+="(user) ";
05798                                             if(c->command_data.no_repl_1.procedure)
05799                                                 d+="(procedure) ";
05800                                             if(c->command_data.no_repl_1.channel_def)
05801                                                 d+="(channel) ";
05802                                             if(c->command_data.no_repl_1.prv)
05803                                                 d+="(private)"; // no trailing SPACE!!!
05804                                             d+=", reason: ";
05805                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05806                                                 d+="up to date";
05807                                             if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05808                                                 d+="access denied";
05809                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05810                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05811 
05812                                             {
05813                                                 string obj_type="?";
05814                                                 if(c->command_data.no_repl_1.user)
05815                                                     obj_type="user";
05816                                                 if(c->command_data.no_repl_1.procedure)
05817                                                     obj_type="procedure";
05818                                                 if(c->command_data.no_repl_1.channel_def)
05819                                                     obj_type="channel";
05820                                                 if(c->command_data.no_repl_1.prv)
05821                                                     obj_type="private";
05822 
05823                                                 string reason="?";
05824                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05825                                                     reason="up to date";
05826                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05827                                                     reason="access denied";
05828 
05829                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05830                                             }
05831 
05832                                             delete c;
05833                                         }
05834                                     } else {
05835                                         s_bot_command* c=new s_bot_command;
05836                                         c->hard_clear();
05837                                         c->packet_type=PACKET_TYPE_COMMAND;
05838                                         c->size=sizeof(c);
05839                                         c->version=1;
05840                                         c->command=CMD_NO_REPL_1;
05841                                         c->command_data.check_time_1.user=false;
05842                                         c->command_data.no_repl_1.procedure=false;
05843                                         c->command_data.no_repl_1.channel_def=false;
05844                                         c->command_data.no_repl_1.prv=true;
05845                                         c->command_data.no_repl_1.reason=REASON_NO_REPL_1_ACCESS_DENIED;
05846                                         memcpy(c->command_data.no_repl_1.object_name,cmd->command_data.cmd_push_1.object_name,sizeof(c->command_data.no_repl_1.object_name));
05847                                         botnet_send_command(*i1,c);
05848 
05849                                         string d="I have rejected replication of object ";
05850                                         if(c->command_data.no_repl_1.user)
05851                                             d+="(user) ";
05852                                         if(c->command_data.no_repl_1.procedure)
05853                                             d+="(procedure) ";
05854                                         if(c->command_data.no_repl_1.channel_def)
05855                                             d+="(channel) ";
05856                                         if(c->command_data.no_repl_1.prv)
05857                                             d+="(private)"; // no trailing SPACE!!!
05858                                         d+=", reason: ";
05859                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05860                                             d+="up to date";
05861                                         if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05862                                             d+="access denied";
05863                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,d.c_str());
05864                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
05865 
05866                                         {
05867                                                 string obj_type="?";
05868                                                 if(c->command_data.no_repl_1.user)
05869                                                     obj_type="user";
05870                                                 if(c->command_data.no_repl_1.procedure)
05871                                                     obj_type="procedure";
05872                                                 if(c->command_data.no_repl_1.channel_def)
05873                                                     obj_type="channel";
05874                                                 if(c->command_data.no_repl_1.prv)
05875                                                     obj_type="private";
05876 
05877                                                 string reason="?";
05878                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_UP_TO_DATE)
05879                                                     reason="up to date";
05880                                                 if(c->command_data.no_repl_1.reason==REASON_NO_REPL_1_ACCESS_DENIED)
05881                                                     reason="access denied";
05882 
05883                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
05884                                         }
05885 
05886                                         delete c;
05887 
05888                                         break;
05889                                     }
05890                                 }
05891                             }
05892                             break;
05893                         case CMD_REPL_USER_01_1:
05894                             {
05895                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_01_1.name);
05896                                 char* n=new char[n_size+1];
05897                                 memset(n,0,n_size+1);
05898                                 memcpy(n,cmd->command_data.cmd_repl_user_01_1.name,n_size);
05899                                 string name=n;
05900                                 delete[] n;
05901                                 n=NULL;
05902 
05903                                 {
05904                                 again_erase:
05905                                     vector<s_user_to_pull>::iterator i2;
05906                                     for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
05907                                         if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
05908                                             (*i1)->pulling_users.erase(i2);
05909                                             goto again_erase;
05910                                         }
05911                                     }
05912 
05913                                     bool got=false;
05914                                     vector<s_user>::iterator i3;
05915                                     for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
05916                                         if(!(*i3).name.compare(name)) {
05917                                             got=true;
05918                                             vector<s_replication>::iterator i4;
05919                                             for(i4=(*i3).replication.begin(); i4!=(*i3).replication.end(); i4++) {
05920                                                 if(!(*i4).partner.compare((*i1)->botname) && ((*i4).type==REPL_PULL || (*i4).type==REPL_PUSHPULL)) {
05921                                                     s_user_to_pull u;
05922                                                     u.botname=(*i1)->botname;
05923                                                     u.user=*i3;
05924                                                     (*i1)->pulling_users.push_back(u);
05925                                                     got=true;
05926                                                     break;
05927                                                 }
05928                                             }
05929                                             if(got)
05930                                                 break;
05931                                         }
05932                                     }
05933                                     if(!got) {
05934                                         s_user_to_pull u;
05935                                         u.botname=(*i1)->botname;
05936                                         u.user.name=name;
05937                                         u.user.replication_partner=false;
05938                                         u.user.meta.clear();
05939 
05940                                         // we got a new user, so set them replication flags
05941                                         s_replication r;
05942                                         r.partner=(*i1)->botname;
05943                                         r.type=REPL_PULL;
05944                                         u.user.replication.push_back(r);
05945 
05946                                         (*i1)->pulling_users.push_back(u);
05947                                     }
05948                                 }
05949 
05950                                 s_user_to_pull* u=NULL;
05951                                 bool got=false;
05952                                 vector<s_user_to_pull>::iterator i2;
05953                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
05954                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
05955                                         u=&(*i2);
05956                                         got=true;
05957                                         break;
05958                                     }
05959                                 }
05960                                 if(got) {
05961                                     u->user.host_unknown=cmd->command_data.cmd_repl_user_01_1.host_unknown;
05962                                     u->user.host_bot=cmd->command_data.cmd_repl_user_01_1.host_bot;
05963                                     u->user.is_template=cmd->command_data.cmd_repl_user_01_1.is_template;
05964                                     u->user.terminator=cmd->command_data.cmd_repl_user_01_1.terminator;
05965                                     u->user.access_grant_partyline=cmd->command_data.cmd_repl_user_01_1.access_grant_partyline;
05966                                     u->user.access_to_backup=cmd->command_data.cmd_repl_user_01_1.access_to_backup;
05967                                     u->user.access_grant_backup=cmd->command_data.cmd_repl_user_01_1.access_grant_backup;
05968                                     u->user.access_to_rehash=cmd->command_data.cmd_repl_user_01_1.access_to_rehash;
05969                                     u->user.access_grant_rehash=cmd->command_data.cmd_repl_user_01_1.access_grant_rehash;
05970                                     u->user.access_to_partyline=cmd->command_data.cmd_repl_user_01_1.access_to_partyline;
05971                                     u->user.access_grant_partyline=cmd->command_data.cmd_repl_user_01_1.access_grant_partyline;
05972 
05973                                     u->user.access_to_plususer=cmd->command_data.cmd_repl_user_01_1.access_to_plususer;
05974                                     u->user.access_grant_plususer=cmd->command_data.cmd_repl_user_01_1.access_grant_plususer;
05975                                     u->user.access_to_plusproc=cmd->command_data.cmd_repl_user_01_1.access_to_plusproc;
05976                                     u->user.access_grant_plusproc=cmd->command_data.cmd_repl_user_01_1.access_grant_plusproc;
05977 
05978                                     u->user.access_to_can_send_all_users=cmd->command_data.cmd_repl_user_01_1.access_to_can_send_all_users;
05979                                     u->user.access_grant_can_send_all_users=cmd->command_data.cmd_repl_user_01_1.access_grant_can_send_all_users;
05980 
05981                                     u->user.access_to_can_send_unknown_users=cmd->command_data.cmd_repl_user_01_1.access_to_can_send_unknown_users;
05982                                     u->user.access_grant_can_send_unknown_users=cmd->command_data.cmd_repl_user_01_1.access_grant_can_send_unknown_users;
05983 
05984                                     u->user.last_changed=cmd->command_data.cmd_repl_user_01_1.last_changed;
05985 
05986                                     u->user.hostmask.clear();
05987                                     u->user.fullname.clear();
05988                                     u->user.access_to_group.clear();
05989                                     u->user.access_to_proc.clear();
05990                                     u->user.access_grant_procedure.clear();
05991                                     u->user.access_grant_group.clear();
05992                                     u->user.access_to_channel.clear();
05993                                     u->user.access_grant_channel.clear();
05994                                     u->user.groups.clear();
05995                                     u->user.dcc_hosts.clear();
05996 
05997                                     u->user.partyline_msg_flood.lines=cmd->command_data.cmd_repl_user_01_1.partyline_msg_flood.lines;
05998                                     u->user.partyline_msg_flood.seconds=cmd->command_data.cmd_repl_user_01_1.partyline_msg_flood.seconds;
05999                                 }
06000                             }
06001                             break;
06002                         case CMD_REPL_USER_02_1:
06003                             {
06004                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_02_1.name); // !!!
06005                                 char* n=new char[n_size+1];
06006                                 memset(n,0,n_size+1);
06007                                 memcpy(n,cmd->command_data.cmd_repl_user_02_1.name,n_size); // !!!
06008                                 string name=n;
06009                                 delete[] n;
06010                                 n=NULL;
06011 
06012                                 s_user_to_pull* u=NULL;
06013                                 bool got=false;
06014                                 vector<s_user_to_pull>::iterator i2;
06015                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06016                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06017                                         u=&(*i2);
06018                                         got=true;
06019                                         break;
06020                                     }
06021                                 }
06022                                 if(got) {
06023                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_02_1.hostmask); // !!!
06024                                     char* d=new char[d_size+1];
06025                                     memset(d,0,d_size+1);
06026                                     memcpy(d,cmd->command_data.cmd_repl_user_02_1.hostmask,d_size); // !!!
06027                                     string data=d;
06028                                     delete[] d;
06029                                     d=NULL;
06030 
06031                                     u->user.hostmask.push_back(data);
06032                                 }
06033                             }
06034                             break;
06035                         case CMD_REPL_USER_03_1:
06036                             {
06037                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_03_1.name); // !!!
06038                                 char* n=new char[n_size+1];
06039                                 memset(n,0,n_size+1);
06040                                 memcpy(n,cmd->command_data.cmd_repl_user_03_1.name,n_size); // !!!
06041                                 string name=n;
06042                                 delete[] n;
06043                                 n=NULL;
06044 
06045                                 s_user_to_pull* u=NULL;
06046                                 bool got=false;
06047                                 vector<s_user_to_pull>::iterator i2;
06048                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06049                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06050                                         u=&(*i2);
06051                                         got=true;
06052                                         break;
06053                                     }
06054                                 }
06055                                 if(got) {
06056                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_03_1.fullname); // !!!
06057                                     char* d=new char[d_size+1];
06058                                     memset(d,0,d_size+1);
06059                                     memcpy(d,cmd->command_data.cmd_repl_user_03_1.fullname,d_size); // !!!
06060                                     string data=d;
06061                                     delete[] d;
06062                                     d=NULL;
06063 
06064                                     u->user.fullname.push_back(data);
06065                                 }
06066                             }
06067                             break;
06068                         case CMD_REPL_USER_04_1:
06069                             {
06070                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_04_1.name); // !!!
06071                                 char* n=new char[n_size+1];
06072                                 memset(n,0,n_size+1);
06073                                 memcpy(n,cmd->command_data.cmd_repl_user_04_1.name,n_size); // !!!
06074                                 string name=n;
06075                                 delete[] n;
06076                                 n=NULL;
06077 
06078                                 s_user_to_pull* u=NULL;
06079                                 bool got=false;
06080                                 vector<s_user_to_pull>::iterator i2;
06081                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06082                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06083                                         u=&(*i2);
06084                                         got=true;
06085                                         break;
06086                                     }
06087                                 }
06088                                 if(got) {
06089                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_04_1.access_to_group); // !!!
06090                                     char* d=new char[d_size+1];
06091                                     memset(d,0,d_size+1);
06092                                     memcpy(d,cmd->command_data.cmd_repl_user_04_1.access_to_group,d_size); // !!!
06093                                     string data=d;
06094                                     delete[] d;
06095                                     d=NULL;
06096 
06097                                     u->user.access_to_group.push_back(data);
06098                                 }
06099                             }
06100                             break;
06101                         case CMD_REPL_USER_05_1:
06102                             {
06103                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_05_1.name); // !!!
06104                                 char* n=new char[n_size+1];
06105                                 memset(n,0,n_size+1);
06106                                 memcpy(n,cmd->command_data.cmd_repl_user_05_1.name,n_size); // !!!
06107                                 string name=n;
06108                                 delete[] n;
06109                                 n=NULL;
06110 
06111                                 s_user_to_pull* u=NULL;
06112                                 bool got=false;
06113                                 vector<s_user_to_pull>::iterator i2;
06114                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06115                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06116                                         u=&(*i2);
06117                                         got=true;
06118                                         break;
06119                                     }
06120                                 }
06121                                 if(got) {
06122                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_05_1.access_to_proc); // !!!
06123                                     char* d=new char[d_size+1];
06124                                     memset(d,0,d_size+1);
06125                                     memcpy(d,cmd->command_data.cmd_repl_user_05_1.access_to_proc,d_size); // !!!
06126                                     string data=d;
06127                                     delete[] d;
06128                                     d=NULL;
06129 
06130                                     u->user.access_to_proc.push_back(data);
06131                                 }
06132                             }
06133                             break;
06134                         case CMD_REPL_USER_06_1:
06135                             {
06136                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_06_1.name); // !!!
06137                                 char* n=new char[n_size+1];
06138                                 memset(n,0,n_size+1);
06139                                 memcpy(n,cmd->command_data.cmd_repl_user_06_1.name,n_size); // !!!
06140                                 string name=n;
06141                                 delete[] n;
06142                                 n=NULL;
06143 
06144                                 s_user_to_pull* u=NULL;
06145                                 bool got=false;
06146                                 vector<s_user_to_pull>::iterator i2;
06147                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06148                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06149                                         u=&(*i2);
06150                                         got=true;
06151                                         break;
06152                                     }
06153                                 }
06154                                 if(got) {
06155                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_06_1.access_grant_proc); // !!!
06156                                     char* d=new char[d_size+1];
06157                                     memset(d,0,d_size+1);
06158                                     memcpy(d,cmd->command_data.cmd_repl_user_06_1.access_grant_proc,d_size); // !!!
06159                                     string data=d;
06160                                     delete[] d;
06161                                     d=NULL;
06162 
06163                                     u->user.access_grant_procedure.push_back(data);
06164                                 }
06165                             }
06166                             break;
06167                         case CMD_REPL_USER_07_1:
06168                             {
06169                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_07_1.name); // !!!
06170                                 char* n=new char[n_size+1];
06171                                 memset(n,0,n_size+1);
06172                                 memcpy(n,cmd->command_data.cmd_repl_user_07_1.name,n_size); // !!!
06173                                 string name=n;
06174                                 delete[] n;
06175                                 n=NULL;
06176 
06177                                 s_user_to_pull* u=NULL;
06178                                 bool got=false;
06179                                 vector<s_user_to_pull>::iterator i2;
06180                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06181                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06182                                         u=&(*i2);
06183                                         got=true;
06184                                         break;
06185                                     }
06186                                 }
06187                                 if(got) {
06188                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_07_1.access_grant_group); // !!!
06189                                     char* d=new char[d_size+1];
06190                                     memset(d,0,d_size+1);
06191                                     memcpy(d,cmd->command_data.cmd_repl_user_07_1.access_grant_group,d_size); // !!!
06192                                     string data=d;
06193                                     delete[] d;
06194                                     d=NULL;
06195 
06196                                     u->user.access_grant_group.push_back(data);
06197                                 }
06198                             }
06199                             break;
06200                         case CMD_REPL_USER_08_1:
06201                             {
06202                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_08_1.name); // !!!
06203                                 char* n=new char[n_size+1];
06204                                 memset(n,0,n_size+1);
06205                                 memcpy(n,cmd->command_data.cmd_repl_user_08_1.name,n_size); // !!!
06206                                 string name=n;
06207                                 delete[] n;
06208                                 n=NULL;
06209 
06210                                 s_user_to_pull* u=NULL;
06211                                 bool got=false;
06212                                 vector<s_user_to_pull>::iterator i2;
06213                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06214                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06215                                         u=&(*i2);
06216                                         got=true;
06217                                         break;
06218                                     }
06219                                 }
06220                                 if(got) {
06221                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_08_1.access_to_channel); // !!!
06222                                     char* d=new char[d_size+1];
06223                                     memset(d,0,d_size+1);
06224                                     memcpy(d,cmd->command_data.cmd_repl_user_08_1.access_to_channel,d_size); // !!!
06225                                     string data=d;
06226                                     delete[] d;
06227                                     d=NULL;
06228 
06229                                     u->user.access_to_channel.push_back(data);
06230                                 }
06231                             }
06232                             break;
06233                         case CMD_REPL_USER_09_1:
06234                             {
06235                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_09_1.name); // !!!
06236                                 char* n=new char[n_size+1];
06237                                 memset(n,0,n_size+1);
06238                                 memcpy(n,cmd->command_data.cmd_repl_user_09_1.name,n_size); // !!!
06239                                 string name=n;
06240                                 delete[] n;
06241                                 n=NULL;
06242 
06243                                 s_user_to_pull* u=NULL;
06244                                 bool got=false;
06245                                 vector<s_user_to_pull>::iterator i2;
06246                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06247                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06248                                         u=&(*i2);
06249                                         got=true;
06250                                         break;
06251                                     }
06252                                 }
06253                                 if(got) {
06254                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_09_1.access_grant_channel); // !!!
06255                                     char* d=new char[d_size+1];
06256                                     memset(d,0,d_size+1);
06257                                     memcpy(d,cmd->command_data.cmd_repl_user_09_1.access_grant_channel,d_size); // !!!
06258                                     string data=d;
06259                                     delete[] d;
06260                                     d=NULL;
06261 
06262                                     u->user.access_grant_channel.push_back(data);
06263                                 }
06264                             }
06265                             break;
06266                         case CMD_REPL_USER_10_1:
06267                             {
06268                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_10_1.name); // !!!
06269                                 char* n=new char[n_size+1];
06270                                 memset(n,0,n_size+1);
06271                                 memcpy(n,cmd->command_data.cmd_repl_user_10_1.name,n_size); // !!!
06272                                 string name=n;
06273                                 delete[] n;
06274                                 n=NULL;
06275 
06276                                 s_user_to_pull* u=NULL;
06277                                 bool got=false;
06278                                 vector<s_user_to_pull>::iterator i2;
06279                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06280                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06281                                         u=&(*i2);
06282                                         got=true;
06283                                         break;
06284                                     }
06285                                 }
06286                                 if(got) {
06287                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_10_1.group); // !!!
06288                                     char* d=new char[d_size+1];
06289                                     memset(d,0,d_size+1);
06290                                     memcpy(d,cmd->command_data.cmd_repl_user_10_1.group,d_size); // !!!
06291                                     string data=d;
06292                                     delete[] d;
06293                                     d=NULL;
06294 
06295                                     s_group g;
06296                                     g.name=data;
06297 
06298                                     u->user.groups.push_back(g);
06299                                 }
06300                             }
06301                             break;
06302                         case CMD_REPL_USER_11_1:
06303                             {
06304                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_11_1.name); // !!!
06305                                 char* n=new char[n_size+1];
06306                                 memset(n,0,n_size+1);
06307                                 memcpy(n,cmd->command_data.cmd_repl_user_11_1.name,n_size); // !!!
06308                                 string name=n;
06309                                 delete[] n;
06310                                 n=NULL;
06311 
06312                                 s_user_to_pull* u=NULL;
06313                                 bool got=false;
06314                                 vector<s_user_to_pull>::iterator i2;
06315                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06316                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06317                                         u=&(*i2);
06318                                         got=true;
06319                                         break;
06320                                     }
06321                                 }
06322                                 if(got) {
06323                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_11_1.dcc_host); // !!!
06324                                     char* d=new char[d_size+1];
06325                                     memset(d,0,d_size+1);
06326                                     memcpy(d,cmd->command_data.cmd_repl_user_11_1.dcc_host,d_size); // !!!
06327                                     string data=d;
06328                                     delete[] d;
06329                                     d=NULL;
06330 
06331                                     s_dcc_host h;
06332                                     h.host=data;
06333                                     h.group=cmd->command_data.cmd_repl_user_11_1.dcc_group;
06334                                     u->user.dcc_hosts.push_back(h);
06335                                 }
06336                             }
06337                             break;
06338                         case CMD_REPL_USER_12_1:
06339                             {
06340                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_12_1.name); // !!!
06341                                 char* n=new char[n_size+1];
06342                                 memset(n,0,n_size+1);
06343                                 memcpy(n,cmd->command_data.cmd_repl_user_12_1.name,n_size); // !!!
06344                                 string name=n;
06345                                 delete[] n;
06346                                 n=NULL;
06347 
06348                                 s_user_to_pull* u=NULL;
06349                                 bool got=false;
06350                                 vector<s_user_to_pull>::iterator i2;
06351                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06352                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06353                                         u=&(*i2);
06354                                         got=true;
06355                                         break;
06356                                     }
06357                                 }
06358                                 if(got) {
06359                                     {
06360                                         s_user bot;
06361                                         logic_botnet_get_user((*i1)->botname,bot);
06362 
06363                                         map<string,string> vars;
06364                                         bool got=false;
06365                                         vector<string>::iterator i_1;
06366                                         for(i_1=bot.access_to_channel.begin(); i_1!=bot.access_to_channel.end(); i_1++)
06367                                             if(!(*i_1).compare(cmd->command_data.cmd_repl_user_12_1.channel) || !(*i_1).compare("*")) {
06368                                                 got=true;
06369                                                 break;
06370                                             }
06371                                         if(!got) {
06372                                             string d="I have partially rejected replication of object ";
06373                                             d+="(user) ";
06374                                             d+=cmd->command_data.cmd_repl_user_12_1.name;
06375                                             d+=", rejected sub-object=channel: ";
06376                                             d+=cmd->command_data.cmd_repl_user_12_1.channel;
06377                                             d+=", reason: Remote bot doesn't have privilege access_to_channel";
06378                                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,d.c_str());
06379                                             log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
06380 
06381                                             {
06382                                                 string obj_type="user";
06383                                                 string obj=cmd->command_data.cmd_repl_user_12_1.name;
06384                                                 string reason="not have: access_to_channel";
06385 
06386                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_WARNING,d,"LOCAL");
06387                                             }
06388                                             break;
06389                                         }
06390                                     }
06391 
06392                                     s_user bot;
06393                                     logic_botnet_get_user((*i1)->botname,bot);
06394 
06395                                     s_channel ch;
06396                                     ch.username=cmd->command_data.cmd_repl_user_12_1.name;
06397                                     ch.channel_name=cmd->command_data.cmd_repl_user_12_1.channel;
06398                                     ch.host_unknown=u->user.host_unknown;
06399                                     {
06400                                         s_user old_user;
06401                                         vector<s_channel> old_channels;
06402                                         if(!u->user.is_template) {
06403                                             if(!u->user.terminator)
06404                                                 logic_partyline_get_user(u->user.name,old_user,old_channels);
06405                                             else
06406                                                 logic_partyline_get_user(u->user.name,old_user,old_channels);
06407                                         } else {
06408                                             logic_partyline_get_user_template(u->user.name,old_user,old_channels);
06409                                         }
06410                                         s_channel old_channel;
06411                                         old_channel.clear();
06412                                         vector<s_channel>::iterator i2;
06413                                         for(i2=old_channels.begin(); i2!=old_channels.end(); i2++)
06414                                             if(!(*i2).channel_name.compare(ch.channel_name)) {
06415                                                 old_channel=*i2;
06416                                                 break;
06417                                             }
06418 
06419                                         ch.on_deop=old_channel.on_deop;
06420                                         if(botnet_has_grant(bot,old_channel.on_deop) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_deop))
06421                                             ch.on_deop=cmd->command_data.cmd_repl_user_12_1.on_deop;
06422 
06423                                         ch.on_ban=old_channel.on_ban;
06424                                         if(botnet_has_grant(bot,old_channel.on_ban) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_ban))
06425                                             ch.on_ban=cmd->command_data.cmd_repl_user_12_1.on_ban;
06426 
06427                                         ch.on_unban=old_channel.on_unban;
06428                                         if(botnet_has_grant(bot,old_channel.on_unban) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_unban))
06429                                             ch.on_unban=cmd->command_data.cmd_repl_user_12_1.on_unban;
06430 
06431                                         ch.on_kick=old_channel.on_kick;
06432                                         if(botnet_has_grant(bot,old_channel.on_kick) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_kick))
06433                                             ch.on_kick=cmd->command_data.cmd_repl_user_12_1.on_kick;
06434 
06435                                         ch.on_op=old_channel.on_op;
06436                                         if(botnet_has_grant(bot,old_channel.on_op) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_op))
06437                                             ch.on_op=cmd->command_data.cmd_repl_user_12_1.on_op;
06438 
06439                                         ch.on_voice=old_channel.on_voice;
06440                                         if(botnet_has_grant(bot,old_channel.on_voice) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_voice))
06441                                             ch.on_voice=cmd->command_data.cmd_repl_user_12_1.on_voice;
06442 
06443                                         ch.on_devoice=old_channel.on_devoice;
06444                                         if(botnet_has_grant(bot,old_channel.on_devoice) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_devoice))
06445                                             ch.on_devoice=cmd->command_data.cmd_repl_user_12_1.on_devoice;
06446 
06447                                         ch.on_creator=old_channel.on_creator;
06448                                         if(botnet_has_grant(bot,old_channel.on_creator) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_creator))
06449                                             ch.on_creator=cmd->command_data.cmd_repl_user_12_1.on_creator;
06450 
06451                                         ch.on_decreator=old_channel.on_decreator;
06452                                         if(botnet_has_grant(bot,old_channel.on_decreator) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_decreator))
06453                                             ch.on_decreator=cmd->command_data.cmd_repl_user_12_1.on_decreator;
06454 
06455                                         ch.on_join=old_channel.on_join;
06456                                         if(botnet_has_grant(bot,old_channel.on_join) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_join))
06457                                             ch.on_join=cmd->command_data.cmd_repl_user_12_1.on_join;
06458 
06459                                         ch.on_banned=old_channel.on_banned;
06460                                         if(botnet_has_grant(bot,old_channel.on_banned) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_banned))
06461                                             ch.on_banned=cmd->command_data.cmd_repl_user_12_1.on_banned;
06462 
06463                                         ch.on_flood=old_channel.on_flood;
06464                                         if(botnet_has_grant(bot,old_channel.on_flood) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_flood))
06465                                             ch.on_flood=cmd->command_data.cmd_repl_user_12_1.on_flood;
06466 
06467                                         ch.on_privmsg=old_channel.on_privmsg;
06468                                         if(botnet_has_grant(bot,old_channel.on_privmsg) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_privmsg))
06469                                             ch.on_privmsg=cmd->command_data.cmd_repl_user_12_1.on_privmsg;
06470 
06471                                         ch.on_notice=old_channel.on_notice;
06472                                         if(botnet_has_grant(bot,old_channel.on_notice) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_notice))
06473                                             ch.on_notice=cmd->command_data.cmd_repl_user_12_1.on_notice;
06474 
06475                                         ch.on_except=old_channel.on_except;
06476                                         if(botnet_has_grant(bot,old_channel.on_except) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_except))
06477                                             ch.on_except=cmd->command_data.cmd_repl_user_12_1.on_except;
06478 
06479                                         ch.on_unexcept=old_channel.on_unexcept;
06480                                         if(botnet_has_grant(bot,old_channel.on_unexcept) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_unexcept))
06481                                             ch.on_unexcept=cmd->command_data.cmd_repl_user_12_1.on_unexcept;
06482 
06483                                         ch.on_invite=old_channel.on_invite;
06484                                         if(botnet_has_grant(bot,old_channel.on_invite) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_invite))
06485                                             ch.on_invite=cmd->command_data.cmd_repl_user_12_1.on_invite;
06486 
06487                                         ch.on_uninvite=old_channel.on_uninvite;
06488                                         if(botnet_has_grant(bot,old_channel.on_uninvite) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_uninvite))
06489                                             ch.on_uninvite=cmd->command_data.cmd_repl_user_12_1.on_uninvite;
06490 
06491                                         ch.on_not_invited=old_channel.on_not_invited;
06492                                         if(botnet_has_grant(bot,old_channel.on_not_invited) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_not_invited))
06493                                             ch.on_not_invited=cmd->command_data.cmd_repl_user_12_1.on_not_invited;
06494 
06495                                         ch.on_not_in_reop=old_channel.on_not_in_reop;
06496                                         if(botnet_has_grant(bot,old_channel.on_not_in_reop) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_not_in_reop))
06497                                             ch.on_not_in_reop=cmd->command_data.cmd_repl_user_12_1.on_not_in_reop;
06498 
06499                                         ch.on_reop=old_channel.on_reop;
06500                                         if(botnet_has_grant(bot,old_channel.on_reop) && botnet_has_grant(bot,cmd->command_data.cmd_repl_user_12_1.on_reop))
06501                                             ch.on_reop=cmd->command_data.cmd_repl_user_12_1.on_reop;
06502 
06503                                         ch.can_send_unknown_users=old_channel.can_send_unknown_users;
06504                                         if(bot.access_grant_can_send_unknown_users)
06505                                             ch.can_send_unknown_users=cmd->command_data.cmd_repl_user_12_1.can_send_unknown_users;
06506                                     }
06507 
06508                                     ch.msg_flood.lines=cmd->command_data.cmd_repl_user_12_1.msg_flood_l;
06509                                     ch.msg_flood.seconds=cmd->command_data.cmd_repl_user_12_1.msg_flood_s;
06510 
06511                                     ch.notice_flood.lines=cmd->command_data.cmd_repl_user_12_1.notice_flood_l;
06512                                     ch.notice_flood.seconds=cmd->command_data.cmd_repl_user_12_1.notice_flood_s;
06513 
06514                                     ch.repeat_flood.lines=cmd->command_data.cmd_repl_user_12_1.repeat_flood_l;
06515                                     ch.repeat_flood.seconds=cmd->command_data.cmd_repl_user_12_1.repeat_flood_s;
06516 
06517                                     ch.nick_flood.lines=cmd->command_data.cmd_repl_user_12_1.nick_flood_l;
06518                                     ch.nick_flood.seconds=cmd->command_data.cmd_repl_user_12_1.nick_flood_s;
06519 
06520                                     ch.join_flood.lines=cmd->command_data.cmd_repl_user_12_1.join_flood_l;
06521                                     ch.join_flood.seconds=cmd->command_data.cmd_repl_user_12_1.join_flood_s;
06522 
06523                                     ch.mode_flood.lines=cmd->command_data.cmd_repl_user_12_1.mode_flood_l;
06524                                     ch.mode_flood.seconds=cmd->command_data.cmd_repl_user_12_1.mode_flood_s;
06525 
06526                                     ch.ctcp_flood.lines=cmd->command_data.cmd_repl_user_12_1.ctcp_flood_l;
06527                                     ch.ctcp_flood.seconds=cmd->command_data.cmd_repl_user_12_1.ctcp_flood_s;
06528 
06529                                     ch.dynamic_plus_modes=cmd->command_data.cmd_repl_user_12_1.dynamic_plus_modes;
06530                                     ch.dynamic_minus_modes=cmd->command_data.cmd_repl_user_12_1.dynamic_minus_modes;
06531 
06532                                     {
06533                                         s_user u2;
06534                                         if(!logic_botnet_get_user(u->user.name,u2)) {
06535                                             u2.access_to_backup=false;
06536                                             u2.access_grant_backup=false;
06537                                             u2.access_to_rehash=false;
06538                                             u2.access_grant_rehash=false;
06539                                             u2.access_to_plususer=false;
06540                                             u2.access_grant_plususer=false;
06541                                             u2.access_to_plusproc=false;
06542                                             u2.access_grant_plusproc=false;
06543                                         }
06544                                         if(!bot.access_grant_backup) {
06545                                             u->user.access_to_backup=u2.access_to_backup;
06546                                             u->user.access_grant_backup=u2.access_grant_backup;
06547                                         }
06548                                         if(!bot.access_grant_rehash) {
06549                                             u->user.access_to_rehash=u2.access_to_rehash;
06550                                             u->user.access_grant_rehash=u2.access_grant_rehash;
06551                                         }
06552                                         if(!bot.access_grant_plususer) {
06553                                             u->user.access_to_plususer=u2.access_to_plususer;
06554                                             u->user.access_grant_plususer=u2.access_grant_plususer;
06555                                         }
06556                                         if(!bot.access_grant_plusproc) {
06557                                             u->user.access_to_plusproc=u2.access_to_plusproc;
06558                                             u->user.access_grant_plusproc=u2.access_grant_plusproc;
06559                                         }
06560                                     }
06561 
06562                                     bool got2=false;
06563                                     {
06564                                         s_user us;
06565                                         if(logic_botnet_get_user(u->user.name,us))
06566                                             got2=true;
06567                                     }
06568 
06569                                     if(got2 || (!got2 && bot.access_to_plususer)) {
06570                                 erase_again:
06571                                         vector<s_channel>::iterator i2;
06572                                         for(i2=r_channels.begin(); i2!=r_channels.end(); i2++) {
06573                                             if(!(*i2).username.compare(ch.username) && !(*i2).channel_name.compare(ch.channel_name)) {
06574                                                 r_channels.erase(i2);
06575                                                 goto erase_again;
06576                                             }
06577                                         }
06578                                         for(i2=r_channel_templates.begin(); i2!=r_channel_templates.end(); i2++) {
06579                                             if(!(*i2).username.compare(ch.username) && !(*i2).channel_name.compare(ch.channel_name)) {
06580                                                 r_channels.erase(i2);
06581                                                 goto erase_again;
06582                                             }
06583                                         }
06584                                         for(i2=r_channel_terminators.begin(); i2!=r_channel_terminators.end(); i2++) {
06585                                             if(!(*i2).username.compare(ch.username) && !(*i2).channel_name.compare(ch.channel_name)) {
06586                                                 r_channels.erase(i2);
06587                                                 goto erase_again;
06588                                             }
06589                                         }
06590 
06591                                         if(!u->user.is_template) {
06592                                             if(!u->user.terminator)
06593                                                 r_channels.push_back(ch);
06594                                             else
06595                                                 r_channel_terminators.push_back(ch);
06596                                         } else {
06597                                             ch.is_template=true;
06598                                             r_channel_templates.push_back(ch);
06599                                         }
06600                                     }
06601                                 }
06602                             }
06603                             break;
06604                         case CMD_REPL_USER_13_1:
06605                             {
06606                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_13_1.name); // !!!
06607                                 char* n=new char[n_size+1];
06608                                 memset(n,0,n_size+1);
06609                                 memcpy(n,cmd->command_data.cmd_repl_user_13_1.name,n_size); // !!!
06610                                 string name=n;
06611                                 delete[] n;
06612                                 n=NULL;
06613 
06614                                 s_user_to_pull* u=NULL;
06615                                 bool got=false;
06616                                 vector<s_user_to_pull>::iterator i2;
06617                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06618                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06619                                         u=&(*i2);
06620                                         got=true;
06621                                         break;
06622                                     }
06623                                 }
06624                                 if(got) {
06625                                     bool got_ch=false;
06626                                     vector<s_channel>::iterator i2;
06627                                     for(i2=r_channels.begin(); i2!=r_channels.end(); i2++) {
06628                                         if(!(*i2).username.compare(u->user.name) && !(*i2).channel_name.compare(cmd->command_data.cmd_repl_user_13_1.channel)) {
06629                                             got_ch=true;
06630                                             break;
06631                                         }
06632                                     }
06633 
06634                                     if(got_ch) {
06635                                         int g_size=sizeof(cmd->command_data.cmd_repl_user_13_1.group); // !!!
06636                                         char* g=new char[g_size+1];
06637                                         memset(g,0,g_size+1);
06638                                         memcpy(g,cmd->command_data.cmd_repl_user_13_1.group,g_size); // !!!
06639                                         string group=g;
06640                                         delete[] g;
06641                                         g=NULL;
06642 
06643                                         int pm_size=sizeof(cmd->command_data.cmd_repl_user_13_1.plus_modes); // !!!
06644                                         char* pm=new char[pm_size+1];
06645                                         memset(pm,0,pm_size+1);
06646                                         memcpy(pm,cmd->command_data.cmd_repl_user_13_1.plus_modes,pm_size); // !!!
06647                                         string plus_modes=pm;
06648                                         delete[] pm;
06649                                         pm=NULL;
06650 
06651                                         int mm_size=sizeof(cmd->command_data.cmd_repl_user_13_1.minus_modes); // !!!
06652                                         char* mm=new char[mm_size+1];
06653                                         memset(mm,0,mm_size+1);
06654                                         memcpy(mm,cmd->command_data.cmd_repl_user_13_1.minus_modes,mm_size); // !!!
06655                                         string minus_modes=mm;
06656                                         delete[] mm;
06657                                         mm=NULL;
06658 
06659                                         s_dynamic_rule r;
06660                                         r.group=group;
06661                                         r.plus_modes=plus_modes;
06662                                         r.minus_modes=minus_modes;
06663                                         (*i2).allow_dynamic.push_back(r);
06664                                     }
06665                                 }
06666                             }
06667                             break;
06668                         case CMD_REPL_USER_14_1:
06669                             {
06670                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_14_1.name); // !!!
06671                                 char* n=new char[n_size+1];
06672                                 memset(n,0,n_size+1);
06673                                 memcpy(n,cmd->command_data.cmd_repl_user_14_1.name,n_size); // !!!
06674                                 string name=n;
06675                                 delete[] n;
06676                                 n=NULL;
06677 
06678                                 s_user_to_pull* u=NULL;
06679                                 bool got=false;
06680                                 vector<s_user_to_pull>::iterator i2;
06681                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06682                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06683                                         u=&(*i2);
06684                                         got=true;
06685                                         break;
06686                                     }
06687                                 }
06688                                 if(got) {
06689                                     pair<string,string> p;
06690                                     p.first=cmd->command_data.cmd_repl_user_14_1.meta_key;
06691                                     p.second=cmd->command_data.cmd_repl_user_14_1.meta_val;
06692                                     (*i2).user.meta.insert(p);
06693                                 }
06694                             }
06695                             break;
06696                         case CMD_REPL_USER_15_1:
06697                             {
06698                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_15_1.name); // !!!
06699                                 char* n=new char[n_size+1];
06700                                 memset(n,0,n_size+1);
06701                                 memcpy(n,cmd->command_data.cmd_repl_user_15_1.name,n_size); // !!!
06702                                 string name=n;
06703                                 delete[] n;
06704                                 n=NULL;
06705 
06706                                 s_user_to_pull* u=NULL;
06707                                 bool got=false;
06708                                 vector<s_user_to_pull>::iterator i2;
06709                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06710                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06711                                         u=&(*i2);
06712                                         got=true;
06713                                         break;
06714                                     }
06715                                 }
06716                                 if(got) {
06717                                     int d_size=sizeof(cmd->command_data.cmd_repl_user_15_1.access_usage_proc); // !!!
06718                                     char* d=new char[d_size+1];
06719                                     memset(d,0,d_size+1);
06720                                     memcpy(d,cmd->command_data.cmd_repl_user_15_1.access_usage_proc,d_size); // !!!
06721                                     string data=d;
06722                                     delete[] d;
06723                                     d=NULL;
06724 
06725                                     u->user.access_usage_procedure.push_back(data);
06726                                 }
06727                             }
06728                             break;
06729                         case CMD_REPL_USER_16_5:
06730                             {
06731                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_16_5.name); // !!!
06732                                 char* n=new char[n_size+1];
06733                                 memset(n,0,n_size+1);
06734                                 memcpy(n,cmd->command_data.cmd_repl_user_16_5.name,n_size); // !!!
06735                                 string name=n;
06736                                 delete[] n;
06737                                 n=NULL;
06738 
06739                                 s_user_to_pull* u=NULL;
06740                                 bool got=false;
06741                                 vector<s_user_to_pull>::iterator i2;
06742                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06743                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06744                                         u=&(*i2);
06745                                         got=true;
06746                                         break;
06747                                     }
06748                                 }
06749                                 if(got) {
06750                                     u->user.access_to_upgrade=cmd->command_data.cmd_repl_user_16_5.access_to_upgrade;
06751                                     u->user.access_grant_upgrade=cmd->command_data.cmd_repl_user_16_5.access_grant_upgrade;
06752                                 }
06753                             }
06754                             break;
06755                         case CMD_REPL_USER_17_9:
06756                             {
06757                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_17_9.name); // !!!
06758                                 char* n=new char[n_size+1];
06759                                 memset(n,0,n_size+1);
06760                                 memcpy(n,cmd->command_data.cmd_repl_user_17_9.name,n_size); // !!!
06761                                 string name=n;
06762                                 delete[] n;
06763                                 n=NULL;
06764 
06765                                 s_user_to_pull* u=NULL;
06766                                 bool got=false;
06767                                 vector<s_user_to_pull>::iterator i2;
06768                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06769                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06770                                         u=&(*i2);
06771                                         got=true;
06772                                         break;
06773                                     }
06774                                 }
06775                                 if(got) {
06776                                     u->user.access_to_apply=cmd->command_data.cmd_repl_user_17_9.access_to_apply;
06777                                     u->user.access_grant_apply=cmd->command_data.cmd_repl_user_17_9.access_grant_apply;
06778                                 }
06779                             }
06780                             break;
06781                         case CMD_REPL_USER_99_1:
06782                             {
06783                                 int n_size=sizeof(cmd->command_data.cmd_repl_user_99_1.name); // !!!
06784                                 char* n=new char[n_size+1];
06785                                 memset(n,0,n_size+1);
06786                                 memcpy(n,cmd->command_data.cmd_repl_user_99_1.name,n_size); // !!!
06787                                 string name=n;
06788                                 delete[] n;
06789                                 n=NULL;
06790                                 {
06791                                     s_bot_control* c=new s_bot_control;
06792                                     c->hard_clear();
06793                                     c->packet_type=PACKET_TYPE_CONTROL;
06794                                     c->supported_proto_version=SUPPORTED_PROTO_VERSION;
06795                                     c->control=CTRL_PING;
06796                                     botnet_send_control(*i1,c);
06797                                     (*i1)->next_ping=time(NULL)+ping_time;
06798                                     (*i1)->start_awaiting_pong=time(NULL);
06799                                     delete c;
06800 
06801                                     string obj=(string)"USER "+name;
06802                                     vector<s_bot*>::iterator i2;
06803                                 again_1:
06804                                     for(i2=bots.begin(); i2!=bots.end(); i2++) {
06805                                         vector<string>::iterator i3;
06806                                         for(i3=(*i2)->rejected_objects.begin(); i3!=(*i2)->rejected_objects.end(); i3++) {
06807                                             if(!(*i3).compare(obj)) {
06808                                                 (*i2)->rejected_objects.erase(i3);
06809                                                 goto again_1;
06810                                             }
06811                                         }
06812                                     }
06813                                 }
06814 
06815                                 s_user_to_pull* u=NULL;
06816                                 bool got=false;
06817                                 vector<s_user_to_pull>::iterator i2;
06818                                 for(i2=(*i1)->pulling_users.begin(); i2!=(*i1)->pulling_users.end(); i2++) {
06819                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).user.name.compare(name)) {
06820                                         u=&(*i2);
06821                                         got=true;
06822                                         break;
06823                                     }
06824                                 }
06825                                 if(got) {
06826                                     s_user bot;
06827                                     logic_botnet_get_user((*i1)->botname,bot);
06828 
06829                                     {
06830                                         s_user u2;
06831                                         if(!logic_botnet_get_user(u->user.name,u2)) {
06832                                             u2.access_to_backup=false;
06833                                             u2.access_grant_backup=false;
06834                                             u2.access_to_can_send_all_users=false;
06835                                             u2.access_grant_can_send_all_users=false;
06836                                             u2.access_to_can_send_unknown_users=false;
06837                                             u2.access_grant_can_send_unknown_users=false;
06838                                             u2.access_to_die=false;
06839                                             u2.access_grant_die=false;
06840                                             u2.access_to_filesystem=false;
06841                                             u2.access_grant_filesystem=false;
06842                                             u2.access_to_partyline=false;
06843                                             u2.access_grant_partyline=false;
06844                                             u2.access_to_plusproc=false;
06845                                             u2.access_grant_plusproc=false;
06846                                             u2.access_to_plususer=false;
06847                                             u2.access_grant_plususer=false;
06848                                             u2.access_to_private=false;
06849                                             u2.access_grant_private=false;
06850                                             u2.access_to_rehash=false;
06851                                             u2.access_grant_rehash=false;
06852                                             u2.access_to_replication=false;
06853                                             u2.access_grant_replication=false;
06854                                             u2.access_to_restart=false;
06855                                             u2.access_grant_restart=false;
06856                                             u2.access_to_upgrade=false;
06857                                             u2.access_grant_upgrade=false;
06858                                             u2.access_to_apply=false;
06859                                             u2.access_grant_apply=false;
06860                                         }
06861                                         if(!bot.access_grant_backup) {
06862                                             u->user.access_to_backup=u2.access_to_backup;
06863                                             u->user.access_grant_backup=u2.access_grant_backup;
06864                                         }
06865                                         if(!bot.access_grant_can_send_all_users) {
06866                                             u->user.access_to_can_send_all_users=u2.access_to_can_send_all_users;
06867                                             u->user.access_grant_can_send_all_users=u2.access_grant_can_send_all_users;
06868                                         }
06869                                         if(!bot.access_grant_can_send_unknown_users) {
06870                                             u->user.access_to_can_send_unknown_users=u2.access_to_can_send_unknown_users;
06871                                             u->user.access_grant_can_send_unknown_users=u2.access_grant_can_send_unknown_users;
06872                                         }
06873                                         if(!bot.access_grant_die) {
06874                                             u->user.access_to_die=u2.access_to_die;
06875                                             u->user.access_grant_die=u2.access_grant_die;
06876                                         }
06877                                         if(!bot.access_grant_filesystem) {
06878                                             u->user.access_to_filesystem=u2.access_to_filesystem;
06879                                             u->user.access_grant_filesystem=u2.access_grant_filesystem;
06880                                         }
06881                                         if(!bot.access_grant_partyline) {
06882                                             u->user.access_to_partyline=u2.access_to_partyline;
06883                                             u->user.access_grant_partyline=u2.access_grant_partyline;
06884                                         }
06885                                         if(!bot.access_grant_plusproc) {
06886                                             u->user.access_to_plusproc=u2.access_to_plusproc;
06887                                             u->user.access_grant_plusproc=u2.access_grant_plusproc;
06888                                         }
06889                                         if(!bot.access_grant_plususer) {
06890                                             u->user.access_to_plususer=u2.access_to_plususer;
06891                                             u->user.access_grant_plususer=u2.access_grant_plususer;
06892                                         }
06893                                         if(!bot.access_grant_private) {
06894                                             u->user.access_to_private=u2.access_to_private;
06895                                             u->user.access_grant_private=u2.access_grant_private;
06896                                         }
06897                                         if(!bot.access_grant_rehash) {
06898                                             u->user.access_to_rehash=u2.access_to_rehash;
06899                                             u->user.access_grant_rehash=u2.access_grant_rehash;
06900                                         }
06901                                         if(!bot.access_grant_replication) {
06902                                             u->user.access_to_replication=u2.access_to_replication;
06903                                             u->user.access_grant_replication=u2.access_grant_replication;
06904                                         }
06905                                         if(!bot.access_grant_restart) {
06906                                             u->user.access_to_restart=u2.access_to_restart;
06907                                             u->user.access_grant_restart=u2.access_grant_restart;
06908                                         }
06909                                         if(!bot.access_grant_upgrade) {
06910                                             u->user.access_to_upgrade=u2.access_to_upgrade;
06911                                             u->user.access_grant_upgrade=u2.access_grant_upgrade;
06912                                         }
06913                                         if(!bot.access_grant_apply) {
06914                                             u->user.access_to_apply=u2.access_to_apply;
06915                                             u->user.access_grant_apply=u2.access_grant_apply;
06916                                         }
06917                                     }
06918                                     vector<string> new_right;
06919                                     vector<string>::iterator i_1;
06920 
06921                                     new_right.clear();
06922                                     for(i_1=u->user.access_to_group.begin(); i_1!=u->user.access_to_group.end(); i_1++) {
06923                                         vector<string>::iterator i_2;
06924                                         for(i_2=bot.access_grant_group.begin(); i_2!=bot.access_grant_group.end(); i_2++)
06925                                             if(!(*i_2).compare("*") || !(*i_2).compare(*i_1)) {
06926                                                 new_right.push_back(*i_1);
06927                                                 break;
06928                                             }
06929                                     }
06930                                     u->user.access_to_group=new_right;
06931 
06932                                     new_right.clear();
06933                                     for(i_1=u->user.access_grant_group.begin(); i_1!=u->user.access_grant_group.end(); i_1++) {
06934                                         vector<string>::iterator i_2;
06935                                         for(i_2=bot.access_grant_group.begin(); i_2!=bot.access_grant_group.end(); i_2++)
06936                                             if(!(*i_2).compare("*") || !(*i_2).compare(*i_1)) {
06937                                                 new_right.push_back(*i_1);
06938                                                 break;
06939                                             }
06940                                     }
06941                                     u->user.access_grant_group=new_right;
06942 
06943                                     new_right.clear();
06944                                     for(i_1=u->user.access_to_proc.begin(); i_1!=u->user.access_to_proc.end(); i_1++) {
06945                                         vector<string>::iterator i_2;
06946                                         for(i_2=bot.access_grant_procedure.begin(); i_2!=bot.access_grant_procedure.end(); i_2++)
06947                                             if(!(*i_2).compare("*") || !(*i_2).compare(*i_1)) {
06948                                                 new_right.push_back(*i_1);
06949                                                 break;
06950                                             }
06951                                     }
06952                                     u->user.access_to_proc=new_right;
06953 
06954                                     new_right.clear();
06955                                     for(i_1=u->user.access_grant_procedure.begin(); i_1!=u->user.access_grant_procedure.end(); i_1++) {
06956                                         vector<string>::iterator i_2;
06957                                         for(i_2=bot.access_grant_procedure.begin(); i_2!=bot.access_grant_procedure.end(); i_2++)
06958                                             if(!(*i_2).compare("*") || !(*i_2).compare(*i_1)) {
06959                                                 new_right.push_back(*i_1);
06960                                                 break;
06961                                             }
06962                                     }
06963                                     u->user.access_grant_procedure=new_right;
06964 
06965                                     new_right.clear();
06966                                     for(i_1=u->user.access_to_channel.begin(); i_1!=u->user.access_to_channel.end(); i_1++) {
06967                                         vector<string>::iterator i_2;
06968                                         for(i_2=bot.access_grant_channel.begin(); i_2!=bot.access_grant_channel.end(); i_2++)
06969                                             if(!(*i_2).compare("*") || !(*i_2).compare(*i_1)) {
06970                                                 new_right.push_back(*i_1);
06971                                                 break;
06972                                             }
06973                                     }
06974                                     u->user.access_to_channel=new_right;
06975 
06976                                     new_right.clear();
06977                                     for(i_1=u->user.access_grant_channel.begin(); i_1!=u->user.access_grant_channel.end(); i_1++) {
06978                                         vector<string>::iterator i_2;
06979                                         for(i_2=bot.access_grant_channel.begin(); i_2!=bot.access_grant_channel.end(); i_2++)
06980                                             if(!(*i_2).compare("*") || !(*i_2).compare(*i_1)) {
06981                                                 new_right.push_back(*i_1);
06982                                                 break;
06983                                             }
06984                                     }
06985                                     u->user.access_grant_channel=new_right;
06986 
06987                                     bool got2=false;
06988                                     {
06989                                         s_user us;
06990                                         if(logic_botnet_get_user(u->user.name,us))
06991                                             got2=true;
06992                                     }
06993 
06994                                     if(got2 || (!got2 && bot.access_to_plususer)) {
06995                                         if(u->user.last_changed==0)
06996                                             u->user.last_changed++;
06997 
06998                                         s_replication r;
06999                                         r.partner=bot.name;
07000                                         r.type=REPL_PULL;
07001                                         u->user.replication.push_back(r);
07002 
07003                                         logic_botnet_remove_user(u->user.name);
07004                                         if(!u->user.is_template) {
07005                                             if(!u->user.terminator)
07006                                                 r_users.push_back(u->user);
07007                                             else
07008                                                 r_terminators.push_back(u->user);
07009                                         } else
07010                                             r_user_templates.push_back(u->user);
07011 
07012                                         if(bot.access_to_backup) {
07013                                             botnet_backup((*i1)->botname);
07014 
07015                                             if(bot.access_to_rehash)
07016                                                 botnet_rehash(*i1,(*i1)->botname);
07017                                         }
07018 
07019                                         string d="pulling of object ";
07020                                         d+="(user) ";
07021                                         d+=u->user.name;
07022                                         d+=" successful";
07023                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,d.c_str());
07024                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
07025 
07026                                         stats_botnet_user_pulled();
07027 
07028                                         {
07029                                             string obj_type="user";
07030                                             string reason="OK";
07031                                             string obj=u->user.name;
07032 
07033                                             logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL");
07034                                         }
07035                                     }
07036 
07037                                     (*i1)->pulling_users.erase(i2);
07038                                 }
07039                             }
07040                             break;
07041                         case CMD_REPL_PRV_01_1:
07042                             {
07043                                 if(!(*i1)->prv_pulling)
07044                                     break;
07045 
07046                                 (*i1)->prv_to_pull.clear();
07047                                 (*i1)->prv_to_pull.last_changed=cmd->command_data.cmd_repl_prv_01_1.last_changed;
07048                             }
07049                             break;
07050                         case CMD_REPL_PRV_02_1:
07051                             {
07052                                 if(!(*i1)->prv_pulling)
07053                                     break;
07054 
07055                                 s_group g;
07056                                 g.name=cmd->command_data.cmd_repl_prv_02_1.group;
07057                                 (*i1)->prv_to_pull.groups.push_back(g);
07058                             }
07059                             break;
07060                         case CMD_REPL_PRV_03_1:
07061                             {
07062                                 if(!(*i1)->prv_pulling)
07063                                     break;
07064 
07065                                 (*i1)->prv_to_pull.on_privmsg=cmd->command_data.cmd_repl_prv_03_1.on_privmsg;
07066                                 (*i1)->prv_to_pull.on_notice=cmd->command_data.cmd_repl_prv_03_1.on_notice;
07067                                 (*i1)->prv_to_pull.on_ctcp=cmd->command_data.cmd_repl_prv_03_1.on_ctcp;
07068 
07069                                 // for older BOTNET protocols (e.g. older bots) keep this event current
07070                                 if((*i1)->supported_proto_version<7) {
07071                                     (*i1)->prv_to_pull.on_filesys_got_new=r_private.on_filesys_got_new;
07072                                     (*i1)->prv_to_pull.on_fnc=r_private.on_fnc;
07073                                 }
07074                                 if((*i1)->supported_proto_version<8) {
07075                                     (*i1)->prv_to_pull.on_broadcast=r_private.on_broadcast;
07076                                     (*i1)->prv_to_pull.on_server_msg=r_private.on_server_msg;
07077                                 }
07078                             }
07079                             break;
07080                         case CMD_REPL_PRV_04_7:
07081                             {
07082                                 if(!(*i1)->prv_pulling)
07083                                     break;
07084 
07085                                 (*i1)->prv_to_pull.on_filesys_got_new=cmd->command_data.cmd_repl_prv_04_7.on_filesys_got_new;
07086                                 (*i1)->prv_to_pull.on_fnc=cmd->command_data.cmd_repl_prv_04_7.on_fnc;
07087                             }
07088                             break;
07089                         case CMD_REPL_PRV_05_8:
07090                             {
07091                                 if(!(*i1)->prv_pulling)
07092                                     break;
07093 
07094                                 (*i1)->prv_to_pull.on_broadcast=cmd->command_data.cmd_repl_prv_05_8.on_broadcast;
07095                                 (*i1)->prv_to_pull.on_server_msg=cmd->command_data.cmd_repl_prv_05_8.on_server_msg;
07096                             }
07097                             break;
07098                         case CMD_REPL_PRV_06_11:
07099                             {
07100                                 if(!(*i1)->prv_pulling)
07101                                     break;
07102 
07103                                 (*i1)->prv_to_pull.on_internal_event=cmd->command_data.cmd_repl_prv_06_11.on_internal_event;
07104                             }
07105                             break;
07106                         case CMD_REPL_PRV_99_1:
07107                             {
07108                                 {
07109                                     s_bot_control* c=new s_bot_control;
07110                                     c->hard_clear();
07111                                     c->packet_type=PACKET_TYPE_CONTROL;
07112                                     c->supported_proto_version=SUPPORTED_PROTO_VERSION;
07113                                     c->control=CTRL_PING;
07114                                     botnet_send_control(*i1,c);
07115                                     (*i1)->next_ping=time(NULL)+ping_time;
07116                                     (*i1)->start_awaiting_pong=time(NULL);
07117                                     delete c;
07118 
07119                                     string obj=(string)"PRIV";
07120                                     vector<s_bot*>::iterator i2;
07121                                 again_4:
07122                                     for(i2=bots.begin(); i2!=bots.end(); i2++) {
07123                                         vector<string>::iterator i3;
07124                                         for(i3=(*i2)->rejected_objects.begin(); i3!=(*i2)->rejected_objects.end(); i3++) {
07125                                             if(!(*i3).compare(obj)) {
07126                                                 (*i2)->rejected_objects.erase(i3);
07127                                                 goto again_4;
07128                                             }
07129                                         }
07130                                     }
07131                                 }
07132                                 if(!(*i1)->prv_pulling)
07133                                     break;
07134 
07135                                 s_user bot;
07136                                 logic_botnet_get_user((*i1)->botname,bot);
07137 
07138                                 if(bot.access_to_private) {
07139                                     s_replication r;
07140                                     r.partner=bot.name;
07141                                     r.type=REPL_PULL;
07142                                     (*i1)->prv_to_pull.replication.push_back(r);
07143                                     r_private=(*i1)->prv_to_pull;
07144 
07145                                     if(bot.access_to_backup)
07146                                         botnet_backup((*i1)->botname);
07147 
07148                                     if(bot.access_to_rehash)
07149                                         botnet_rehash(*i1,(*i1)->botname);
07150 
07151                                     string d="pulling of object ";
07152                                     d+="(private)"; // no trailing SPACE!!!
07153                                     d+=" successful";
07154 
07155                                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,d.c_str());
07156                                     log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
07157 
07158                                     stats_botnet_private_pulled();
07159 
07160                                     {
07161                                         string obj_type="private";
07162                                         string reason="OK";
07163                                         string obj="private";
07164 
07165                                         logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL");
07166                                     }
07167                                 }
07168                             }
07169                             break;
07170                         case CMD_PROC_1:
07171                             {
07172                                 int n_size=sizeof(cmd->command_data.cmd_proc_1.name);
07173                                 char* n=new char[n_size+1];
07174                                 memset(n,0,n_size+1);
07175                                 memcpy(n,cmd->command_data.cmd_proc_1.name,n_size);
07176                                 string name=n;
07177                                 delete[] n;
07178                                 n=NULL;
07179 
07180                                 {
07181                                     if(cmd->command_data.cmd_proc_1.init) {
07182                                     again_erase2:
07183                                         vector<s_proc_to_pull>::iterator i2;
07184                                         for(i2=(*i1)->pulling_procs.begin(); i2!=(*i1)->pulling_procs.end(); i2++) {
07185                                             if(!(*i2).botname.compare((*i1)->botname) && !(*i2).proc_name.compare(name)) {
07186                                                 (*i1)->pulling_procs.erase(i2);
07187                                                 goto again_erase2;
07188                                             }
07189                                         }
07190                                     }
07191 
07192                                     bool got=false;
07193                                     vector<s_procedure>::iterator i3;
07194                                     for(i3=r_procedures.begin(); i3!=r_procedures.end(); i3++) {
07195                                         if(!(*i3).name.compare(name)) {
07196                                             got=true;
07197                                             vector<s_replication>::iterator i4;
07198                                             for(i4=(*i3).replication.begin(); i4!=(*i3).replication.end(); i4++) {
07199                                                 if(!(*i4).partner.compare((*i1)->botname) && ((*i4).type==REPL_PULL || (*i4).type==REPL_PUSHPULL)) {
07200                                                     s_proc_to_pull p;
07201                                                     p.botname=(*i1)->botname;
07202                                                     p.proc_name=name;
07203                                                     if(cmd->command_data.cmd_proc_1.init) {
07204                                                         p.lines.clear();
07205                                                         p.replication=(*i3).replication;
07206                                                         vector<s_group>::iterator i5;
07207                                                         for(i5=(*i3).groups.begin(); i5!=(*i3).groups.end(); i5++)
07208                                                             p.orig_groups.push_back((*i5).name);
07209                                                     }
07210                                                     (*i1)->pulling_procs.push_back(p);
07211                                                     got=true;
07212                                                     break;
07213                                                 }
07214                                             }
07215                                             if(got)
07216                                                 break;
07217                                         }
07218                                     }
07219                                     if(!got) {
07220                                         s_proc_to_pull p;
07221                                         p.botname=(*i1)->botname;
07222                                         p.proc_name=name;
07223 
07224                                         // we got a new procedure, so set them replication flags
07225                                         s_replication r;
07226                                         r.partner=(*i1)->botname;
07227                                         r.type=REPL_PULL;
07228                                         p.replication.clear();
07229                                         p.replication.push_back(r);
07230                                         p.orig_groups.clear();
07231 
07232                                         (*i1)->pulling_procs.push_back(p);
07233                                     }
07234                                 }
07235 
07236                                 s_proc_to_pull* p=NULL;
07237                                 bool got=false;
07238                                 vector<s_proc_to_pull>::iterator i2;
07239                                 for(i2=(*i1)->pulling_procs.begin(); i2!=(*i1)->pulling_procs.end(); i2++) {
07240                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).proc_name.compare(name)) {
07241                                         p=&(*i2);
07242                                         got=true;
07243                                         break;
07244                                     }
07245                                 }
07246                                 if(got) {
07247                                     p->last_changed=cmd->command_data.cmd_proc_1.last_changed;
07248                                     if(p->last_changed==0)
07249                                         p->last_changed++;
07250                                     string ln=cmd->command_data.cmd_proc_1.line;
07251                                     string token;
07252                                     for(unsigned int i1=0; i1<ln.length()+1; i1++) {
07253                                         if(i1<ln.length() && ln[i1]!=0x20)
07254                                             token+=ln[i1];
07255                                         else {
07256                                             break;
07257                                         }
07258                                     }
07259 
07260                                     if(!token.compare("replication") || !token.compare("member_of_group")) {
07261                                         // silently ignore
07262                                     } else {
07263                                         p->lines.push_back(ln);
07264                                     }
07265                                 }
07266                             }
07267                             break;
07268                         case CMD_PROC_END_1:
07269                             {
07270                                 int n_size=sizeof(cmd->command_data.cmd_proc_end_1.name); // !!!
07271                                 char* n=new char[n_size+1];
07272                                 memset(n,0,n_size+1);
07273                                 memcpy(n,cmd->command_data.cmd_proc_end_1.name,n_size); // !!!
07274                                 string name=n;
07275                                 delete[] n;
07276                                 n=NULL;
07277                                 {
07278                                     s_bot_control* c=new s_bot_control;
07279                                     c->hard_clear();
07280                                     c->packet_type=PACKET_TYPE_CONTROL;
07281                                     c->supported_proto_version=SUPPORTED_PROTO_VERSION;
07282                                     c->control=CTRL_PING;
07283                                     botnet_send_control(*i1,c);
07284                                     (*i1)->next_ping=time(NULL)+ping_time;
07285                                     (*i1)->start_awaiting_pong=time(NULL);
07286                                     delete c;
07287 
07288                                     string obj=(string)"PROC "+name;
07289                                     vector<s_bot*>::iterator i2;
07290                                 again_2:
07291                                     for(i2=bots.begin(); i2!=bots.end(); i2++) {
07292                                         vector<string>::iterator i3;
07293                                         for(i3=(*i2)->rejected_objects.begin(); i3!=(*i2)->rejected_objects.end(); i3++) {
07294                                             if(!(*i3).compare(obj)) {
07295                                                 (*i2)->rejected_objects.erase(i3);
07296                                                 goto again_2;
07297                                             }
07298                                         }
07299                                     }
07300                                 }
07301 
07302                                 s_proc_to_pull* p=NULL;
07303                                 bool got=false;
07304                                 vector<s_proc_to_pull>::iterator i2;
07305                                 for(i2=(*i1)->pulling_procs.begin(); i2!=(*i1)->pulling_procs.end(); i2++) {
07306                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).proc_name.compare(name)) {
07307                                         p=&(*i2);
07308                                         got=true;
07309                                         break;
07310                                     }
07311                                 }
07312                                 if(got) {
07313                                     p->lines.pop_back(); // erase ending '}' bracket
07314 
07315                                     string l="last_changed ";
07316                                     char tmp[128];
07317                                     ltoa((long)p->last_changed,tmp,10);
07318                                     l+=tmp;
07319                                     p->lines.push_back(l);
07320 
07321                                     vector<string>::iterator i4;
07322                                     for(i4=p->orig_groups.begin(); i4!=p->orig_groups.end(); i4++) {
07323                                         string l="member_of_group ";
07324                                         l+=*i4;
07325                                         p->lines.push_back(l);
07326                                     }
07327                                     vector<s_replication>::iterator i3;
07328                                     for(i3=p->replication.begin(); i3!=p->replication.end(); i3++) {
07329                                         string type;
07330                                         if((*i3).type==REPL_PUSH)
07331                                             type="push";
07332                                         if((*i3).type==REPL_PULL)
07333                                             type="pull";
07334                                         if((*i3).type==REPL_PUSHPULL)
07335                                             type="pushpull";
07336                                         string l=(string)"replication "+(*i3).partner+" "+type;
07337                                         p->lines.push_back(l);
07338                                     }
07339 
07340                                     s_user bot;
07341                                     logic_botnet_get_user((*i1)->botname,bot);
07342 
07343                                     bool got2=false;
07344                                     vector<s_procedure>::iterator i5;
07345                                     for(i5=r_procedures.begin(); i5!=r_procedures.end(); i5++)
07346                                         if(!(*i5).name.compare(p->proc_name)) {
07347                                             got2=true;
07348                                             break;
07349                                         }
07350 
07351                                     if(got2 || (!got2 && bot.access_to_plusproc)) {
07352                                         int error_line;
07353                                         const char* error_reason=NULL;
07354                                         logic_parse_proc(error_reason,error_line,p->lines,false,p->proc_name,p->orig_groups);
07355 
07356                                         string d="pulling of object ";
07357                                         d+="(procedure) ";
07358                                         d+=p->proc_name;
07359 
07360                                         if(error_line!=0) {
07361                                             // an compilation error
07362                                         } else {
07363                                             logic_parse_proc(error_reason,error_line,p->lines,true,p->proc_name,p->orig_groups);
07364                                         
07365                                             if(bot.access_to_backup)
07366                                                 botnet_backup((*i1)->botname);
07367 
07368                                             if(bot.access_to_rehash)
07369                                                 botnet_rehash(*i1,(*i1)->botname);
07370 
07371                                             stats_botnet_proc_pulled();
07372                                         }
07373                                         if(error_line==0) {
07374                                             d+=" successful";
07375 
07376                                             {
07377                                                 string obj_type="procedure";
07378                                                 string reason="OK";
07379                                                 string obj=p->proc_name;
07380 
07381                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL");
07382                                             }
07383 
07384                                             if(!botnet_has_grant(bot,p->proc_name)) {
07385                                                 string x="\"";
07386                                                 x+=p->proc_name;
07387                                                 x+="\"";
07388 
07389                                                 bot.access_usage_procedure.push_back(x);
07390 
07391                                                 logic_botnet_remove_user((*i1)->botname);
07392                                                 if(!bot.is_template) {
07393                                                     if(!bot.terminator)
07394                                                         r_users.push_back(bot);
07395                                                     else
07396                                                         r_terminators.push_back(bot);
07397                                                 } else
07398                                                     r_user_templates.push_back(bot);
07399                                             }
07400                                         } else {
07401                                             d+=" error: ";
07402                                             d+=error_reason;
07403                                             d+=" on line #";
07404                                             char tmp[64];
07405                                             ltoa(error_line,tmp,10);
07406                                             d+=tmp;
07407 
07408                                             {
07409                                                 string obj_type="procedure";
07410                                                 string reason="compile error";
07411                                                 string obj=p->proc_name;
07412 
07413                                                 logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_CRITICAL_ERROR,d,"PULL");
07414                                             }
07415                                         }
07416 
07417                                         log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,d.c_str());
07418                                         log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
07419                                     }
07420 
07421                                     (*i1)->pulling_procs.erase(i2);
07422                                 }
07423                             }
07424                             break;
07425                         case CMD_PARTYLINE_1:
07426                             {
07427                                 int user_size=sizeof(cmd->command_data.cmd_partyline_1.user);
07428                                 int ch_size=sizeof(cmd->command_data.cmd_partyline_1.channel);
07429                                 int bn_size=sizeof(cmd->command_data.cmd_partyline_1.botname);
07430 
07431                                 char* x=new char[ch_size+1];
07432                                 memset(x,0,ch_size+1);
07433                                 strncpy(x,cmd->command_data.cmd_partyline_1.channel,ch_size);
07434                                 bool got=false;
07435                             again3:
07436                                 vector<s_botnet_channel>::iterator i2;
07437                                 for(i2=botnet_channels.begin(); i2!=botnet_channels.end(); i2++)
07438                                     if(!(*i2).channel_name.compare(x)) {
07439                                         got=true;
07440                                         break;
07441                                     }
07442                                 string channel=x;
07443                                 if(!got && !channel.empty()) {
07444                                     s_botnet_channel c;
07445                                     c.channel_name=x;
07446                                     botnet_channels.push_back(c);
07447                                     goto again3;
07448                                 }
07449                                 s_partyline_member me;
07450                                 delete[] x;
07451                                 x=new char[user_size+1];
07452                                 memset(x,0,user_size+1);
07453                                 strncpy(x,cmd->command_data.cmd_partyline_1.user,user_size);
07454                                 me.user=x;
07455                                 delete[] x;
07456 
07457                                 x=new char[bn_size+1];
07458                                 memset(x,0,bn_size+1);
07459                                 strncpy(x,cmd->command_data.cmd_partyline_1.botname,bn_size);
07460                                 me.botname=x;
07461                                 delete[] x;
07462 
07463                                 bool got2=false;
07464                                 if(!channel.empty()) {
07465                                     vector<s_partyline_member>::iterator i3;
07466                                     for(i3=(*i2).members.begin(); i3!=(*i2).members.end(); i3++)
07467                                         if(!(*i3).user.compare(me.user)) {
07468                                             got2=true;
07469                                             break;
07470                                         }
07471                                     if(!got2)
07472                                         (*i2).members.push_back(me);
07473                                 }
07474 
07475                                 botnet_cleanup_ids();
07476                                 bool got_id=false;
07477                                 vector<s_msg_id>::iterator i5;
07478                                 for(i5=msg_ids.begin(); i5!=msg_ids.end(); i5++)
07479                                     if((*i5).id==cmd->command_data.cmd_partyline_1.id) {
07480                                         got_id=true;
07481                                         break;
07482                                     }
07483 
07484                                 if(!got_id) {
07485                                     s_msg_id id;
07486                                     time((time_t*)&id.time);
07487                                     id.id=cmd->command_data.cmd_partyline_1.id;
07488                                     msg_ids.push_back(id);
07489 
07490                                     vector<s_bot*>::iterator i4;
07491                                     for(i4=bots.begin(); i4!=bots.end(); i4++) {
07492                                         //if((*i4).botname.compare(me.botname) && (*i4).botname.compare((*i1)->botname))
07493                                             botnet_send_command(*i4,cmd);
07494                                     }
07495 
07496                                     botnet_partyline_event(me.botname,cmd);
07497 
07498                                     stats_botnet_partyline_event();
07499                                 }
07500                             }
07501                             break;
07502                         case CMD_PARTYLINE_USER_1:
07503                             {
07504                                 int user_size=sizeof(cmd->command_data.cmd_partyline_user_1.user);
07505                                 int ch_size=sizeof(cmd->command_data.cmd_partyline_user_1.channel);
07506                                 int bn_size=sizeof(cmd->command_data.cmd_partyline_user_1.botname);
07507 
07508                                 char* x=new char[ch_size+1];
07509                                 memset(x,0,ch_size+1);
07510                                 strncpy(x,cmd->command_data.cmd_partyline_user_1.channel,ch_size);
07511                                 bool got=false;
07512                             again4:
07513                                 vector<s_botnet_channel>::iterator i2;
07514                                 for(i2=botnet_channels.begin(); i2!=botnet_channels.end(); i2++)
07515                                     if(!(*i2).channel_name.compare(x)) {
07516                                         got=true;
07517                                         break;
07518                                     }
07519                                 if(!got) {
07520                                     s_botnet_channel c;
07521                                     c.channel_name=x;
07522                                     botnet_channels.push_back(c);
07523                                     goto again4;
07524                                 }
07525                                 s_partyline_member me;
07526                                 delete[] x;
07527                                 x=new char[user_size+1];
07528                                 memset(x,0,user_size+1);
07529                                 strncpy(x,cmd->command_data.cmd_partyline_user_1.user,user_size);
07530                                 me.user=x;
07531                                 delete[] x;
07532                                 x=new char[bn_size+1];
07533                                 memset(x,0,bn_size+1);
07534                                 strncpy(x,cmd->command_data.cmd_partyline_user_1.botname,bn_size);
07535                                 me.botname=x;
07536                                 delete[] x;
07537                                 bool got2=false;
07538                                 vector<s_partyline_member>::iterator i3;
07539                                 for(i3=(*i2).members.begin(); i3!=(*i2).members.end(); i3++)
07540                                     if(!(*i3).user.compare(me.user) && !(*i3).botname.compare(me.botname)) {
07541                                         got2=true;
07542                                         break;
07543                                     }
07544                                 if(!got2)
07545                                     (*i2).members.push_back(me);
07546 
07547                                 botnet_cleanup_ids();
07548                                 bool got_id=false;
07549                                 vector<s_msg_id>::iterator i5;
07550                                 for(i5=msg_ids.begin(); i5!=msg_ids.end(); i5++)
07551                                     if((*i5).id==cmd->command_data.cmd_partyline_user_1.id) {
07552                                         got_id=true;
07553                                         break;
07554                                     }
07555 
07556                                 if(!got_id) {
07557                                     s_msg_id id;
07558                                     time((time_t*)&id.time);
07559                                     id.id=cmd->command_data.cmd_partyline_user_1.id;
07560                                     msg_ids.push_back(id);
07561 
07562                                     vector<s_bot*>::iterator i4;
07563                                     for(i4=bots.begin(); i4!=bots.end(); i4++)
07564                                         //if((*i4).botname.compare((*i1)->botname))
07565                                             botnet_send_command(*i4,cmd);
07566 
07567                                     botnet_partyline_event((*i1)->botname,cmd);
07568 
07569                                     stats_botnet_partyline_event();
07570                                 }
07571                             }
07572                             break;
07573                         case CMD_REPL_CHDEF_01_1:
07574                             {
07575                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_01_1.name);
07576                                 char* n=new char[n_size+1];
07577                                 memset(n,0,n_size+1);
07578                                 memcpy(n,cmd->command_data.cmd_repl_chdef_01_1.name,n_size);
07579                                 string name=n;
07580                                 delete[] n;
07581                                 n=NULL;
07582 
07583                                 {
07584                                 again_erase_2:
07585                                     vector<s_chan_def_to_pull>::iterator i2;
07586                                     for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07587                                         if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07588                                             (*i1)->pulling_chans.erase(i2);
07589                                             goto again_erase_2;
07590                                         }
07591                                     }
07592 
07593                                     bool got=false;
07594                                     vector<s_channel_def>::iterator i3;
07595                                     for(i3=r_channel_defs.begin(); i3!=r_channel_defs.end(); i3++) {
07596                                         if(!(*i3).channel_name.compare(name)) {
07597                                             got=true;
07598                                             vector<s_replication>::iterator i4;
07599                                             for(i4=(*i3).replication.begin(); i4!=(*i3).replication.end(); i4++) {
07600                                                 if(!(*i4).partner.compare((*i1)->botname) && ((*i4).type==REPL_PULL || (*i4).type==REPL_PUSHPULL)) {
07601                                                     s_chan_def_to_pull ch;
07602                                                     ch.botname=(*i1)->botname;
07603                                                     ch.chan_name=(*i3).channel_name;
07604                                                     (*i1)->pulling_chans.push_back(ch);
07605                                                     got=true;
07606                                                     break;
07607                                                 }
07608                                             }
07609                                             if(got)
07610                                                 break;
07611                                         }
07612                                     }
07613                                     if(!got) {
07614                                         s_chan_def_to_pull ch;
07615                                         ch.botname=(*i1)->botname;
07616                                         ch.chan_name=name;
07617 
07618                                         // we got a new channel definition, so set them replication flags
07619                                         s_replication r;
07620                                         r.partner=(*i1)->botname;
07621                                         r.type=REPL_PULL;
07622                                         ch.chd.replication.push_back(r);
07623 
07624                                         (*i1)->pulling_chans.push_back(ch);
07625                                     }
07626                                 }
07627 
07628                                 s_chan_def_to_pull* ch=NULL;
07629                                 bool got=false;
07630                                 vector<s_chan_def_to_pull>::iterator i2;
07631                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07632                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07633                                         ch=&(*i2);
07634                                         got=true;
07635                                         break;
07636                                     }
07637                                 }
07638                                 if(got) {
07639                                     ch->last_changed=cmd->command_data.cmd_repl_chdef_01_1.last_changed;
07640 
07641                                     ch->chd.channel_name=name;
07642                                     ch->chd.on_mode=cmd->command_data.cmd_repl_chdef_01_1.on_mode;
07643                                     ch->chd.on_key=cmd->command_data.cmd_repl_chdef_01_1.on_key;
07644                                     ch->chd.on_limit=cmd->command_data.cmd_repl_chdef_01_1.on_limit;
07645                                     ch->chd.on_topic=cmd->command_data.cmd_repl_chdef_01_1.on_topic;
07646                                     ch->chd.on_ircop=cmd->command_data.cmd_repl_chdef_01_1.on_ircop;
07647                                     ch->chd.on_ctcp=cmd->command_data.cmd_repl_chdef_01_1.on_ctcp;
07648                                     ch->chd.on_privmsg=cmd->command_data.cmd_repl_chdef_01_1.on_privmsg;
07649                                     ch->chd.on_notice=cmd->command_data.cmd_repl_chdef_01_1.on_notice;
07650                                     ch->chd.on_part=cmd->command_data.cmd_repl_chdef_01_1.on_part;
07651                                     ch->chd.on_dynamic_ban=cmd->command_data.cmd_repl_chdef_01_1.on_dynamic_ban;
07652                                     ch->chd.allow_dynamic.clear();
07653                                     ch->chd.dynamic_plus_modes=cmd->command_data.cmd_repl_chdef_01_1.dynamic_plus_modes;
07654                                     ch->chd.dynamic_minus_modes=cmd->command_data.cmd_repl_chdef_01_1.dynamic_minus_modes;
07655                                     ch->chd.groups.clear();
07656                                     ch->chd.replication.clear();
07657                                     ch->chd.dynamic_bans.clear();
07658                                     ch->chd.dynbans_editors.clear();
07659                                 }
07660                             }
07661                             break;
07662                         case CMD_REPL_CHDEF_02_1:
07663                             {
07664                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_02_1.name); // !!!
07665                                 char* n=new char[n_size+1];
07666                                 memset(n,0,n_size+1);
07667                                 memcpy(n,cmd->command_data.cmd_repl_chdef_02_1.name,n_size); // !!!
07668                                 string name=n;
07669                                 delete[] n;
07670                                 n=NULL;
07671 
07672                                 s_chan_def_to_pull* ch=NULL;
07673                                 bool got=false;
07674                                 vector<s_chan_def_to_pull>::iterator i2;
07675                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07676                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07677                                         ch=&(*i2);
07678                                         got=true;
07679                                         break;
07680                                     }
07681                                 }
07682                                 if(got) {
07683                                     int d_size=sizeof(cmd->command_data.cmd_repl_chdef_02_1.group); // !!!
07684                                     char* d=new char[d_size+1];
07685                                     memset(d,0,d_size+1);
07686                                     memcpy(d,cmd->command_data.cmd_repl_chdef_02_1.group,d_size); // !!!
07687                                     string data=d;
07688                                     delete[] d;
07689                                     d=NULL;
07690 
07691                                     s_group g;
07692                                     g.name=data;
07693                                     ch->chd.groups.push_back(g);
07694                                 }
07695                             }
07696                             break;
07697                         case CMD_REPL_CHDEF_03_1:
07698                             {
07699                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_03_1.name); // !!!
07700                                 char* n=new char[n_size+1];
07701                                 memset(n,0,n_size+1);
07702                                 memcpy(n,cmd->command_data.cmd_repl_chdef_03_1.name,n_size); // !!!
07703                                 string name=n;
07704                                 delete[] n;
07705                                 n=NULL;
07706 
07707                                 s_chan_def_to_pull* ch=NULL;
07708                                 bool got=false;
07709                                 vector<s_chan_def_to_pull>::iterator i2;
07710                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07711                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07712                                         ch=&(*i2);
07713                                         got=true;
07714                                         break;
07715                                     }
07716                                 }
07717                                 if(got) {
07718                                     int d_size=sizeof(cmd->command_data.cmd_repl_chdef_03_1.group); // !!!
07719                                     char* d=new char[d_size+1];
07720                                     memset(d,0,d_size+1);
07721                                     memcpy(d,cmd->command_data.cmd_repl_chdef_03_1.group,d_size); // !!!
07722                                     string data=d;
07723                                     delete[] d;
07724                                     d=NULL;
07725 
07726                                     s_dynamic_rule dr;
07727                                     dr.group=data;
07728                                     dr.plus_modes=cmd->command_data.cmd_repl_chdef_03_1.plus_modes;
07729                                     dr.minus_modes=cmd->command_data.cmd_repl_chdef_03_1.minus_modes;
07730                                     ch->chd.allow_dynamic.push_back(dr);
07731                                 }
07732                             }
07733                             break;
07734                         case CMD_REPL_CHDEF_04_1:
07735                             {
07736                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_04_1.name); // !!!
07737                                 char* n=new char[n_size+1];
07738                                 memset(n,0,n_size+1);
07739                                 memcpy(n,cmd->command_data.cmd_repl_chdef_04_1.name,n_size); // !!!
07740                                 string name=n;
07741                                 delete[] n;
07742                                 n=NULL;
07743 
07744                                 s_chan_def_to_pull* ch=NULL;
07745                                 bool got=false;
07746                                 vector<s_chan_def_to_pull>::iterator i2;
07747                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07748                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07749                                         ch=&(*i2);
07750                                         got=true;
07751                                         break;
07752                                     }
07753                                 }
07754                                 if(got) {
07755                                     int d_size=sizeof(cmd->command_data.cmd_repl_chdef_04_1.mask); // !!!
07756                                     char* d=new char[d_size+1];
07757                                     memset(d,0,d_size+1);
07758                                     memcpy(d,cmd->command_data.cmd_repl_chdef_04_1.mask,d_size); // !!!
07759                                     string mask=d;
07760                                     delete[] d;
07761                                     d=NULL;
07762 
07763                                     d_size=sizeof(cmd->command_data.cmd_repl_chdef_04_1.reason); // !!!
07764                                     d=new char[d_size+1];
07765                                     memset(d,0,d_size+1);
07766                                     memcpy(d,cmd->command_data.cmd_repl_chdef_04_1.reason,d_size); // !!!
07767                                     string reason=d;
07768                                     delete[] d;
07769                                     d=NULL;
07770 
07771                                     pair<string,string> p;
07772                                     p.first=mask;
07773                                     p.second=reason;
07774 
07775                                     ch->chd.dynamic_bans.insert(p);
07776                                 }
07777                             }
07778                             break;
07779                         case CMD_REPL_CHDEF_05_1:
07780                             {
07781                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_05_1.name); // !!!
07782                                 char* n=new char[n_size+1];
07783                                 memset(n,0,n_size+1);
07784                                 memcpy(n,cmd->command_data.cmd_repl_chdef_05_1.name,n_size); // !!!
07785                                 string name=n;
07786                                 delete[] n;
07787                                 n=NULL;
07788 
07789                                 s_chan_def_to_pull* ch=NULL;
07790                                 bool got=false;
07791                                 vector<s_chan_def_to_pull>::iterator i2;
07792                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07793                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07794                                         ch=&(*i2);
07795                                         got=true;
07796                                         break;
07797                                     }
07798                                 }
07799                                 if(got) {
07800                                     int d_size=sizeof(cmd->command_data.cmd_repl_chdef_05_1.group); // !!!
07801                                     char* d=new char[d_size+1];
07802                                     memset(d,0,d_size+1);
07803                                     memcpy(d,cmd->command_data.cmd_repl_chdef_05_1.group,d_size); // !!!
07804                                     string data=d;
07805                                     delete[] d;
07806                                     d=NULL;
07807 
07808                                     ch->chd.dynbans_editors.push_back(data);
07809                                 }
07810                             }
07811                             break;
07812                         case CMD_REPL_CHDEF_06_8:
07813                             {
07814                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_06_8.name); // !!!
07815                                 char* n=new char[n_size+1];
07816                                 memset(n,0,n_size+1);
07817                                 memcpy(n,cmd->command_data.cmd_repl_chdef_06_8.name,n_size); // !!!
07818                                 string name=n;
07819                                 delete[] n;
07820                                 n=NULL;
07821 
07822                                 s_chan_def_to_pull* ch=NULL;
07823                                 bool got=false;
07824                                 vector<s_chan_def_to_pull>::iterator i2;
07825                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07826                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07827                                         ch=&(*i2);
07828                                         got=true;
07829                                         break;
07830                                     }
07831                                 }
07832                                 if(got) {
07833                                     int d_size=sizeof(cmd->command_data.cmd_repl_chdef_06_8.on_server_msg); // !!!
07834                                     char* d=new char[d_size+1];
07835                                     memset(d,0,d_size+1);
07836                                     memcpy(d,cmd->command_data.cmd_repl_chdef_06_8.on_server_msg,d_size); // !!!
07837                                     string data=d;
07838                                     delete[] d;
07839                                     d=NULL;
07840 
07841                                     ch->chd.channel_name=name;
07842                                     ch->chd.on_server_msg=data;
07843                                 }
07844                             }
07845                             break;
07846                         case CMD_REPL_CHDEF_99_1:
07847                             {
07848                                 int n_size=sizeof(cmd->command_data.cmd_repl_chdef_99_1.name); // !!!
07849                                 char* n=new char[n_size+1];
07850                                 memset(n,0,n_size+1);
07851                                 memcpy(n,cmd->command_data.cmd_repl_chdef_99_1.name,n_size); // !!!
07852                                 string name=n;
07853                                 delete[] n;
07854                                 n=NULL;
07855                                 {
07856                                     s_bot_control* c=new s_bot_control;
07857                                     c->hard_clear();
07858                                     c->packet_type=PACKET_TYPE_CONTROL;
07859                                     c->supported_proto_version=SUPPORTED_PROTO_VERSION;
07860                                     c->control=CTRL_PING;
07861                                     botnet_send_control(*i1,c);
07862                                     (*i1)->next_ping=time(NULL)+ping_time;
07863                                     (*i1)->start_awaiting_pong=time(NULL);
07864                                     delete c;
07865 
07866                                     string obj=(string)"CHAN "+name;
07867                                     vector<s_bot*>::iterator i2;
07868                                 again_3:
07869                                     for(i2=bots.begin(); i2!=bots.end(); i2++) {
07870                                         vector<string>::iterator i3;
07871                                         for(i3=(*i2)->rejected_objects.begin(); i3!=(*i2)->rejected_objects.end(); i3++) {
07872                                             if(!(*i3).compare(obj)) {
07873                                                 (*i2)->rejected_objects.erase(i3);
07874                                                 goto again_3;
07875                                             }
07876                                         }
07877                                     }
07878                                 }
07879 
07880                                 s_chan_def_to_pull* ch=NULL;
07881                                 bool got=false;
07882                                 vector<s_chan_def_to_pull>::iterator i2;
07883                                 for(i2=(*i1)->pulling_chans.begin(); i2!=(*i1)->pulling_chans.end(); i2++) {
07884                                     if(!(*i2).botname.compare((*i1)->botname) && !(*i2).chan_name.compare(name)) {
07885                                         ch=&(*i2);
07886                                         got=true;
07887                                         break;
07888                                     }
07889                                 }
07890                                 if(got) {
07891                                     s_user bot;
07892                                     logic_botnet_get_user((*i1)->botname,bot);
07893 
07894                                     {
07895                                         s_channel_def chd;
07896                                         logic_botnet_get_channel_def(ch->chan_name,chd);
07897                                         s_replication r;
07898                                         r.partner=(*i1)->botname;
07899                                         r.type=REPL_PULL;
07900                                         ch->chd.replication.clear();
07901                                         vector<s_replication>::iterator i2;
07902                                         bool got_this_repl=false;
07903                                         for(i2=chd.replication.begin(); i2!=chd.replication.end(); i2++) {
07904                                             ch->chd.replication.push_back(*i2);
07905                                             if(!(*i2).partner.compare(r.partner))
07906                                                 got_this_repl=true;
07907                                         }
07908                                         if(!got_this_repl)
07909                                             ch->chd.replication.push_back(r);
07910                                     }
07911 
07912                                     s_replication r;
07913                                     r.partner=bot.name;
07914                                     r.type=REPL_PULL;
07915                                     ch->chd.replication.push_back(r);
07916 
07917                                     logic_botnet_remove_channel_def(ch->chan_name);
07918                                     r_channel_defs.push_back(ch->chd);
07919 
07920                                     if(bot.access_to_backup)
07921                                         botnet_backup((*i1)->botname);
07922 
07923                                     if(bot.access_to_rehash)
07924                                         botnet_rehash(*i1,(*i1)->botname);
07925 
07926                                     string d="pulling of object ";
07927                                     d+="(channel) ";
07928                                     d+=ch->chan_name;
07929                                     d+=" successful";
07930                                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,d.c_str());
07931                                     log_botnet(botnet_botname,(*i1)->botname.c_str(),d.c_str());
07932 
07933                                     (*i1)->pulling_chans.erase(i2);
07934 
07935                                     stats_botnet_chandef_pulled();
07936 
07937                                     {
07938                                         string obj_type="channel";
07939                                         string reason="OK";
07940                                         string obj=ch->chan_name;
07941 
07942                                         logic_on_internal_event("@botnet_replication@",(*i1)->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PULL");
07943                                     }
07944                                 }
07945                             }
07946                             break;
07947                         default:
07948                             log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,"unknown PACKET_TYPE_COMMAND from remote bot - in file " __FILE__ " in function " __FUNC__);
07949                             break;
07950                     }
07951                 }
07952             }
07953             if(packet_type!=PACKET_TYPE_COMMAND && packet_type!=PACKET_TYPE_CONTROL)
07954                 log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,"invalid PACKET_TYPE from remote bot");
07955             else {
07956                 if(packet_type==PACKET_TYPE_COMMAND)
07957                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),cmd->packet_type,cmd->command,"COMMAND from remote bot");
07958                 if(packet_type==PACKET_TYPE_CONTROL)
07959                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),ctrl->packet_type,ctrl->control,"CONTROL from remote bot");
07960             }
07961         }
07962     }
07963     /*delete cmd;
07964     delete ctrl;*/
07965 
07966 l:
07967     // send
07968     for(i1=bots.begin(); i1!=bots.end(); i1++) {
07969         if((*i1)->ssl)
07970             ssl_do_read_write((*i1)->ssl);
07971         if((*i1)->socket.cmp()==true && (*i1)->ssl_connection && (*i1)->awaiting_ready!=0) {
07972             time_t now=time(NULL);
07973             //time_t x=(*i1)->awaiting_ready+10-now;
07974             if((*i1)->awaiting_ready+10<now) {
07975                 (*i1)->awaiting_ready=0;
07976                 ssl_close((*i1)->ssl,&((*i1)->socket));
07977                 (*i1)->ssl=NULL;
07978                 sock_close((*i1)->socket);
07979                 (*i1)->socket.clear();
07980                 continue;
07981             }
07982             char buff;
07983             size_t len=recv((*i1)->socket.handle,&buff,1,0);
07984             if(len<=0)
07985                 continue;
07986 
07987             if(len==1 && buff==0x01) {
07988                 (*i1)->awaiting_ready=0;
07989                 char err_str[1024];
07990                 if(ssl_client_connection((*i1)->ssl,&((*i1)->socket),err_str,(char*)ssl_conf.client_cert.c_str(),(char*)ssl_conf.client_key.c_str())) {
07991                     ssl_close((*i1)->ssl,&((*i1)->socket));
07992                     (*i1)->ssl=NULL;
07993                     sock_close((*i1)->socket);
07994                     (*i1)->socket.clear();
07995                     continue;
07996                 }
07997             }
07998             continue;
07999         }
08000         if((*i1)->socket.cmp()==false) {
08001             if((*i1)->was_linked) {
08002                 log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,"LINK connection broken");
08003                 log_botnet(botnet_botname,(*i1)->botname.c_str(),"LINK connection broken");
08004                 (*i1)->was_linked=false;
08005                 botnet_on_unlink((*i1)->botname,botnet_botname,botnet_get_unique_id());
08006             }
08007 
08008             bool got=false;
08009             vector<s_bot*>::iterator i2;
08010             for(i2=bots.begin(); i2!=bots.end(); i2++)
08011                 if(!(*i2)->botname.compare((*i1)->botname) && (*i1)->socket.cmp()!=false)
08012                     got=true;
08013 
08014             if(!(*i1)->invoked_from_telnet && !(*i1)->unlink_proc_called && !got) {
08015                 (*i1)->unlink_proc_called=true;
08016 
08017                 string call_string=(*i1)->unlink_proc;
08018                 string cs=call_string;
08019                 unsigned int i2;
08020                 for(i2=0; i2<cs.length(); i2++)
08021                     if(cs[i2]=='(')
08022                         break;
08023                 cs.erase(i2,cs.length()-i2); // erase everything after '('
08024                 call_string=logic_find_proc_by_name(cs);
08025                 cs=(*i1)->unlink_proc;
08026                 for(i2=0; i2<cs.length(); i2++)
08027                     if(cs[i2]=='(')
08028                         break;
08029                 cs.erase(0,i2+1);
08030                 if(cs.length()>0 && cs[cs.length()-1]==')')
08031                     cs.erase(cs.length()-1,1);
08032                 cs+=",";
08033 
08034                 map<string,string> vars=(*i1)->vars;
08035 
08036                 list<string> params;
08037                 bool str=false;
08038                 string p;
08039                 for(i2=0; i2<cs.length(); i2++) {
08040                     if(cs[i2]=='\"') {
08041                         str=!str;
08042                         continue;
08043                     }
08044                     if(!str && cs[i2]==',') {
08045                         if(p.length()>0 && p[0]=='$') {
08046                             map<string,string>::iterator i3;
08047                             for(i3=vars.begin(); i3!=vars.end(); i3++) {
08048                                 if(!(*i3).first.compare(p)) {
08049                                     p=(*i3).second;
08050                                     break;
08051                                 }
08052                             }
08053                         }
08054                         params.push_back(p);
08055                         p="";
08056                         continue;
08057                     }
08058                     if(!str && cs[i2]==')') {
08059                         if(p!="") {
08060                             if(p.length()>0 && p[0]=='$') {
08061                                 map<string,string>::iterator i3;
08062                                 for(i3=vars.begin(); i3!=vars.end(); i3++) {
08063                                     if(!(*i3).first.compare(p)) {
08064                                         p=(*i3).second;
08065                                         break;
08066                                     }
08067                                 }
08068                             }
08069                             params.push_back(p);
08070                         }
08071                         break;
08072                     }
08073                     p+=cs[i2];
08074                 }
08075 
08076                 logic_call_proc_ex2(call_string.c_str(),vars,params);
08077             }
08078 
08079             if((*i1)->invoked_from_telnet) {
08080                 /*(*i1)->command_receive_buffer=NULL;
08081                 (*i1)->control_receive_buffer=NULL;
08082                 (*i1)->rle_buffer=NULL;*/
08083                 delete *i1;
08084                 bots.erase(i1);
08085                 goto l;
08086             }
08087             // init again
08088             if(!(*i1)->clean) {
08089                 (*i1)->clean=true;
08090                 (*i1)->socket.clear();
08091                 (*i1)->sent_bot_auth_1=false;
08092                 (*i1)->received_bot_auth_1=false;
08093                 (*i1)->receive_buffer_pos=0;
08094                 if((*i1)->rle_buffer) {
08095                     free((*i1)->rle_buffer);
08096                     (*i1)->rle_buffer=NULL;
08097                     (*i1)->rle_buffer_len=0;
08098                 }
08099                 (*i1)->buff_size_from_dcc=0;
08100                 (*i1)->buff_pos_from_dcc=0;
08101                 (*i1)->got_bytes=0;
08102                 (*i1)->auth_ok=false;
08103                 (*i1)->remote_pswd_ok=false;
08104                 (*i1)->was_linked=false;
08105                 time(&(*i1)->next_ping);
08106                 (*i1)->next_ping+=ping_time;
08107                 (*i1)->start_awaiting_pong=0;
08108                 // (*i1)->unlink_proc_called=false;  // do NOT execute this! it causes multiple unlink_proc calls!
08109                 (*i1)->users_to_pull_last_update=0;
08110                 (*i1)->pulling_users.clear();
08111                 (*i1)->users_to_push_last_update=0;
08112                 (*i1)->pushing_users.clear();
08113                 (*i1)->procs_to_pull_last_update=0;
08114                 (*i1)->pulling_procs.clear();
08115                 (*i1)->procs_to_push_last_update=0;
08116                 (*i1)->pushing_procs.clear();
08117 
08118                 (*i1)->chans_to_pull_last_update=0;
08119                 (*i1)->pulling_chans.clear();
08120 
08121                 (*i1)->chans_to_push_last_update;
08122                 (*i1)->pushing_chans.clear();
08123 
08124                 (*i1)->rejected_objects.clear();
08125 
08126                 (*i1)->prv_to_push_last_update=0;
08127                 (*i1)->prv_to_push.clear();
08128                 (*i1)->prv_to_pull.clear();
08129                 (*i1)->prv_pulling=false;
08130 
08131                 (*i1)->last_proc_push=0;
08132 
08133                 (*i1)->sent_partyline_users=false;
08134 
08135                 if((*i1)->ssl)
08136                     ssl_close((*i1)->ssl,&((*i1)->socket));
08137                 (*i1)->ssl=NULL;
08138             }
08139 
08140             time_t now;
08141             time(&now);
08142             if((*i1)->last_try+botnet_penalty>now) {
08143                 (*i1)->waiting=true;
08144                 continue;
08145             }
08146             time(&(*i1)->last_try);
08147 
08148             int ec=0;
08149             (*i1)->socket=sock_connect((char*)(*i1)->localip.c_str(),(char*)(*i1)->botip.c_str(),(*i1)->botport,ec,(*i1)->ssl_connection?false:true);
08150             if((*i1)->socket.cmp()==false) {
08151                 //log_socket(ec,sock_error(ec),"while calling sock_connect in file " __FILE__ " in function " __FUNC__);
08152                 continue;
08153             }
08154             (*i1)->clean=false;
08155             if((*i1)->ssl_connection) {
08156                 sock_set_blocking((*i1)->socket,true);
08157             }
08158 
08159             stats_botnet_new_connection();
08160 
08161             sleep(1000);
08162             size_t len=0;
08163             do {
08164                 char buff[1024];
08165                 int ec=0;
08166                 bool closed;
08167                 if(!(*i1)->ssl_connection)
08168                     len=sock_read((*i1)->socket,buff,1024,ec,closed);
08169                 else {
08170                     timeval t;
08171                     t.tv_sec=0;
08172                     t.tv_usec=10;
08173 
08174                     fd_set a;
08175                     FD_ZERO(&a);
08176                     FD_SET((*i1)->socket.handle,&a);
08177 
08178                     int i=select((int)(*i1)->socket.handle+1,&a,NULL,NULL,&t);
08179                     if(i==0)
08180                         break;
08181                     len=recv((*i1)->socket.handle,buff,1024,0);
08182                 }
08183                 if((signed)len<0)
08184                     len=0;
08185                 stats_botnet_bytes_received(len);
08186                 if(ec)
08187                     len=0;
08188             } while(len);
08189 
08190             ec=0;
08191             string nick=botnet_botname;
08192             nick+="\r\n";
08193             size_t sent=0;
08194             if(!(*i1)->ssl_connection)
08195                 sent=sock_send((*i1)->socket,(char*)nick.c_str(),nick.length(),ec);
08196             else
08197                 sent=send((*i1)->socket.handle,(char*)nick.c_str(),(int)nick.length(),0);
08198             stats_botnet_bytes_sent(sent);
08199             if(sent!=nick.length() || ec!=0) {
08200                 log_socket(ec,sock_error(ec),"in file " __FILE__ " in function " __FUNC__ " (not all the data were sent)");
08201                 if((*i1)->ssl) {
08202                     ssl_close((*i1)->ssl,&((*i1)->socket));
08203                     (*i1)->ssl=NULL;
08204                 }
08205                 sock_close((*i1)->socket);
08206                 (*i1)->socket.clear();
08207                 continue;
08208             }
08209 
08210             if((*i1)->ssl_connection)
08211                 (*i1)->awaiting_ready=time(NULL);
08212         } else {
08213             if((*i1)->socket.cmp()==false)
08214                 continue;
08215 
08216             time_t now;
08217             time(&now);
08218 
08219             if((*i1)->next_ping<now) {
08220                 s_bot_control* c=new s_bot_control;
08221                 c->hard_clear();
08222                 c->packet_type=PACKET_TYPE_CONTROL;
08223                 c->supported_proto_version=SUPPORTED_PROTO_VERSION;
08224                 c->control=CTRL_PING;
08225                 botnet_send_control(*i1,c);
08226                 (*i1)->next_ping=now+ping_time;
08227                 (*i1)->start_awaiting_pong=now;
08228                 delete c;
08229             }
08230             if((*i1)->start_awaiting_pong!=0) {
08231                 if((*i1)->start_awaiting_pong+10<now) {
08232                     // ping timeout
08233                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),-1,-1,"PING timeout - in file " __FILE__ " in function " __FUNC__);
08234                     log_botnet(botnet_botname,(*i1)->botname.c_str(),"PING timeout");
08235                     if((*i1)->ssl) {
08236                         ssl_close((*i1)->ssl,&((*i1)->socket));
08237                         (*i1)->ssl=NULL;
08238                     }
08239                     sock_close((*i1)->socket);
08240                     (*i1)->socket.clear();
08241                     continue;
08242                 }
08243             }
08244 
08245             if(!(*i1)->sent_at_least_one_ping) {
08246                 // send dummy ping packet first
08247                 s_bot_control* c=new s_bot_control;
08248                 c->hard_clear();
08249                 c->packet_type=PACKET_TYPE_CONTROL;
08250                 c->supported_proto_version=SUPPORTED_PROTO_VERSION;
08251                 c->control=CTRL_PING;
08252                 botnet_send_control(*i1,c);
08253                 (*i1)->next_ping=now+ping_time;
08254                 (*i1)->start_awaiting_pong=now;
08255                 delete c;
08256 
08257                 (*i1)->sent_at_least_one_ping=true;
08258             }
08259 
08260             if(!(*i1)->sent_bot_auth_1 && (*i1)->got_at_least_one_pong) {
08261                 s_bot_command* c=new s_bot_command;
08262                 c->hard_clear();
08263 
08264                 c->packet_type=PACKET_TYPE_COMMAND;
08265                 c->size=sizeof(c);
08266                 c->version=1;
08267                 c->command=CMD_AUTH_1;
08268                 strcpy(c->command_data.bot_auth_1.botname,botnet_botname);
08269 
08270                 unsigned char signature[32+1];
08271                 signature[32]=0;
08272 
08273                 if((*i1)->remote_MD5_password.length()==sizeof(signature)-1)
08274                     strcpy((char*)signature,dcc_get_password(botnet_botname).c_str());
08275 
08276                 MD5Context md5c;
08277                 MD5Init(&md5c);
08278                 MD5Update(&md5c,signature,sizeof(signature)-1);
08279                 MD5Final(signature,&md5c);
08280 
08281                 char sig[128];
08282                 sig[0]=0;
08283                 for(int i1_=0; i1_<16; i1_++) {
08284                     char tmp[16];
08285                     sprintf(tmp,"%02X",signature[i1_]);
08286                     strcat(sig,tmp);
08287                 }
08288 
08289                 memset(c->command_data.bot_auth_1.digest,0,sizeof(c->command_data.bot_auth_1.digest));
08290                 memcpy(c->command_data.bot_auth_1.digest,sig,sizeof(signature)-1);
08291 
08292                 if(botnet_send_command(*i1,c)) {
08293                     log_botnet_debug(botnet_botname,(*i1)->botname.c_str(),c->packet_type,c->command,"unable to send PACKET_TYPE_COMMAND to remote bot - in file " __FILE__ " in function " __FUNC__);
08294                     log_botnet(botnet_botname,(*i1)->botname.c_str(),"closing LINK connection (error)");
08295                     if((*i1)->ssl) {
08296                         ssl_close((*i1)->ssl,&((*i1)->socket));
08297                         (*i1)->ssl=NULL;
08298                     }
08299                     sock_close((*i1)->socket);
08300                     (*i1)->socket.clear();
08301                     continue;
08302                 }
08303 
08304                 (*i1)->sent_bot_auth_1=true;
08305 
08306                 delete c;
08307             }
08308 
08309             if((*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08310                 time_t now;
08311                 time(&now);
08312                 if(/*(*i1)->users_to_push_last_update+120<now*/ 1) { // commented out because we got last_proc_push functionality
08313                     time(&(*i1)->users_to_push_last_update);
08314 
08315                     /*vector<s_bot*>::iterator i1;
08316                     for(i1=bots.begin(); i1!=bots.end(); i1++) {*/
08317                     for(int _i1_=0; _i1_<1; _i1_++) { // for continue command we use later
08318                         // procedures first!
08319                         if((*i1)->last_proc_push==0 || (*i1)->last_proc_push+60>time(NULL))
08320                             continue; // it is not the right time now! procedures first!
08321                         (*i1)->last_proc_push=0;
08322 
08323                         vector<s_user> users;
08324                         logic_get_push_users((*i1)->botname,users);
08325                         vector<s_user>::iterator i2;
08326                         for(i2=users.begin(); i2!=users.end(); i2++) {
08327                             if((*i2).last_changed==0)
08328                                 (*i2).last_changed=1;
08329                             {
08330                                 bool reject=false;
08331                                 string obj=(string)"USER "+(*i2).name;
08332                                 vector<string>::iterator i2;
08333                                 for(i2=(*i1)->rejected_objects.begin(); i2!=(*i1)->rejected_objects.end(); i2++) {
08334                                     if(!(*i2).compare(obj)) {
08335                                         reject=true;
08336                                         break;
08337                                     }
08338                                 }
08339                                 if(reject)
08340                                     continue;
08341                             }
08342                             s_user_to_push u;
08343                             u.botname=(*i1)->botname;
08344                             u.user=*i2;
08345 
08346                             s_bot_command* c=new s_bot_command;
08347                             c->hard_clear();
08348                             c->packet_type=PACKET_TYPE_COMMAND;
08349                             c->size=sizeof(c);
08350                             c->version=1;
08351                             c->command=CMD_PUSH_1;
08352                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
08353                             c->command_data.check_time_1.user=true;
08354                             c->command_data.check_time_1.procedure=false;
08355                             c->command_data.check_time_1.channel_def=false;
08356                             c->command_data.check_time_1.prv=false;
08357                             char* user=c->command_data.check_time_1.object_name;
08358                             memset(user,0,sizeof(c->command_data.check_time_1.object_name));
08359                             strncpy(user,u.user.name.c_str(),sizeof(c->command_data.check_time_1.object_name));
08360                             c->command_data.check_time_1.original_time=(my_time_t)u.user.last_changed;
08361                             botnet_send_command(*i1,c);
08362 
08363                             delete c;
08364                         }
08365                     }
08366                 }
08367             }
08368 
08369             if((*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08370                 time_t now;
08371                 time(&now);
08372                 if((*i1)->procs_to_push_last_update+120+40<now) {
08373                     time(&(*i1)->procs_to_push_last_update);
08374 
08375                     /*vector<s_bot*>::iterator i1;
08376                     for(i1=bots.begin(); i1!=bots.end(); i1++) {
08377                     */
08378                     {
08379                         (*i1)->last_proc_push=time(NULL);
08380                         vector<s_procedure> procs;
08381                         logic_get_push_procs((*i1)->botname,procs);
08382                         vector<s_procedure>::iterator i2;
08383                         for(i2=procs.begin(); i2!=procs.end(); i2++) {
08384                             if((*i2).last_changed==0)
08385                                 (*i2).last_changed=1;
08386                             {
08387                                 bool reject=false;
08388                                 if((*i2).minimal_botnet_version>(*i1)->supported_proto_version)
08389                                     reject=true;
08390                                 string obj=(string)"PROC "+(*i2).name;
08391                                 vector<string>::iterator i2;
08392                                 for(i2=(*i1)->rejected_objects.begin(); i2!=(*i1)->rejected_objects.end(); i2++) {
08393                                     if(!(*i2).compare(obj)) {
08394                                         reject=true;
08395                                         break;
08396                                     }
08397                                 }
08398                                 if(reject)
08399                                     continue;
08400                             }
08401                             s_proc_to_push p;
08402                             p.botname=(*i1)->botname;
08403                             p.proc_name=(*i2).name;
08404                             vector<string> groups;
08405                             //logic_list_proc((*i2).name,p.lines,p.proc_name,groups);
08406                             p.last_changed=(*i2).last_changed;
08407                             p.proc_name=(*i2).name;
08408 
08409                             s_bot_command* c=new s_bot_command;
08410                             c->hard_clear();
08411                             c->packet_type=PACKET_TYPE_COMMAND;
08412                             c->size=sizeof(c);
08413                             c->version=1;
08414                             c->command=CMD_PUSH_1;
08415                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
08416                             c->command_data.check_time_1.user=false;
08417                             c->command_data.check_time_1.procedure=true;
08418                             c->command_data.check_time_1.channel_def=false;
08419                             c->command_data.check_time_1.prv=false;
08420                             char* proc=c->command_data.check_time_1.object_name;
08421                             memset(proc,0,sizeof(c->command_data.check_time_1.object_name));
08422                             strncpy(proc,p.proc_name.c_str(),sizeof(c->command_data.check_time_1.object_name));
08423                             c->command_data.check_time_1.original_time=(my_time_t)p.last_changed;
08424                             botnet_send_command(*i1,c);
08425 
08426                             delete c;
08427                         }
08428                     }
08429                 }
08430             }
08431 
08432             if((*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08433                 time_t now;
08434                 time(&now);
08435                 if((*i1)->chans_to_push_last_update+120+25<now) {
08436                     time(&(*i1)->chans_to_push_last_update);
08437 
08438                     /*vector<s_bot*>::iterator i1;
08439                     for(i1=bots.begin(); i1!=bots.end(); i1++) {*/
08440                     {
08441                         vector<s_channel_def> chans;
08442                         logic_get_push_chan_defs((*i1)->botname,chans);
08443                         vector<s_channel_def>::iterator i2;
08444                         for(i2=chans.begin(); i2!=chans.end(); i2++) {
08445                             if((*i2).last_changed==0)
08446                                 (*i2).last_changed=1;
08447                             {
08448                                 bool reject=false;
08449                                 string obj=(string)"CHAN "+(*i2).channel_name;
08450                                 vector<string>::iterator i2;
08451                                 for(i2=(*i1)->rejected_objects.begin(); i2!=(*i1)->rejected_objects.end(); i2++) {
08452                                     if(!(*i2).compare(obj)) {
08453                                         reject=true;
08454                                         break;
08455                                     }
08456                                 }
08457                                 if(reject)
08458                                     continue;
08459                             }
08460                             s_chan_def_to_push ch;
08461                             ch.botname=(*i1)->botname;
08462                             ch.chan_name=(*i2).channel_name;
08463                             vector<string> groups;
08464                             ch.last_changed=(*i2).last_changed;
08465 
08466                             s_bot_command* c=new s_bot_command;
08467                             c->hard_clear();
08468                             c->packet_type=PACKET_TYPE_COMMAND;
08469                             c->size=sizeof(c);
08470                             c->version=1;
08471                             c->command=CMD_PUSH_1;
08472                             c->command_data.check_time_1.now=(my_time_t)time(NULL);
08473                             c->command_data.check_time_1.user=false;
08474                             c->command_data.check_time_1.procedure=false;
08475                             c->command_data.check_time_1.channel_def=true;
08476                             c->command_data.check_time_1.prv=false;
08477                             char* chan=c->command_data.check_time_1.object_name;
08478                             memset(chan,0,sizeof(c->command_data.check_time_1.object_name));
08479                             strncpy(chan,ch.chan_name.c_str(),sizeof(c->command_data.check_time_1.object_name));
08480                             c->command_data.check_time_1.original_time=(my_time_t)ch.last_changed;
08481                             botnet_send_command(*i1,c);
08482 
08483                             delete c;
08484                         }
08485                     }
08486                 }
08487             }
08488 
08489             if((*i1)->auth_ok && (*i1)->remote_pswd_ok && !(*i1)->sent_partyline_users) {
08490                 (*i1)->sent_partyline_users=true;
08491                 vector<s_botnet_channel>::iterator i2;
08492                 for(i2=botnet_channels.begin(); i2!=botnet_channels.end(); i2++) {
08493                     vector<s_partyline_member>::iterator i3;
08494                     for(i3=(*i2).members.begin(); i3!=(*i2).members.end(); i3++) {
08495                         s_bot_command* c=new s_bot_command;
08496                         c->hard_clear();
08497 
08498                         c->packet_type=PACKET_TYPE_COMMAND;
08499                         c->size=sizeof(c);
08500                         c->version=1;
08501                         c->command=CMD_PARTYLINE_USER_1;
08502 
08503                         c->command_data.cmd_partyline_user_1.id=botnet_get_unique_id();
08504 
08505                         int user_size=sizeof(c->command_data.cmd_partyline_user_1.user);
08506                         int ch_size=sizeof(c->command_data.cmd_partyline_user_1.channel);
08507                         int bn_size=sizeof(c->command_data.cmd_partyline_user_1.botname);
08508                         strncpy(c->command_data.cmd_partyline_user_1.user,(*i3).user.c_str(),user_size);
08509                         strncpy(c->command_data.cmd_partyline_user_1.channel,(*i2).channel_name.c_str(),ch_size);
08510                         strncpy(c->command_data.cmd_partyline_user_1.botname,(*i3).botname.c_str(),bn_size);
08511 
08512                         botnet_send_command(*i1,c);
08513 
08514                         botnet_partyline_event(botnet_botname,c);
08515 
08516                         delete c;
08517                     }
08518                 }
08519             }
08520 
08521             if((*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08522                 time_t now;
08523                 time(&now);
08524                 if((*i1)->prv_to_push_last_update+120-10<now) {
08525                     time(&(*i1)->prv_to_push_last_update);
08526 
08527                     vector<s_replication>::iterator i2;
08528                     bool skip=true;
08529                     for(i2=r_private.replication.begin(); i2!=r_private.replication.end(); i2++) {
08530                         if(!(*i2).partner.compare((*i1)->botname) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
08531                             skip=false;
08532                             break;
08533                         }
08534                     }
08535                     {
08536                         bool reject=false;
08537                         string obj=(string)"PRIV";
08538                         vector<string>::iterator i2;
08539                         for(i2=(*i1)->rejected_objects.begin(); i2!=(*i1)->rejected_objects.end(); i2++) {
08540                             if(!(*i2).compare(obj)) {
08541                                 reject=true;
08542                                 break;
08543                             }
08544                         }
08545                         if(reject)
08546                             skip=true;
08547                     }
08548 
08549                     if(!skip) {
08550                         (*i1)->prv_to_push=r_private;
08551                         if(r_private.last_changed==0)
08552                             r_private.last_changed=1;
08553                         s_bot_command* c=new s_bot_command;
08554                         c->hard_clear();
08555                         c->packet_type=PACKET_TYPE_COMMAND;
08556                         c->size=sizeof(c);
08557                         c->version=1;
08558                         c->command=CMD_CHECK_TIME_1;
08559                         c->command_data.check_time_1.now=(my_time_t)time(NULL);
08560                         c->command_data.check_time_1.user=false;
08561                         c->command_data.check_time_1.procedure=false;
08562                         c->command_data.check_time_1.channel_def=false;
08563                         c->command_data.check_time_1.prv=true;
08564                         c->command_data.check_time_1.original_time=(my_time_t)(*i1)->prv_to_push.last_changed;
08565                         botnet_send_command(*i1,c);
08566 
08567                         delete c;
08568                     }
08569                 }
08570             }
08571         }
08572     }
08573 
08574 }

Here is the call graph for this function:

void botnet_on_unlink string  botname,
string  from_bot,
int  id
 

Called on unlink of bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname My name
from_bot Name of remote bot
id ID of message

Definition at line 3824 of file botnet.cpp.

References botnet_channels, and dcc_partyline_message().

Referenced by botnet_loop().

03825 {
03826     vector<s_botnet_channel>::iterator i1;
03827 again2:
03828     for(i1=botnet_channels.begin(); i1!=botnet_channels.end(); i1++) {
03829         vector<s_partyline_member>::iterator i2;
03830     again:
03831         for(i2=(*i1).members.begin(); i2!=(*i1).members.end(); i2++) {
03832             if(!(*i2).botname.compare(botname)) {
03833                 string msg=(*i2).user;
03834                 msg+="@";
03835                 msg+=botname;
03836                 msg+=" has left channel ";
03837                 msg+=(*i1).channel_name;
03838                 msg+=" (botnet-split: ";
03839                 msg+=botname;
03840                 msg+=")";
03841                 dcc_partyline_message((*i1).channel_name,msg);
03842                 (*i1).members.erase(i2);
03843                 goto again;
03844             }
03845         }
03846         if((*i1).members.empty()) {
03847             botnet_channels.erase(i1);
03848             goto again2;
03849         }
03850     }
03851 }

Here is the call graph for this function:

void botnet_partyline_event string  origin_bot,
s_bot_command cmd
 

Generates the partyline output message.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
origin_bot Name of bot from which is event
cmd Original command from remote bot

Definition at line 3588 of file botnet.cpp.

References botnet_botname, botnet_partyline_message(), botnet_query_disp_id(), s_bot_command::u_commnd_data::s_cmd_partyline_user_1::channel, s_bot_command::u_commnd_data::s_cmd_partyline_1::channel, s_bot_command::u_commnd_data::cmd_partyline_1, CMD_PARTYLINE_1, s_bot_command::u_commnd_data::cmd_partyline_user_1, CMD_PARTYLINE_USER_1, s_bot_command::command, s_bot_command::command_data, ctx, dcc_broadcast(), dcc_partyline_message(), dcc_user_pong(), s_bot_command::u_commnd_data::s_cmd_partyline_user_1::id, s_msg_id::id, s_bot_command::u_commnd_data::s_cmd_partyline_1::id, s_bot_command::u_commnd_data::s_cmd_partyline_1::join, s_bot_command::u_commnd_data::s_cmd_partyline_1::leave, match(), s_bot_command::u_commnd_data::s_cmd_partyline_1::message, s_bot_command::u_commnd_data::s_cmd_partyline_1::msg, msg_disp_ids, s_msg_id::time, s_bot_command::u_commnd_data::s_cmd_partyline_user_1::user, s_bot_command::u_commnd_data::s_cmd_partyline_1::user, VERSION, and VERSION_COMMENT.

Referenced by botnet_loop(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), and botnet_partyline_message().

03589 {
03590     string msg;
03591 
03592     char* ch=NULL;
03593 
03594     if(cmd->command==CMD_PARTYLINE_1) {
03595         uint32 id=cmd->command_data.cmd_partyline_1.id;
03596 
03597         char* u=new char[sizeof(cmd->command_data.cmd_partyline_1.user)+1];
03598         u[sizeof(cmd->command_data.cmd_partyline_1.user)]=0;
03599         strncpy(u,cmd->command_data.cmd_partyline_1.user,sizeof(cmd->command_data.cmd_partyline_1.user));
03600 
03601         ch=new char[sizeof(cmd->command_data.cmd_partyline_1.channel)+1];
03602         ch[sizeof(cmd->command_data.cmd_partyline_1.channel)]=0;
03603         strncpy(ch,cmd->command_data.cmd_partyline_1.channel,sizeof(cmd->command_data.cmd_partyline_1.channel));
03604 
03605         char* m=new char[sizeof(cmd->command_data.cmd_partyline_1.message)+1];
03606         m[sizeof(cmd->command_data.cmd_partyline_1.message)]=0;
03607         strncpy(m,cmd->command_data.cmd_partyline_1.message,sizeof(cmd->command_data.cmd_partyline_1.message));
03608 
03609         if(strlen(m)>0 && m[0]==0x01) {
03610             if(strstr(m,"\x01" "BROADCAST_PING\x01 ")==m) {
03611                 msg=m;
03612 
03613                 char tmp[]="\x01" "BROADCAST_PONG\x01 ";
03614                 strncpy(m,tmp,strlen(tmp));
03615                 botnet_partyline_message(u,"",m);
03616 
03617                 {
03618                     if(msg.find(" ",0)!=string::npos)
03619                         msg.erase(0,msg.find(" ",0)+1);
03620                     if(msg.find(" ",0)!=string::npos)
03621                         msg.erase(0,msg.find(" ",0)+1);
03622                     string user=msg;
03623                     if(user.find(" ",0)!=string::npos)
03624                         user.erase(user.find(" ",0),user.length()-user.find(" ",0));
03625 
03626                     string version="\x01" "BROADCAST_PONG\x02 VERSION ";
03627                     version+=user;
03628                     version+=" ";
03629                     version+="VooDoo_cIRCle"; // name
03630                     version+=" ";
03631                     version+=VERSION; // version numeric
03632                     version+=" ";
03633                     version+=VERSION_COMMENT; // version comment
03634 
03635                     botnet_partyline_message(u,"",version);
03636                 }
03637 
03638                 msg="";
03639             }
03640             if(strstr(m,"\x01" "BROADCAST_PONG\x01 ")==m) {
03641                 msg=m;
03642                 if(msg.find(" ",0)!=string::npos)
03643                     msg.erase(0,msg.find(" ",0)+1);
03644                 string time_=msg;
03645                 if(msg.find(" ",0)!=string::npos)
03646                     msg.erase(0,msg.find(" ",0)+1);
03647                 if(time_.find(" ",0)!=string::npos)
03648                     time_.erase(time_.find(" ",0),time_.length()-time_.find(" ",0));
03649                 if(msg.find(" ",0)!=string::npos)
03650                     msg.erase(msg.find(" ",0),msg.length()-msg.find(" ",0));
03651                 if(!botnet_query_disp_id(cmd->command_data.cmd_partyline_1.id)) {
03652                     dcc_user_pong(time_,msg,origin_bot);
03653                     s_msg_id i;
03654                     i.id=id;
03655                     i.time=(my_time_t)time(NULL);
03656                     msg_disp_ids.push_back(i);
03657                 }
03658                 msg="";
03659             }
03660             if(strstr(m,"\x01" "BROADCAST_PONG\x02 VERSION ")==m) {
03661                 msg=m;
03662                 if(msg.find(" ",0)!=string::npos)
03663                     msg.erase(0,msg.find(" ",0)+1);
03664                 if(msg.find(" ",0)!=string::npos)
03665                     msg.erase(0,msg.find(" ",0)+1);
03666                 string user=msg;
03667                 if(user.find(" ",0)!=string::npos)
03668                     user.erase(user.find(" ",0),user.length()-user.find(" ",0));
03669                 if(msg.find(" ",0)!=string::npos)
03670                     msg.erase(0,msg.find(" ",0)+1);
03671 
03672                 int ctx=0;
03673                 string v1, v2, v3;
03674                 for(unsigned i1=0; i1<msg.length(); i1++) {
03675                     if(msg[i1]==0x20) {
03676                         ctx++;
03677                         continue;
03678                     }
03679                     if(ctx==0) {
03680                         v1+=(string)""+msg[i1];
03681                         continue;
03682                     }
03683                     if(ctx==1) {
03684                         v2+=(string)""+msg[i1];
03685                         continue;
03686                     }
03687                     if(ctx>=2) {
03688                         v3+=(string)""+msg[i1];
03689                         continue;
03690                     }
03691                 }
03692 
03693                 if(!botnet_query_disp_id(id)) {
03694                     dcc_user_pong(user,origin_bot,v1,v2,v3);
03695                     s_msg_id i;
03696                     i.id=id;
03697                     i.time=(my_time_t)time(NULL);
03698                     msg_disp_ids.push_back(i);
03699                 }
03700                 msg="";
03701             }
03702             if(strstr(m,"\x01" "BROADCAST_ADMIN_MESSAGE\x01 ")==m) {
03703                 msg=m;
03704                 if(msg.find(" ",0)!=string::npos)
03705                     msg.erase(0,msg.find(" ",0)+1);
03706 
03707                 string reserved1=msg;
03708                 if(msg.find(" ",0)!=string::npos)
03709                     msg.erase(0,msg.find(" ",0)+1);
03710                 if(reserved1.find(" ",0)!=string::npos)
03711                     reserved1.erase(reserved1.find(" ",0),reserved1.length()-reserved1.find(" ",0));
03712 
03713                 string reserved2=msg;
03714                 if(msg.find(" ",0)!=string::npos)
03715                     msg.erase(0,msg.find(" ",0)+1);
03716                 if(reserved2.find(" ",0)!=string::npos)
03717                     reserved2.erase(reserved2.find(" ",0),reserved2.length()-reserved2.find(" ",0));
03718 
03719                 string dest_bot=msg;
03720                 if(msg.find(" ",0)!=string::npos)
03721                     msg.erase(0,msg.find(" ",0)+1);
03722                 if(dest_bot.find(" ",0)!=string::npos)
03723                     dest_bot.erase(dest_bot.find(" ",0),dest_bot.length()-dest_bot.find(" ",0));
03724 
03725                 string dest_user=msg;
03726                 if(msg.find(" ",0)!=string::npos)
03727                     msg.erase(0,msg.find(" ",0)+1);
03728                 if(dest_user.find(" ",0)!=string::npos)
03729                     dest_user.erase(dest_user.find(" ",0),dest_user.length()-dest_user.find(" ",0));
03730 
03731                 if(!match((char*)dest_bot.c_str(),botnet_botname))
03732                     if(!botnet_query_disp_id(id)) {
03733                         dcc_broadcast(dest_user,msg,u,dest_bot);
03734                         s_msg_id i;
03735                         i.id=id;
03736                         i.time=(my_time_t)time(NULL);
03737                         msg_disp_ids.push_back(i);
03738                     }
03739                 
03740                 msg="";
03741             }
03742         } else {
03743             if(cmd->command_data.cmd_partyline_1.msg) {
03744                 msg="<";
03745                 msg+=u;
03746                 msg+="@";
03747                 msg+=origin_bot;
03748                 msg+="> ";
03749                 msg+=m;
03750             }
03751             if(cmd->command_data.cmd_partyline_1.join) {
03752                 msg=u;
03753                 msg+="@";
03754                 msg+=origin_bot;
03755                 msg+=" has joined channel ";
03756                 msg+=ch;
03757             }
03758             if(cmd->command_data.cmd_partyline_1.leave) {
03759                 msg=u;
03760                 msg+="@";
03761                 msg+=origin_bot;
03762                 msg+=" has left channel ";
03763                 msg+=ch;
03764             }
03765 
03766             if(!botnet_query_disp_id(cmd->command_data.cmd_partyline_1.id)) {
03767                 s_msg_id i;
03768                 i.id=id;
03769                 i.time=(my_time_t)time(NULL);
03770                 msg_disp_ids.push_back(i);
03771             } else {
03772                 msg="";
03773             }
03774         }
03775         delete[] u;
03776         delete[] m;
03777     }
03778     if(cmd->command==CMD_PARTYLINE_USER_1) {
03779         uint32 id=cmd->command_data.cmd_partyline_user_1.id;
03780 
03781         char* u=new char[sizeof(cmd->command_data.cmd_partyline_user_1.user)+1];
03782         u[sizeof(cmd->command_data.cmd_partyline_user_1.user)]=0;
03783         strncpy(u,cmd->command_data.cmd_partyline_user_1.user,sizeof(cmd->command_data.cmd_partyline_user_1.user));
03784 
03785         ch=new char[sizeof(cmd->command_data.cmd_partyline_user_1.channel)+1];
03786         ch[sizeof(cmd->command_data.cmd_partyline_user_1.channel)]=0;
03787         strncpy(ch,cmd->command_data.cmd_partyline_user_1.channel,sizeof(cmd->command_data.cmd_partyline_user_1.channel));
03788 
03789         if(cmd->command_data.cmd_partyline_1.join) {
03790             msg=u;
03791             msg+="@";
03792             msg+=origin_bot;
03793             msg+=" has joined channel ";
03794             msg+=ch;
03795             msg+=" (after botnet-split)";
03796         }
03797 
03798         if(!botnet_query_disp_id(cmd->command_data.cmd_partyline_1.id)) {
03799             s_msg_id i;
03800             i.id=id;
03801             i.time=(my_time_t)time(NULL);
03802             msg_disp_ids.push_back(i);
03803         } else {
03804             msg="";
03805         }
03806 
03807         delete[] u;
03808     }
03809     if(msg.compare("") && ch!=NULL)
03810         dcc_partyline_message(ch,msg);
03811 
03812     delete[] ch;
03813 }

Here is the call graph for this function:

string botnet_partyline_join_channel string  user,
string  channel
 

Called from partyline, when user connected to this bot is joining partline channel.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
user Name of user as in logic.txt
channel Name of partyline channel

Definition at line 8650 of file botnet.cpp.

References s_bot_command::u_commnd_data::s_cmd_partyline_1::botname, s_partyline_member::botname, botnet_botname, botnet_channels, botnet_get_unique_id(), botnet_partyline_event(), botnet_send_command(), bots, s_bot_command::u_commnd_data::s_cmd_partyline_1::channel, s_botnet_channel::channel_name, CMD_PARTYLINE_1, s_bot_command::u_commnd_data::cmd_partyline_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::hard_clear(), s_bot_command::u_commnd_data::s_cmd_partyline_1::id, s_bot_command::u_commnd_data::s_cmd_partyline_1::join, s_bot_command::u_commnd_data::s_cmd_partyline_1::leave, s_bot_command::u_commnd_data::s_cmd_partyline_1::msg, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_bot_command::size, s_bot_command::u_commnd_data::s_cmd_partyline_1::user, s_partyline_member::user, and s_bot_command::version.

Referenced by dcc_loop().

08651 {
08652     s_bot_command* c=new s_bot_command;
08653     c->hard_clear();
08654     c->packet_type=PACKET_TYPE_COMMAND;
08655     c->size=sizeof(c);
08656     c->version=1;
08657     c->command=CMD_PARTYLINE_1;
08658 
08659     c->command_data.cmd_partyline_1.id=botnet_get_unique_id();
08660 
08661     c->command_data.cmd_partyline_1.msg=false;
08662     c->command_data.cmd_partyline_1.join=true;
08663     c->command_data.cmd_partyline_1.leave=false;
08664 
08665     int user_size=sizeof(c->command_data.cmd_partyline_1.user);
08666     int ch_size=sizeof(c->command_data.cmd_partyline_1.channel);
08667     int bn_size=sizeof(c->command_data.cmd_partyline_1.botname);
08668     strncpy(c->command_data.cmd_partyline_1.user,user.c_str(),user_size);
08669     strncpy(c->command_data.cmd_partyline_1.channel,channel.c_str(),ch_size);
08670     strncpy(c->command_data.cmd_partyline_1.botname,botnet_botname,bn_size);
08671 
08672     char* ch=new char[ch_size+1];
08673     memset(ch,0,ch_size+1);
08674     strncpy(ch,channel.c_str(),ch_size);
08675     bool got=false;
08676 again:
08677     vector<s_botnet_channel>::iterator i2;
08678     for(i2=botnet_channels.begin(); i2!=botnet_channels.end(); i2++)
08679         if(!(*i2).channel_name.compare(ch)) {
08680             got=true;
08681             break;
08682         }
08683     if(!got) {
08684         s_botnet_channel c;
08685         c.channel_name=ch;
08686         botnet_channels.push_back(c);
08687         goto again;
08688     }
08689     s_partyline_member me;
08690     delete[] ch;
08691     ch=new char[user_size+1];
08692     memset(ch,0,user_size+1);
08693     strncpy(ch,user.c_str(),user_size);
08694     me.user=ch;
08695     delete[] ch;
08696     me.botname=botnet_botname;
08697     (*i2).members.push_back(me);
08698 
08699     bool at_least_one=false;
08700     vector<s_bot*>::iterator i1;
08701     for(i1=bots.begin(); i1!=bots.end(); i1++)
08702         if((*i1)->socket.cmp() && (*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08703             at_least_one=true;
08704             botnet_send_command(*i1,c);
08705         }
08706 
08707     //if(!at_least_one)
08708         botnet_partyline_event(botnet_botname,c);
08709 
08710     string users;
08711     vector<s_partyline_member>::iterator i3;
08712     for(i3=(*i2).members.begin(); i3!=(*i2).members.end(); i3++) {
08713         if(users.compare(""))
08714             users+=", ";
08715         users+=(*i3).user;
08716         users+="@";
08717         users+=(*i3).botname;
08718     }
08719 
08720     delete c;
08721 
08722     return users;
08723 }

Here is the call graph for this function:

void botnet_partyline_leave_channel string  user,
string  channel
 

Called from partyline, when user connected to this bot is leaving partline channel.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
user Name of user as in logic.txt
channel Name of partyline channel

Definition at line 8733 of file botnet.cpp.

References s_bot_command::u_commnd_data::s_cmd_partyline_1::botname, botnet_botname, botnet_channels, botnet_get_unique_id(), botnet_partyline_event(), botnet_send_command(), bots, s_bot_command::u_commnd_data::s_cmd_partyline_1::channel, CMD_PARTYLINE_1, s_bot_command::u_commnd_data::cmd_partyline_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::hard_clear(), s_bot_command::u_commnd_data::s_cmd_partyline_1::id, s_bot_command::u_commnd_data::s_cmd_partyline_1::join, s_bot_command::u_commnd_data::s_cmd_partyline_1::leave, s_bot_command::u_commnd_data::s_cmd_partyline_1::msg, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_bot_command::size, s_bot_command::u_commnd_data::s_cmd_partyline_1::user, and s_bot_command::version.

Referenced by dcc_loop().

08734 {
08735     s_bot_command* c=new s_bot_command;
08736     c->hard_clear();
08737     c->packet_type=PACKET_TYPE_COMMAND;
08738     c->size=sizeof(c);
08739     c->version=1;
08740     c->command=CMD_PARTYLINE_1;
08741 
08742     c->command_data.cmd_partyline_1.id=botnet_get_unique_id();
08743 
08744     c->command_data.cmd_partyline_1.msg=false;
08745     c->command_data.cmd_partyline_1.join=false;
08746     c->command_data.cmd_partyline_1.leave=true;
08747 
08748     int user_size=sizeof(c->command_data.cmd_partyline_1.user);
08749     int ch_size=sizeof(c->command_data.cmd_partyline_1.channel);
08750     int bn_size=sizeof(c->command_data.cmd_partyline_1.botname);
08751     strncpy(c->command_data.cmd_partyline_1.user,user.c_str(),user_size);
08752     strncpy(c->command_data.cmd_partyline_1.channel,channel.c_str(),ch_size);
08753     strncpy(c->command_data.cmd_partyline_1.botname,botnet_botname,bn_size);
08754 
08755     char* ch=new char[ch_size+1];
08756     memset(ch,0,ch_size+1);
08757     strncpy(ch,channel.c_str(),ch_size);
08758     bool got=false;
08759     vector<s_botnet_channel>::iterator i2;
08760     for(i2=botnet_channels.begin(); i2!=botnet_channels.end(); i2++)
08761         if(!(*i2).channel_name.compare(ch)) {
08762             got=true;
08763             break;
08764         }
08765     if(got) {
08766         bool got2=false;
08767         vector<s_partyline_member>::iterator i3;
08768         for(i3=(*i2).members.begin(); i3!=(*i2).members.end(); i3++)
08769             if(!(*i3).user.compare(user) && !(*i3).botname.compare(botnet_botname)) {
08770                 got2=true;
08771                 break;
08772             }
08773         if(got2)
08774             (*i2).members.erase(i3);
08775         if((*i2).members.empty())
08776             botnet_channels.erase(i2);
08777     }
08778 
08779     bool at_least_one=false;
08780     vector<s_bot*>::iterator i1;
08781     for(i1=bots.begin(); i1!=bots.end(); i1++)
08782         if((*i1)->socket.cmp() && (*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08783             at_least_one=true;
08784             botnet_send_command(*i1,c);
08785         }
08786 
08787     //if(!at_least_one)
08788         botnet_partyline_event(botnet_botname,c);
08789 
08790     delete c;
08791 }

Here is the call graph for this function:

void botnet_partyline_message string  user,
string  channel,
string  msg,
uint32  id
 

Called from partyline, when user connected to this bot is writing a message to partline channel.

Author:
VooDooMan
Version:
2
Date:
2004
Parameters:
user Name of user as in logic.txt
channel Name of partyline channel
msg Message
id ID of message to be used

Definition at line 8817 of file botnet.cpp.

References s_bot_command::u_commnd_data::s_cmd_partyline_1::botname, botnet_botname, botnet_partyline_event(), botnet_send_command(), bots, s_bot_command::u_commnd_data::s_cmd_partyline_1::channel, s_bot_command::u_commnd_data::cmd_partyline_1, CMD_PARTYLINE_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::hard_clear(), s_bot_command::u_commnd_data::s_cmd_partyline_1::id, s_msg_id::id, s_bot_command::u_commnd_data::s_cmd_partyline_1::join, s_bot_command::u_commnd_data::s_cmd_partyline_1::leave, s_bot_command::u_commnd_data::s_cmd_partyline_1::message, s_bot_command::u_commnd_data::s_cmd_partyline_1::msg, msg_ids, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_bot_command::size, s_msg_id::time, s_bot_command::u_commnd_data::s_cmd_partyline_1::user, and s_bot_command::version.

Referenced by botnet_admin_msg(), botnet_partyline_event(), botnet_partyline_message(), and dcc_loop().

08818 {
08819     {
08820         vector<s_msg_id>::iterator i1;
08821         bool got=false;
08822         for(i1=msg_ids.begin(); i1!=msg_ids.end(); i1++)
08823             if((*i1).id==id) {
08824                 got=true;
08825                 break;
08826             }
08827         if(!got) {
08828             s_msg_id i;
08829             i.id=id;
08830             i.time=(my_time_t)time(NULL);
08831             msg_ids.push_back(i);
08832         }
08833     }
08834 
08835     s_bot_command* c=new s_bot_command;
08836     c->hard_clear();
08837     c->packet_type=PACKET_TYPE_COMMAND;
08838     c->size=sizeof(c);
08839     c->version=1;
08840     c->command=CMD_PARTYLINE_1;
08841 
08842     c->command_data.cmd_partyline_1.id=id;
08843 
08844     c->command_data.cmd_partyline_1.msg=true;
08845     c->command_data.cmd_partyline_1.join=false;
08846     c->command_data.cmd_partyline_1.leave=false;
08847 
08848     int user_size=sizeof(c->command_data.cmd_partyline_1.user);
08849     int msg_size=sizeof(c->command_data.cmd_partyline_1.message);
08850     int ch_size=sizeof(c->command_data.cmd_partyline_1.channel);
08851     int bn_size=sizeof(c->command_data.cmd_partyline_1.botname);
08852     strncpy(c->command_data.cmd_partyline_1.user,user.c_str(),user_size);
08853     strncpy(c->command_data.cmd_partyline_1.channel,channel.c_str(),ch_size);
08854     strncpy(c->command_data.cmd_partyline_1.message,msg.c_str(),msg_size);
08855     strncpy(c->command_data.cmd_partyline_1.botname,botnet_botname,bn_size);
08856 
08857     bool at_least_one=false;
08858     vector<s_bot*>::iterator i1;
08859     for(i1=bots.begin(); i1!=bots.end(); i1++)
08860         if((*i1)->socket.cmp() && (*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08861             at_least_one=true;
08862             botnet_send_command(*i1,c);
08863         }
08864 
08865     //if(!at_least_one)
08866         botnet_partyline_event(botnet_botname,c);
08867 
08868     delete c;
08869 }

Here is the call graph for this function:

void botnet_push_chan s_bot bot,
s_channel_def chd
 

Pushes channel definition to the remote bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Informations about remote connected bot
chd Channel definition

Definition at line 3401 of file botnet.cpp.

References s_channel_def::allow_dynamic, s_bot::botname, botnet_botname, botnet_send_command(), s_channel_def::channel_name, CMD_REPL_CHDEF_01_1, s_bot_command::u_commnd_data::cmd_repl_chdef_01_1, s_bot_command::u_commnd_data::cmd_repl_chdef_02_1, CMD_REPL_CHDEF_02_1, s_bot_command::u_commnd_data::cmd_repl_chdef_03_1, CMD_REPL_CHDEF_03_1, s_bot_command::u_commnd_data::cmd_repl_chdef_04_1, CMD_REPL_CHDEF_04_1, s_bot_command::u_commnd_data::cmd_repl_chdef_05_1, CMD_REPL_CHDEF_05_1, s_bot_command::u_commnd_data::cmd_repl_chdef_06_8, CMD_REPL_CHDEF_06_8, s_bot_command::u_commnd_data::cmd_repl_chdef_99_1, CMD_REPL_CHDEF_99_1, s_bot_command::command, s_bot_command::command_data, s_channel_def::dynamic_bans, s_channel_def::dynamic_minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::dynamic_minus_modes, s_channel_def::dynamic_plus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::dynamic_plus_modes, s_channel_def::dynbans_editors, s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::group, s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1::group, s_channel_def::groups, s_bot_command::hard_clear(), s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::last_changed, s_channel_def::last_changed, log_botnet(), log_botnet_debug(), logic_on_internal_event(), s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::mask, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_chdef_99_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_05_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_02_1::name, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::name, s_channel_def::on_ctcp, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_ctcp, s_channel_def::on_dynamic_ban, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_dynamic_ban, s_channel_def::on_ircop, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_ircop, s_channel_def::on_key, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_key, s_channel_def::on_limit, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_limit, s_channel_def::on_mode, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_mode, s_channel_def::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_notice, s_channel_def::on_part, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_part, s_channel_def::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_privmsg, s_channel_def::on_server_msg, s_bot_command::u_commnd_data::s_cmd_repl_chdef_06_8::on_server_msg, s_channel_def::on_topic, s_bot_command::u_commnd_data::s_cmd_repl_chdef_01_1::on_topic, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_bot_command::u_commnd_data::s_cmd_repl_chdef_03_1::plus_modes, PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, s_bot_command::u_commnd_data::s_cmd_repl_chdef_04_1::reason, s_bot_command::size, stats_botnet_chandef_pushed(), s_bot::supported_proto_version, and s_bot_command::version.

Referenced by botnet_loop().

03402 {
03403     stats_botnet_chandef_pushed();
03404 
03405     if(chd.last_changed==0)
03406         time(&chd.last_changed);
03407 
03408     s_bot_command* c=new s_bot_command;
03409     int name_size=sizeof(c->command_data.cmd_repl_chdef_01_1.name);
03410     char* name=new char[name_size];
03411     memset(name,0,name_size);
03412     strncpy(name,chd.channel_name.c_str(),name_size);
03413 
03414     {
03415         c->hard_clear();
03416         c->packet_type=PACKET_TYPE_COMMAND;
03417         c->size=sizeof(c);
03418         c->version=1;
03419         c->command=CMD_REPL_CHDEF_01_1;
03420 
03421         c->command_data.cmd_repl_chdef_01_1.last_changed=(my_time_t)chd.last_changed;
03422 
03423         memcpy(c->command_data.cmd_repl_chdef_01_1.name,name,name_size);
03424 
03425         int _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_mode);
03426         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_key))
03427             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_key);
03428         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_limit))
03429             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_limit);
03430         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_topic))
03431             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_topic);
03432         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_ircop))
03433             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_ircop);
03434         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_ctcp))
03435             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_ctcp);
03436         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_privmsg))
03437             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_privmsg);
03438         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_notice))
03439             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_notice);
03440         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_part))
03441             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_part);
03442         if(_size>sizeof(c->command_data.cmd_repl_chdef_01_1.on_dynamic_ban))
03443             _size=sizeof(c->command_data.cmd_repl_chdef_01_1.on_dynamic_ban);
03444         int _size2=sizeof(c->command_data.cmd_repl_chdef_01_1.dynamic_plus_modes);
03445         if(_size2>sizeof(c->command_data.cmd_repl_chdef_01_1.dynamic_minus_modes))
03446             _size2=sizeof(c->command_data.cmd_repl_chdef_01_1.dynamic_minus_modes);
03447 
03448         _size--;
03449         _size2--;
03450 
03451         strncpy(c->command_data.cmd_repl_chdef_01_1.on_mode,chd.on_mode.c_str(),_size);
03452         strncpy(c->command_data.cmd_repl_chdef_01_1.on_key,chd.on_key.c_str(),_size);
03453         strncpy(c->command_data.cmd_repl_chdef_01_1.on_limit,chd.on_limit.c_str(),_size);
03454         strncpy(c->command_data.cmd_repl_chdef_01_1.on_topic,chd.on_topic.c_str(),_size);
03455         strncpy(c->command_data.cmd_repl_chdef_01_1.on_ircop,chd.on_ircop.c_str(),_size);
03456         strncpy(c->command_data.cmd_repl_chdef_01_1.on_ctcp,chd.on_ctcp.c_str(),_size);
03457         strncpy(c->command_data.cmd_repl_chdef_01_1.on_privmsg,chd.on_privmsg.c_str(),_size);
03458         strncpy(c->command_data.cmd_repl_chdef_01_1.on_notice,chd.on_notice.c_str(),_size);
03459         strncpy(c->command_data.cmd_repl_chdef_01_1.on_part,chd.on_part.c_str(),_size);
03460         strncpy(c->command_data.cmd_repl_chdef_01_1.on_dynamic_ban,chd.on_dynamic_ban.c_str(),_size);
03461 
03462         strncpy(c->command_data.cmd_repl_chdef_01_1.dynamic_plus_modes,chd.dynamic_plus_modes.c_str(),_size2);
03463         strncpy(c->command_data.cmd_repl_chdef_01_1.dynamic_minus_modes,chd.dynamic_minus_modes.c_str(),_size2);
03464 
03465         botnet_send_command(bot,c);
03466     }
03467     {
03468         vector<s_group>::iterator i1;
03469         for(i1=chd.groups.begin(); i1!=chd.groups.end(); i1++) {
03470 
03471             c->hard_clear();
03472             c->packet_type=PACKET_TYPE_COMMAND;
03473             c->size=sizeof(c);
03474             c->version=1;
03475             c->command=CMD_REPL_CHDEF_02_1;
03476 
03477             memcpy(c->command_data.cmd_repl_chdef_02_1.name,name,name_size);
03478 
03479             strncpy(c->command_data.cmd_repl_chdef_02_1.group,(*i1).name.c_str(),sizeof(c->command_data.cmd_repl_chdef_02_1.group)-1);
03480 
03481             botnet_send_command(bot,c);
03482         }
03483     }
03484     {
03485         vector<s_dynamic_rule>::iterator i1;
03486         for(i1=chd.allow_dynamic.begin(); i1!=chd.allow_dynamic.end(); i1++) {
03487 
03488             c->hard_clear();
03489             c->packet_type=PACKET_TYPE_COMMAND;
03490             c->size=sizeof(c);
03491             c->version=1;
03492             c->command=CMD_REPL_CHDEF_03_1;
03493 
03494             memcpy(c->command_data.cmd_repl_chdef_03_1.name,name,name_size);
03495 
03496             strncpy(c->command_data.cmd_repl_chdef_03_1.group,(*i1).group.c_str(),sizeof(c->command_data.cmd_repl_chdef_03_1.group)-1);
03497             strncpy(c->command_data.cmd_repl_chdef_03_1.plus_modes,(*i1).plus_modes.c_str(),sizeof(c->command_data.cmd_repl_chdef_03_1.plus_modes)-1);
03498             strncpy(c->command_data.cmd_repl_chdef_03_1.minus_modes,(*i1).minus_modes.c_str(),sizeof(c->command_data.cmd_repl_chdef_03_1.minus_modes)-1);
03499 
03500             botnet_send_command(bot,c);
03501         }
03502     }
03503     {
03504         map<string,string>::iterator i1;
03505         for(i1=chd.dynamic_bans.begin(); i1!=chd.dynamic_bans.end(); i1++) {
03506 
03507             c->hard_clear();
03508             c->packet_type=PACKET_TYPE_COMMAND;
03509             c->size=sizeof(c);
03510             c->version=1;
03511             c->command=CMD_REPL_CHDEF_04_1;
03512 
03513             memcpy(c->command_data.cmd_repl_chdef_04_1.name,name,name_size);
03514 
03515             strncpy(c->command_data.cmd_repl_chdef_04_1.mask,(*i1).first.c_str(),sizeof(c->command_data.cmd_repl_chdef_04_1.mask)-1);
03516             strncpy(c->command_data.cmd_repl_chdef_04_1.reason,(*i1).second.c_str(),sizeof(c->command_data.cmd_repl_chdef_04_1.reason)-1);
03517 
03518             botnet_send_command(bot,c);
03519         }
03520     }
03521     {
03522         vector<string>::iterator i1;
03523         for(i1=chd.dynbans_editors.begin(); i1!=chd.dynbans_editors.end(); i1++) {
03524 
03525             c->hard_clear();
03526             c->packet_type=PACKET_TYPE_COMMAND;
03527             c->size=sizeof(c);
03528             c->version=1;
03529             c->command=CMD_REPL_CHDEF_05_1;
03530 
03531             memcpy(c->command_data.cmd_repl_chdef_05_1.name,name,name_size);
03532 
03533             strncpy(c->command_data.cmd_repl_chdef_05_1.group,(*i1).c_str(),sizeof(c->command_data.cmd_repl_chdef_05_1.group)-1);
03534 
03535             botnet_send_command(bot,c);
03536         }
03537     }
03538     if(bot->supported_proto_version>=8) {
03539         c->hard_clear();
03540         c->packet_type=PACKET_TYPE_COMMAND;
03541         c->size=sizeof(c);
03542         c->version=8;
03543         c->command=CMD_REPL_CHDEF_06_8;
03544 
03545         memcpy(c->command_data.cmd_repl_chdef_06_8.name,name,name_size);
03546 
03547         strncpy(c->command_data.cmd_repl_chdef_06_8.on_server_msg,chd.on_server_msg.c_str(),sizeof(c->command_data.cmd_repl_chdef_06_8.on_server_msg)-1);
03548 
03549         botnet_send_command(bot,c);
03550     }
03551     {
03552         c->hard_clear();
03553         c->packet_type=PACKET_TYPE_COMMAND;
03554         c->size=sizeof(c);
03555         c->version=1;
03556         c->command=CMD_REPL_CHDEF_99_1;
03557 
03558         memcpy(c->command_data.cmd_repl_chdef_99_1.name,name,name_size);
03559 
03560         botnet_send_command(bot,c);
03561     }
03562 
03563     delete c;
03564 
03565     string d="replication: PUSH of object ";
03566     d+="(channel) ";
03567     d+=chd.channel_name;
03568     log_botnet_debug(botnet_botname,bot->botname.c_str(),-1,-1,d.c_str());
03569     log_botnet(botnet_botname,bot->botname.c_str(),d.c_str());
03570 
03571     {
03572         string obj_type="channel";
03573         string reason="OK";
03574         string obj=chd.channel_name;
03575 
03576         logic_on_internal_event("@botnet_replication@",bot->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PUSH");
03577     }
03578 }

Here is the call graph for this function:

void botnet_push_proc s_bot bot,
s_procedure p
 

Pushes the procedure to remote bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Remote bot's data
p Procedure to push

Definition at line 3325 of file botnet.cpp.

References s_bot::botname, botnet_botname, botnet_send_command(), CMD_PROC_1, s_bot_command::u_commnd_data::cmd_proc_1, CMD_PROC_END_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::hard_clear(), s_bot_command::u_commnd_data::s_cmd_proc_1::init, init, s_bot_command::u_commnd_data::s_cmd_proc_1::last_changed, s_procedure::last_changed, s_bot::last_proc_push, s_bot_command::u_commnd_data::s_cmd_proc_1::line, log_botnet(), log_botnet_debug(), logic_list_proc(), logic_on_internal_event(), s_bot_command::u_commnd_data::s_cmd_proc_1::name, s_procedure::name, s_bot_command::packet_type, PACKET_TYPE_COMMAND, PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, s_bot_command::size, stats_botnet_proc_pushed(), and s_bot_command::version.

Referenced by botnet_loop().

03326 {
03327     bot->last_proc_push=time(NULL);
03328 
03329     stats_botnet_proc_pushed();
03330 
03331     if(p.last_changed==0)
03332         time(&p.last_changed);
03333 
03334     list<string> commands;
03335     string decl;
03336     vector<string> groups;
03337     logic_list_proc(p.name,commands,decl,groups);
03338 
03339     s_bot_command* c=new s_bot_command;
03340     int name_size=sizeof(c->command_data.cmd_proc_1.name);
03341     char* name=new char[name_size];
03342     memset(name,0,name_size);
03343     strncpy(name,p.name.c_str(),name_size);
03344     bool init=true;
03345     list<string>::iterator i1;
03346     for(i1=commands.begin(); i1!=commands.end(); i1++) {
03347         c->hard_clear();
03348         c->packet_type=PACKET_TYPE_COMMAND;
03349         c->size=sizeof(c);
03350         c->version=1;
03351         c->command=CMD_PROC_1;
03352 
03353         c->command_data.cmd_proc_1.last_changed=(my_time_t)p.last_changed;
03354 
03355         memcpy(c->command_data.cmd_proc_1.name,name,name_size);
03356 
03357         c->command_data.cmd_proc_1.init=init;
03358         init=false;
03359 
03360         if((*i1).length()<sizeof(c->command_data.cmd_proc_1.line))
03361             strcpy(c->command_data.cmd_proc_1.line,(*i1).c_str());
03362 
03363         botnet_send_command(bot,c);
03364     }
03365 
03366     c->hard_clear();
03367     c->packet_type=PACKET_TYPE_COMMAND;
03368     c->size=sizeof(c);
03369     c->version=1;
03370     c->command=CMD_PROC_END_1;
03371 
03372     memcpy(c->command_data.cmd_proc_1.name,name,name_size);
03373 
03374     botnet_send_command(bot,c);
03375 
03376     delete c;
03377 
03378     string d="replication: PUSH of object ";
03379     d+="(procedure) ";
03380     d+=p.name;
03381     log_botnet_debug(botnet_botname,bot->botname.c_str(),-1,-1,d.c_str());
03382     log_botnet(botnet_botname,bot->botname.c_str(),d.c_str());
03383 
03384     {
03385         string obj_type="procedure";
03386         string reason="OK";
03387         string obj=p.name;
03388 
03389         logic_on_internal_event("@botnet_replication@",bot->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PUSH");
03390     }
03391 }

Here is the call graph for this function:

void botnet_push_prv s_bot bot,
s_private prv
 

Pushes the private query definition to remote bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Remote bot's data
prv Private definition to push

Definition at line 2501 of file botnet.cpp.

References s_bot::botname, botnet_botname, botnet_send_command(), s_bot_command::u_commnd_data::cmd_repl_prv_01_1, CMD_REPL_PRV_01_1, CMD_REPL_PRV_02_1, s_bot_command::u_commnd_data::cmd_repl_prv_02_1, s_bot_command::u_commnd_data::cmd_repl_prv_03_1, CMD_REPL_PRV_03_1, s_bot_command::u_commnd_data::cmd_repl_prv_04_7, CMD_REPL_PRV_04_7, s_bot_command::u_commnd_data::cmd_repl_prv_05_8, CMD_REPL_PRV_05_8, s_bot_command::u_commnd_data::cmd_repl_prv_06_11, CMD_REPL_PRV_06_11, CMD_REPL_PRV_99_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::u_commnd_data::s_cmd_repl_prv_02_1::group, s_private::groups, s_bot_command::hard_clear(), s_bot_command::u_commnd_data::s_cmd_repl_prv_01_1::last_changed, s_private::last_changed, log_botnet(), log_botnet_debug(), logic_on_internal_event(), s_private::on_broadcast, s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8::on_broadcast, s_private::on_ctcp, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_ctcp, s_private::on_filesys_got_new, s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7::on_filesys_got_new, s_private::on_fnc, s_bot_command::u_commnd_data::s_cmd_repl_prv_04_7::on_fnc, s_private::on_internal_event, s_bot_command::u_commnd_data::s_cmd_repl_prv_06_11::on_internal_event, s_private::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_notice, s_private::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_prv_03_1::on_privmsg, s_private::on_server_msg, s_bot_command::u_commnd_data::s_cmd_repl_prv_05_8::on_server_msg, s_bot_command::packet_type, PACKET_TYPE_COMMAND, PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, s_bot_command::size, stats_botnet_private_pushed(), s_bot::supported_proto_version, and s_bot_command::version.

Referenced by botnet_loop().

02502 {
02503     stats_botnet_private_pushed();
02504 
02505     if(r_private.last_changed==0)
02506         time(&r_private.last_changed);
02507 
02508     s_bot_command* c=new s_bot_command;
02509     {
02510         c->hard_clear();
02511         c->packet_type=PACKET_TYPE_COMMAND;
02512         c->size=sizeof(c);
02513         c->version=1;
02514         c->command=CMD_REPL_PRV_01_1;
02515 
02516         c->command_data.cmd_repl_prv_01_1.last_changed=(my_time_t)prv.last_changed;
02517         botnet_send_command(bot,c);
02518     }
02519 
02520     {
02521         int data_size=sizeof(c->command_data.cmd_repl_prv_02_1.group); // !!!
02522         char* data=new char[data_size+1];
02523 
02524         vector<s_group>::iterator i2;
02525         for(i2=prv.groups.begin(); i2!=prv.groups.end(); i2++) { // !!!
02526             c->hard_clear();
02527             c->packet_type=PACKET_TYPE_COMMAND;
02528             c->size=sizeof(c);
02529             c->version=1;
02530             c->command=CMD_REPL_PRV_02_1; // !!!
02531 
02532             memset(data,0,data_size);
02533             strncpy(data,(*i2).name.c_str(),data_size);
02534 
02535             memcpy(c->command_data.cmd_repl_prv_02_1.group,data,data_size); // !!!
02536 
02537             botnet_send_command(bot,c);
02538         }
02539         delete[] data;
02540     }
02541 
02542     {
02543         c->hard_clear();
02544         c->packet_type=PACKET_TYPE_COMMAND;
02545         c->size=sizeof(c);
02546         c->version=1;
02547         c->command=CMD_REPL_PRV_03_1;
02548 
02549         int data_size=sizeof(c->command_data.cmd_repl_prv_03_1.on_privmsg); // !!!
02550         if(data_size>sizeof(c->command_data.cmd_repl_prv_03_1.on_notice))
02551             data_size=sizeof(c->command_data.cmd_repl_prv_03_1.on_notice);
02552         if(data_size>sizeof(c->command_data.cmd_repl_prv_03_1.on_ctcp))
02553             data_size=sizeof(c->command_data.cmd_repl_prv_03_1.on_ctcp);
02554         char* data=new char[data_size+1];
02555 
02556         memset(data,0,data_size);
02557         strncpy(data,prv.on_privmsg.c_str(),data_size);
02558         memcpy(c->command_data.cmd_repl_prv_03_1.on_privmsg,data,data_size); // !!!
02559 
02560         memset(data,0,data_size);
02561         strncpy(data,prv.on_notice.c_str(),data_size);
02562         memcpy(c->command_data.cmd_repl_prv_03_1.on_notice,data,data_size); // !!!
02563 
02564         memset(data,0,data_size);
02565         strncpy(data,prv.on_ctcp.c_str(),data_size);
02566         memcpy(c->command_data.cmd_repl_prv_03_1.on_ctcp,data,data_size); // !!!
02567 
02568         delete[] data;
02569 
02570         botnet_send_command(bot,c);
02571     }
02572 
02573     if(bot->supported_proto_version>=7) {
02574         c->hard_clear();
02575         c->packet_type=PACKET_TYPE_COMMAND;
02576         c->size=sizeof(c);
02577         c->version=7;
02578         c->command=CMD_REPL_PRV_04_7;
02579 
02580         int data_size=sizeof(c->command_data.cmd_repl_prv_04_7.on_filesys_got_new); // !!!
02581         if(data_size>sizeof(c->command_data.cmd_repl_prv_04_7.on_filesys_got_new))
02582             data_size=sizeof(c->command_data.cmd_repl_prv_04_7.on_filesys_got_new);
02583         if(data_size>sizeof(c->command_data.cmd_repl_prv_04_7.on_fnc))
02584             data_size=sizeof(c->command_data.cmd_repl_prv_04_7.on_fnc);
02585         char* data=new char[data_size+1];
02586 
02587         memset(data,0,data_size);
02588         strncpy(data,prv.on_filesys_got_new.c_str(),data_size);
02589         memcpy(c->command_data.cmd_repl_prv_04_7.on_filesys_got_new,data,data_size); // !!!
02590 
02591         memset(data,0,data_size);
02592         strncpy(data,prv.on_fnc.c_str(),data_size);
02593         memcpy(c->command_data.cmd_repl_prv_04_7.on_fnc,data,data_size); // !!!
02594 
02595         delete[] data;
02596 
02597         botnet_send_command(bot,c);
02598     }
02599 
02600     if(bot->supported_proto_version>=8) {
02601         c->hard_clear();
02602         c->packet_type=PACKET_TYPE_COMMAND;
02603         c->size=sizeof(c);
02604         c->version=8;
02605         c->command=CMD_REPL_PRV_05_8;
02606 
02607         int data_size=sizeof(c->command_data.cmd_repl_prv_05_8.on_broadcast); // !!!
02608         if(data_size>sizeof(c->command_data.cmd_repl_prv_05_8.on_broadcast))
02609             data_size=sizeof(c->command_data.cmd_repl_prv_05_8.on_broadcast);
02610         if(data_size>sizeof(c->command_data.cmd_repl_prv_05_8.on_server_msg))
02611             data_size=sizeof(c->command_data.cmd_repl_prv_05_8.on_server_msg);
02612         char* data=new char[data_size+1];
02613 
02614         memset(data,0,data_size);
02615         strncpy(data,prv.on_broadcast.c_str(),data_size); // !!!
02616         memcpy(c->command_data.cmd_repl_prv_05_8.on_broadcast,data,data_size); // !!!
02617 
02618         memset(data,0,data_size);
02619         strncpy(data,prv.on_server_msg.c_str(),data_size); // !!!
02620         memcpy(c->command_data.cmd_repl_prv_05_8.on_server_msg,data,data_size); // !!!
02621 
02622         delete[] data;
02623 
02624         botnet_send_command(bot,c);
02625     }
02626 
02627     if(bot->supported_proto_version>=11) {
02628         c->hard_clear();
02629         c->packet_type=PACKET_TYPE_COMMAND;
02630         c->size=sizeof(c);
02631         c->version=8;
02632         c->command=CMD_REPL_PRV_06_11;
02633 
02634         int data_size=sizeof(c->command_data.cmd_repl_prv_06_11.on_internal_event); // !!!
02635         char* data=new char[data_size+1];
02636 
02637         memset(data,0,data_size);
02638         strncpy(data,prv.on_internal_event.c_str(),data_size); // !!!
02639         memcpy(c->command_data.cmd_repl_prv_06_11.on_internal_event,data,data_size); // !!!
02640 
02641         delete[] data;
02642 
02643         botnet_send_command(bot,c);
02644     }
02645 
02646     {
02647         c->hard_clear();
02648         c->packet_type=PACKET_TYPE_COMMAND;
02649         c->size=sizeof(c);
02650         c->version=1;
02651         c->command=CMD_REPL_PRV_99_1;
02652         botnet_send_command(bot,c);
02653     }
02654 
02655     string d="replication: PUSH of object ";
02656     d+="(private)"; // no trailing SPACE!!!
02657     log_botnet_debug(botnet_botname,bot->botname.c_str(),-1,-1,d.c_str());
02658     log_botnet(botnet_botname,bot->botname.c_str(),d.c_str());
02659 
02660     {
02661         string obj_type="private";
02662         string reason="OK";
02663         string obj="private";
02664 
02665         logic_on_internal_event("@botnet_replication@",bot->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PUSH");
02666     }
02667 
02668     delete c;
02669 }

Here is the call graph for this function:

void botnet_push_user s_bot bot,
s_user u
 

Pushes the user to remote bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Remote bot's data
u User to push

Definition at line 2679 of file botnet.cpp.

References s_user::access_grant_apply, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::access_grant_apply, s_user::access_grant_backup, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_backup, s_user::access_grant_can_send_all_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_can_send_all_users, s_user::access_grant_can_send_unknown_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_can_send_unknown_users, s_user::access_grant_channel, s_bot_command::u_commnd_data::s_cmd_repl_user_09_1::access_grant_channel, s_user::access_grant_group, s_bot_command::u_commnd_data::s_cmd_repl_user_07_1::access_grant_group, s_user::access_grant_partyline, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_partyline, s_user::access_grant_plusproc, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_plusproc, s_user::access_grant_plususer, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_plususer, s_bot_command::u_commnd_data::s_cmd_repl_user_06_1::access_grant_proc, s_user::access_grant_procedure, s_user::access_grant_rehash, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_grant_rehash, s_user::access_grant_upgrade, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::access_grant_upgrade, s_user::access_to_apply, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::access_to_apply, s_user::access_to_backup, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_backup, s_user::access_to_can_send_all_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_can_send_all_users, s_user::access_to_can_send_unknown_users, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_can_send_unknown_users, s_user::access_to_channel, s_bot_command::u_commnd_data::s_cmd_repl_user_08_1::access_to_channel, s_user::access_to_group, s_bot_command::u_commnd_data::s_cmd_repl_user_04_1::access_to_group, s_user::access_to_partyline, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_partyline, s_user::access_to_plusproc, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_plusproc, s_user::access_to_plususer, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_plususer, s_user::access_to_proc, s_bot_command::u_commnd_data::s_cmd_repl_user_05_1::access_to_proc, s_user::access_to_rehash, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::access_to_rehash, s_user::access_to_upgrade, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::access_to_upgrade, s_bot_command::u_commnd_data::s_cmd_repl_user_15_1::access_usage_proc, s_user::access_usage_procedure, s_bot::botname, botnet_botname, botnet_send_command(), s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::can_send_unknown_users, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::channel, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::channel, CMD_REPL_USER_01_1, s_bot_command::u_commnd_data::cmd_repl_user_01_1, CMD_REPL_USER_02_1, s_bot_command::u_commnd_data::cmd_repl_user_02_1, CMD_REPL_USER_03_1, s_bot_command::u_commnd_data::cmd_repl_user_03_1, CMD_REPL_USER_04_1, s_bot_command::u_commnd_data::cmd_repl_user_04_1, CMD_REPL_USER_05_1, s_bot_command::u_commnd_data::cmd_repl_user_05_1, CMD_REPL_USER_06_1, s_bot_command::u_commnd_data::cmd_repl_user_06_1, CMD_REPL_USER_07_1, s_bot_command::u_commnd_data::cmd_repl_user_07_1, CMD_REPL_USER_08_1, s_bot_command::u_commnd_data::cmd_repl_user_08_1, CMD_REPL_USER_09_1, s_bot_command::u_commnd_data::cmd_repl_user_09_1, CMD_REPL_USER_10_1, s_bot_command::u_commnd_data::cmd_repl_user_10_1, CMD_REPL_USER_11_1, s_bot_command::u_commnd_data::cmd_repl_user_11_1, CMD_REPL_USER_12_1, s_bot_command::u_commnd_data::cmd_repl_user_12_1, CMD_REPL_USER_13_1, s_bot_command::u_commnd_data::cmd_repl_user_13_1, CMD_REPL_USER_14_1, s_bot_command::u_commnd_data::cmd_repl_user_14_1, CMD_REPL_USER_15_1, s_bot_command::u_commnd_data::cmd_repl_user_15_1, s_bot_command::u_commnd_data::cmd_repl_user_16_5, CMD_REPL_USER_16_5, s_bot_command::u_commnd_data::cmd_repl_user_17_9, CMD_REPL_USER_17_9, s_bot_command::u_commnd_data::cmd_repl_user_99_1, CMD_REPL_USER_99_1, s_bot_command::command, s_bot_command::command_data, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::ctcp_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::ctcp_flood_s, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::dcc_group, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::dcc_host, s_user::dcc_hosts, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::dynamic_minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::dynamic_plus_modes, s_user::fullname, s_bot_command::u_commnd_data::s_cmd_repl_user_03_1::fullname, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::group, s_bot_command::u_commnd_data::s_cmd_repl_user_10_1::group, s_user::groups, s_bot_command::hard_clear(), s_user::host_bot, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::host_bot, s_user::host_unknown, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::host_unknown, s_user::hostmask, s_bot_command::u_commnd_data::s_cmd_repl_user_02_1::hostmask, s_user::is_template, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::is_template, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::join_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::join_flood_s, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::last_changed, s_user::last_changed, s_flood::lines, log_botnet(), log_botnet_debug(), logic_botnet_get_user_channels(), logic_on_internal_event(), s_user::meta, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::meta_key, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::meta_val, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::minus_modes, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::mode_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::mode_flood_s, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::msg_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::msg_flood_s, s_bot_command::u_commnd_data::s_cmd_repl_user_99_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_17_9::name, s_bot_command::u_commnd_data::s_cmd_repl_user_16_5::name, s_bot_command::u_commnd_data::s_cmd_repl_user_15_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_14_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_11_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_10_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_09_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_08_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_07_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_06_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_05_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_04_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_03_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_02_1::name, s_user::name, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::name, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::nick_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::nick_flood_s, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::notice_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::notice_flood_s, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_ban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_banned, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_creator, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_decreator, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_deop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_devoice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_except, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_invite, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_join, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_kick, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_not_in_reop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_not_invited, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_notice, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_op, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_privmsg, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_reop, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_unban, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_unexcept, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_uninvite, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::on_voice, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_user::partyline_msg_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_01_1::partyline_msg_flood, s_bot_command::u_commnd_data::s_cmd_repl_user_13_1::plus_modes, PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::repeat_flood_l, s_bot_command::u_commnd_data::s_cmd_repl_user_12_1::repeat_flood_s, s_flood::seconds, s_bot_command::size, stats_botnet_user_pushed(), s_bot::supported_proto_version, and s_bot_command::version.

Referenced by botnet_loop().

02680 {
02681     stats_botnet_user_pushed();
02682 
02683     if(u.last_changed==0)
02684         time(&u.last_changed);
02685 
02686     s_bot_command* c=new s_bot_command;
02687     int name_size=sizeof(c->command_data.cmd_repl_user_01_1.name);
02688     char* name=new char[name_size];
02689     memset(name,0,name_size);
02690     strncpy(name,u.name.c_str(),name_size);
02691     {
02692         c->hard_clear();
02693         c->packet_type=PACKET_TYPE_COMMAND;
02694         c->size=sizeof(c);
02695         c->version=1;
02696         c->command=CMD_REPL_USER_01_1;
02697 
02698         memcpy(c->command_data.cmd_repl_user_01_1.name,name,name_size);
02699 
02700         c->command_data.cmd_repl_user_01_1.host_unknown=u.host_unknown;
02701         c->command_data.cmd_repl_user_01_1.host_bot=u.host_bot;
02702         c->command_data.cmd_repl_user_01_1.is_template=u.is_template;
02703         c->command_data.cmd_repl_user_01_1.access_grant_partyline=u.access_grant_partyline;
02704         c->command_data.cmd_repl_user_01_1.access_to_backup=u.access_to_backup;
02705         c->command_data.cmd_repl_user_01_1.access_grant_backup=u.access_grant_backup;
02706         c->command_data.cmd_repl_user_01_1.access_to_rehash=u.access_to_rehash;
02707         c->command_data.cmd_repl_user_01_1.access_grant_rehash=u.access_grant_rehash;
02708 
02709         c->command_data.cmd_repl_user_01_1.access_to_plususer=u.access_to_plususer;
02710         c->command_data.cmd_repl_user_01_1.access_grant_plususer=u.access_grant_plususer;
02711         c->command_data.cmd_repl_user_01_1.access_to_plusproc=u.access_to_plusproc;
02712         c->command_data.cmd_repl_user_01_1.access_grant_plusproc=u.access_grant_plusproc;
02713 
02714         c->command_data.cmd_repl_user_01_1.access_to_partyline=u.access_to_partyline;
02715         c->command_data.cmd_repl_user_01_1.partyline_msg_flood.lines=u.partyline_msg_flood.lines;
02716         c->command_data.cmd_repl_user_01_1.partyline_msg_flood.seconds=u.partyline_msg_flood.seconds;
02717         c->command_data.cmd_repl_user_01_1.last_changed=(my_time_t)u.last_changed;
02718 
02719         c->command_data.cmd_repl_user_01_1.access_to_can_send_all_users=u.access_to_can_send_all_users;
02720         c->command_data.cmd_repl_user_01_1.access_grant_can_send_all_users=u.access_grant_can_send_all_users;
02721 
02722         c->command_data.cmd_repl_user_01_1.access_to_can_send_unknown_users=u.access_to_can_send_unknown_users;
02723         c->command_data.cmd_repl_user_01_1.access_grant_can_send_unknown_users=u.access_grant_can_send_unknown_users;
02724 
02725         botnet_send_command(bot,c);
02726     }
02727     {
02728         int data_size=sizeof(c->command_data.cmd_repl_user_02_1.hostmask); // !!!
02729         char* data=new char[data_size+1];
02730 
02731         vector<string>::iterator i2;
02732         for(i2=u.hostmask.begin(); i2!=u.hostmask.end(); i2++) { // !!!
02733             c->hard_clear();
02734             c->packet_type=PACKET_TYPE_COMMAND;
02735             c->size=sizeof(c);
02736             c->version=1;
02737             c->command=CMD_REPL_USER_02_1; // !!!
02738 
02739             memcpy(c->command_data.cmd_repl_user_02_1.name,name,name_size); // !!!
02740 
02741             memset(data,0,data_size);
02742             strncpy(data,(*i2).c_str(),data_size);
02743 
02744             memcpy(c->command_data.cmd_repl_user_02_1.hostmask,data,name_size); // !!!
02745 
02746             botnet_send_command(bot,c);
02747         }
02748         delete[] data;
02749     }
02750     {
02751         int data_size=sizeof(c->command_data.cmd_repl_user_03_1.fullname); // !!!
02752         char* data=new char[data_size+1];
02753 
02754         vector<string>::iterator i2;
02755         for(i2=u.fullname.begin(); i2!=u.fullname.end(); i2++) { // !!!
02756             c->hard_clear();
02757             c->packet_type=PACKET_TYPE_COMMAND;
02758             c->size=sizeof(c);
02759             c->version=1;
02760             c->command=CMD_REPL_USER_03_1; // !!!
02761 
02762             memcpy(c->command_data.cmd_repl_user_03_1.name,name,name_size); // !!!
02763 
02764             memset(data,0,data_size);
02765             strncpy(data,(*i2).c_str(),data_size);
02766 
02767             memcpy(c->command_data.cmd_repl_user_03_1.fullname,data,name_size); // !!!
02768 
02769             botnet_send_command(bot,c);
02770         }
02771         delete[] data;
02772     }
02773     {
02774         int data_size=sizeof(c->command_data.cmd_repl_user_04_1.access_to_group); // !!!
02775         char* data=new char[data_size+1];
02776 
02777         vector<string>::iterator i2;
02778         for(i2=u.access_to_group.begin(); i2!=u.access_to_group.end(); i2++) { // !!!
02779             c->hard_clear();
02780             c->packet_type=PACKET_TYPE_COMMAND;
02781             c->size=sizeof(c);
02782             c->version=1;
02783             c->command=CMD_REPL_USER_04_1; // !!!
02784 
02785             memcpy(c->command_data.cmd_repl_user_04_1.name,name,name_size); // !!!
02786 
02787             memset(data,0,data_size);
02788             strncpy(data,(*i2).c_str(),data_size);
02789 
02790             memcpy(c->command_data.cmd_repl_user_04_1.access_to_group,data,name_size); // !!!
02791 
02792             botnet_send_command(bot,c);
02793         }
02794         delete[] data;
02795     }
02796     {
02797         int data_size=sizeof(c->command_data.cmd_repl_user_05_1.access_to_proc); // !!!
02798         char* data=new char[data_size+1];
02799 
02800         vector<string>::iterator i2;
02801         for(i2=u.access_to_proc.begin(); i2!=u.access_to_proc.end(); i2++) { // !!!
02802             c->hard_clear();
02803             c->packet_type=PACKET_TYPE_COMMAND;
02804             c->size=sizeof(c);
02805             c->version=1;
02806             c->command=CMD_REPL_USER_05_1; // !!!
02807 
02808             memcpy(c->command_data.cmd_repl_user_05_1.name,name,name_size); // !!!
02809 
02810             memset(data,0,data_size);
02811             strncpy(data,(*i2).c_str(),data_size);
02812 
02813             memcpy(c->command_data.cmd_repl_user_05_1.access_to_proc,data,name_size); // !!!
02814 
02815             botnet_send_command(bot,c);
02816         }
02817         delete[] data;
02818     }
02819     {
02820         int data_size=sizeof(c->command_data.cmd_repl_user_06_1.access_grant_proc); // !!!
02821         char* data=new char[data_size+1];
02822 
02823         vector<string>::iterator i2;
02824         for(i2=u.access_grant_procedure.begin(); i2!=u.access_grant_procedure.end(); i2++) { // !!!
02825             c->hard_clear();
02826             c->packet_type=PACKET_TYPE_COMMAND;
02827             c->size=sizeof(c);
02828             c->version=1;
02829             c->command=CMD_REPL_USER_06_1; // !!!
02830 
02831             memcpy(c->command_data.cmd_repl_user_06_1.name,name,name_size); // !!!
02832 
02833             memset(data,0,data_size);
02834             strncpy(data,(*i2).c_str(),data_size);
02835 
02836             memcpy(c->command_data.cmd_repl_user_06_1.access_grant_proc,data,name_size); // !!!
02837 
02838             botnet_send_command(bot,c);
02839         }
02840         delete[] data;
02841     }
02842     {
02843         int data_size=sizeof(c->command_data.cmd_repl_user_07_1.access_grant_group); // !!!
02844         char* data=new char[data_size+1];
02845 
02846         vector<string>::iterator i2;
02847         for(i2=u.access_grant_group.begin(); i2!=u.access_grant_group.end(); i2++) { // !!!
02848             c->hard_clear();
02849             c->packet_type=PACKET_TYPE_COMMAND;
02850             c->size=sizeof(c);
02851             c->version=1;
02852             c->command=CMD_REPL_USER_07_1; // !!!
02853 
02854             memcpy(c->command_data.cmd_repl_user_07_1.name,name,name_size); // !!!
02855 
02856             memset(data,0,data_size);
02857             strncpy(data,(*i2).c_str(),data_size);
02858 
02859             memcpy(c->command_data.cmd_repl_user_07_1.access_grant_group,data,name_size); // !!!
02860 
02861             botnet_send_command(bot,c);
02862         }
02863         delete[] data;
02864     }
02865     {
02866         int data_size=sizeof(c->command_data.cmd_repl_user_08_1.access_to_channel); // !!!
02867         char* data=new char[data_size+1];
02868 
02869         vector<string>::iterator i2;
02870         for(i2=u.access_to_channel.begin(); i2!=u.access_to_channel.end(); i2++) { // !!!
02871             c->hard_clear();
02872             c->packet_type=PACKET_TYPE_COMMAND;
02873             c->size=sizeof(c);
02874             c->version=1;
02875             c->command=CMD_REPL_USER_08_1; // !!!
02876 
02877             memcpy(c->command_data.cmd_repl_user_08_1.name,name,name_size); // !!!
02878 
02879             memset(data,0,data_size);
02880             strncpy(data,(*i2).c_str(),data_size);
02881 
02882             memcpy(c->command_data.cmd_repl_user_08_1.access_to_channel,data,name_size); // !!!
02883 
02884             botnet_send_command(bot,c);
02885         }
02886         delete[] data;
02887     }
02888     {
02889         int data_size=sizeof(c->command_data.cmd_repl_user_09_1.access_grant_channel); // !!!
02890         char* data=new char[data_size+1];
02891 
02892         vector<string>::iterator i2;
02893         for(i2=u.access_grant_channel.begin(); i2!=u.access_grant_channel.end(); i2++) { // !!!
02894             c->hard_clear();
02895             c->packet_type=PACKET_TYPE_COMMAND;
02896             c->size=sizeof(c);
02897             c->version=1;
02898             c->command=CMD_REPL_USER_09_1; // !!!
02899 
02900             memcpy(c->command_data.cmd_repl_user_09_1.name,name,name_size); // !!!
02901 
02902             memset(data,0,data_size);
02903             strncpy(data,(*i2).c_str(),data_size);
02904 
02905             memcpy(c->command_data.cmd_repl_user_09_1.access_grant_channel,data,name_size); // !!!
02906 
02907             botnet_send_command(bot,c);
02908         }
02909         delete[] data;
02910     }
02911     {
02912         int data_size=sizeof(c->command_data.cmd_repl_user_10_1.group); // !!!
02913         char* data=new char[data_size+1];
02914 
02915         vector<s_group>::iterator i2;
02916         for(i2=u.groups.begin(); i2!=u.groups.end(); i2++) { // !!!
02917             c->hard_clear();
02918             c->packet_type=PACKET_TYPE_COMMAND;
02919             c->size=sizeof(c);
02920             c->version=1;
02921             c->command=CMD_REPL_USER_10_1; // !!!
02922 
02923             memcpy(c->command_data.cmd_repl_user_10_1.name,name,name_size); // !!!
02924 
02925             memset(data,0,data_size);
02926             strncpy(data,(*i2).name.c_str(),data_size);
02927 
02928             memcpy(c->command_data.cmd_repl_user_10_1.group,data,name_size); // !!!
02929 
02930             botnet_send_command(bot,c);
02931         }
02932         delete[] data;
02933     }
02934     {
02935         int data_size=sizeof(c->command_data.cmd_repl_user_11_1.dcc_host); // !!!
02936         char* data=new char[data_size+1];
02937 
02938         vector<s_dcc_host>::iterator i2;
02939         for(i2=u.dcc_hosts.begin(); i2!=u.dcc_hosts.end(); i2++) { // !!!
02940             c->hard_clear();
02941             c->packet_type=PACKET_TYPE_COMMAND;
02942             c->size=sizeof(c);
02943             c->version=1;
02944             c->command=CMD_REPL_USER_11_1; // !!!
02945 
02946             memcpy(c->command_data.cmd_repl_user_11_1.name,name,name_size); // !!!
02947 
02948             memset(data,0,data_size);
02949             strncpy(data,(*i2).host.c_str(),data_size);
02950 
02951             c->command_data.cmd_repl_user_11_1.dcc_group=(*i2).group;
02952             memcpy(c->command_data.cmd_repl_user_11_1.dcc_host,data,name_size); // !!!
02953 
02954             botnet_send_command(bot,c);
02955         }
02956         delete[] data;
02957     }
02958     {
02959         int data_size=sizeof(c->command_data.cmd_repl_user_12_1.channel); // !!!
02960         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_deop))
02961             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_deop);
02962         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_ban))
02963             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_ban);
02964         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_unban))
02965             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_unban);
02966         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_kick))
02967             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_kick);
02968         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_op))
02969             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_op);
02970         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_voice))
02971             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_voice);
02972         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_devoice))
02973             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_devoice);
02974         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_creator))
02975             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_creator);
02976         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_decreator))
02977             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_decreator);
02978         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_join))
02979             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_join);
02980         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_banned))
02981             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_banned);
02982         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_flood))
02983             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_flood);
02984         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_privmsg))
02985             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_privmsg);
02986         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_notice))
02987             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_notice);
02988 
02989         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_except))
02990             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_except);
02991         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_unexcept))
02992             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_unexcept);
02993         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_invite))
02994             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_invite);
02995         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_uninvite))
02996             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_uninvite);
02997         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_not_invited))
02998             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_not_invited);
02999         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_not_in_reop))
03000             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_not_in_reop);
03001         if(data_size<sizeof(c->command_data.cmd_repl_user_12_1.on_reop))
03002             data_size=sizeof(c->command_data.cmd_repl_user_12_1.on_reop);
03003 
03004         char* data=new char[data_size+1];
03005 
03006         int dpm_size=sizeof(c->command_data.cmd_repl_user_12_1.dynamic_plus_modes); // !!!
03007         int dmm_size=sizeof(c->command_data.cmd_repl_user_12_1.dynamic_plus_modes); // !!!
03008 
03009         char* plus=new char[dpm_size];
03010         char* minus=new char[dmm_size];
03011 
03012         vector<s_channel> chans;
03013         logic_botnet_get_user_channels(u.name,chans);
03014 
03015         vector<s_channel>::iterator i2;
03016         for(i2=chans.begin(); i2!=chans.end(); i2++) {
03017             c->hard_clear();
03018             c->packet_type=PACKET_TYPE_COMMAND;
03019             c->size=sizeof(c);
03020             c->version=1;
03021             c->command=CMD_REPL_USER_12_1; // !!!
03022 
03023             memcpy(c->command_data.cmd_repl_user_12_1.name,name,name_size); // !!!
03024 
03025             memset(data,0,data_size);
03026             strncpy(data,(*i2).channel_name.c_str(),data_size);
03027             memcpy(c->command_data.cmd_repl_user_12_1.channel,data,sizeof(c->command_data.cmd_repl_user_12_1.channel));
03028 
03029             memset(data,0,data_size);
03030             strncpy(data,(*i2).on_deop.c_str(),data_size);
03031             memcpy(c->command_data.cmd_repl_user_12_1.on_deop,data,sizeof(c->command_data.cmd_repl_user_12_1.on_deop));
03032 
03033             memset(data,0,data_size);
03034             strncpy(data,(*i2).on_ban.c_str(),data_size);
03035             memcpy(c->command_data.cmd_repl_user_12_1.on_ban,data,sizeof(c->command_data.cmd_repl_user_12_1.on_ban));
03036 
03037             memset(data,0,data_size);
03038             strncpy(data,(*i2).on_unban.c_str(),data_size);
03039             memcpy(c->command_data.cmd_repl_user_12_1.on_unban,data,sizeof(c->command_data.cmd_repl_user_12_1.on_unban));
03040 
03041             memset(data,0,data_size);
03042             strncpy(data,(*i2).on_kick.c_str(),data_size);
03043             memcpy(c->command_data.cmd_repl_user_12_1.on_kick,data,sizeof(c->command_data.cmd_repl_user_12_1.on_kick));
03044 
03045             memset(data,0,data_size);
03046             strncpy(data,(*i2).on_op.c_str(),data_size);
03047             memcpy(c->command_data.cmd_repl_user_12_1.on_op,data,sizeof(c->command_data.cmd_repl_user_12_1.on_op));
03048 
03049             memset(data,0,data_size);
03050             strncpy(data,(*i2).on_voice.c_str(),data_size);
03051             memcpy(c->command_data.cmd_repl_user_12_1.on_voice,data,sizeof(c->command_data.cmd_repl_user_12_1.on_voice));
03052 
03053             memset(data,0,data_size);
03054             strncpy(data,(*i2).on_devoice.c_str(),data_size);
03055             memcpy(c->command_data.cmd_repl_user_12_1.on_devoice,data,sizeof(c->command_data.cmd_repl_user_12_1.on_devoice));
03056 
03057             memset(data,0,data_size);
03058             strncpy(data,(*i2).on_creator.c_str(),data_size);
03059             memcpy(c->command_data.cmd_repl_user_12_1.on_creator,data,sizeof(c->command_data.cmd_repl_user_12_1.on_creator));
03060 
03061             memset(data,0,data_size);
03062             strncpy(data,(*i2).on_decreator.c_str(),data_size);
03063             memcpy(c->command_data.cmd_repl_user_12_1.on_decreator,data,sizeof(c->command_data.cmd_repl_user_12_1.on_decreator));
03064 
03065             memset(data,0,data_size);
03066             strncpy(data,(*i2).on_join.c_str(),data_size);
03067             memcpy(c->command_data.cmd_repl_user_12_1.on_join,data,sizeof(c->command_data.cmd_repl_user_12_1.on_join));
03068 
03069             memset(data,0,data_size);
03070             strncpy(data,(*i2).on_banned.c_str(),data_size);
03071             memcpy(c->command_data.cmd_repl_user_12_1.on_banned,data,sizeof(c->command_data.cmd_repl_user_12_1.on_banned));
03072 
03073             memset(data,0,data_size);
03074             strncpy(data,(*i2).on_flood.c_str(),data_size);
03075             memcpy(c->command_data.cmd_repl_user_12_1.on_flood,data,sizeof(c->command_data.cmd_repl_user_12_1.on_flood));
03076 
03077             memset(data,0,data_size);
03078             strncpy(data,(*i2).on_privmsg.c_str(),data_size);
03079             memcpy(c->command_data.cmd_repl_user_12_1.on_privmsg,data,sizeof(c->command_data.cmd_repl_user_12_1.on_privmsg));
03080 
03081             memset(data,0,data_size);
03082             strncpy(data,(*i2).on_notice.c_str(),data_size);
03083             memcpy(c->command_data.cmd_repl_user_12_1.on_notice,data,sizeof(c->command_data.cmd_repl_user_12_1.on_notice));
03084 
03085             memset(data,0,data_size);
03086             strncpy(data,(*i2).on_except.c_str(),data_size);
03087             memcpy(c->command_data.cmd_repl_user_12_1.on_except,data,sizeof(c->command_data.cmd_repl_user_12_1.on_except));
03088 
03089             memset(data,0,data_size);
03090             strncpy(data,(*i2).on_unexcept.c_str(),data_size);
03091             memcpy(c->command_data.cmd_repl_user_12_1.on_unexcept,data,sizeof(c->command_data.cmd_repl_user_12_1.on_unexcept));
03092 
03093             memset(data,0,data_size);
03094             strncpy(data,(*i2).on_invite.c_str(),data_size);
03095             memcpy(c->command_data.cmd_repl_user_12_1.on_invite,data,sizeof(c->command_data.cmd_repl_user_12_1.on_invite));
03096 
03097             memset(data,0,data_size);
03098             strncpy(data,(*i2).on_uninvite.c_str(),data_size);
03099             memcpy(c->command_data.cmd_repl_user_12_1.on_uninvite,data,sizeof(c->command_data.cmd_repl_user_12_1.on_uninvite));
03100 
03101             memset(data,0,data_size);
03102             strncpy(data,(*i2).on_not_invited.c_str(),data_size);
03103             memcpy(c->command_data.cmd_repl_user_12_1.on_not_invited,data,sizeof(c->command_data.cmd_repl_user_12_1.on_not_invited));
03104 
03105             memset(data,0,data_size);
03106             strncpy(data,(*i2).on_not_in_reop.c_str(),data_size);
03107             memcpy(c->command_data.cmd_repl_user_12_1.on_not_in_reop,data,sizeof(c->command_data.cmd_repl_user_12_1.on_not_in_reop));
03108 
03109             memset(data,0,data_size);
03110             strncpy(data,(*i2).on_reop.c_str(),data_size);
03111             memcpy(c->command_data.cmd_repl_user_12_1.on_reop,data,sizeof(c->command_data.cmd_repl_user_12_1.on_reop));
03112 
03113             c->command_data.cmd_repl_user_12_1.msg_flood_l=(*i2).msg_flood.lines;
03114             c->command_data.cmd_repl_user_12_1.msg_flood_s=(my_time_t)(*i2).msg_flood.seconds;
03115 
03116             c->command_data.cmd_repl_user_12_1.notice_flood_l=(*i2).notice_flood.lines;
03117             c->command_data.cmd_repl_user_12_1.notice_flood_s=(my_time_t)(*i2).notice_flood.seconds;
03118 
03119             c->command_data.cmd_repl_user_12_1.repeat_flood_l=(*i2).repeat_flood.lines;
03120             c->command_data.cmd_repl_user_12_1.repeat_flood_s=(my_time_t)(*i2).repeat_flood.seconds;
03121 
03122             c->command_data.cmd_repl_user_12_1.nick_flood_l=(*i2).nick_flood.lines;
03123             c->command_data.cmd_repl_user_12_1.nick_flood_s=(my_time_t)(*i2).nick_flood.seconds;
03124 
03125             c->command_data.cmd_repl_user_12_1.join_flood_l=(*i2).join_flood.lines;
03126             c->command_data.cmd_repl_user_12_1.join_flood_s=(my_time_t)(*i2).join_flood.seconds;
03127 
03128             c->command_data.cmd_repl_user_12_1.mode_flood_l=(*i2).mode_flood.lines;
03129             c->command_data.cmd_repl_user_12_1.mode_flood_s=(my_time_t)(*i2).mode_flood.seconds;
03130 
03131             c->command_data.cmd_repl_user_12_1.ctcp_flood_l=(*i2).ctcp_flood.lines;
03132             c->command_data.cmd_repl_user_12_1.ctcp_flood_s=(my_time_t)(*i2).ctcp_flood.seconds;
03133 
03134             memset(plus,0,dpm_size);
03135             strncpy(plus,(*i2).dynamic_plus_modes.c_str(),dpm_size);
03136             memcpy(c->command_data.cmd_repl_user_12_1.dynamic_plus_modes,data,sizeof(c->command_data.cmd_repl_user_12_1.dynamic_plus_modes));
03137 
03138             memset(minus,0,dmm_size);
03139             strncpy(minus,(*i2).dynamic_minus_modes.c_str(),dmm_size);
03140             memcpy(c->command_data.cmd_repl_user_12_1.dynamic_minus_modes,data,sizeof(c->command_data.cmd_repl_user_12_1.dynamic_minus_modes));
03141 
03142             c->command_data.cmd_repl_user_12_1.can_send_unknown_users=(*i2).can_send_unknown_users;
03143 
03144             botnet_send_command(bot,c);
03145         }
03146         delete[] data;
03147         delete[] plus;
03148         delete[] minus;
03149     }
03150     {
03151         int g_size=sizeof(c->command_data.cmd_repl_user_13_1.group); // !!!
03152         char* g=new char[g_size+1];
03153 
03154         int pm_size=sizeof(c->command_data.cmd_repl_user_13_1.plus_modes); // !!!
03155         char* pm=new char[pm_size+1];
03156 
03157         int mm_size=sizeof(c->command_data.cmd_repl_user_13_1.minus_modes); // !!!
03158         char* mm=new char[mm_size+1];
03159 
03160         int ch_size=sizeof(c->command_data.cmd_repl_user_13_1.channel); // !!!
03161         char* ch=new char[ch_size+1];
03162 
03163         vector<s_channel> chans;
03164         logic_botnet_get_user_channels(u.name,chans);
03165 
03166         vector<s_channel>::iterator i3;
03167         for(i3=chans.begin(); i3!=chans.end(); i3++) {
03168             vector<s_dynamic_rule>::iterator i2;
03169             for(i2=(*i3).allow_dynamic.begin(); i2!=(*i3).allow_dynamic.end(); i2++) { // !!!
03170                 c->hard_clear();
03171                 c->packet_type=PACKET_TYPE_COMMAND;
03172                 c->size=sizeof(c);
03173                 c->version=1;
03174                 c->command=CMD_REPL_USER_13_1; // !!!
03175 
03176                 memcpy(c->command_data.cmd_repl_user_13_1.name,name,name_size); // !!!
03177 
03178                 memset(ch,0,ch_size);
03179                 strncpy(ch,(*i3).channel_name.c_str(),ch_size);
03180                 memcpy(c->command_data.cmd_repl_user_13_1.channel,ch,sizeof(c->command_data.cmd_repl_user_13_1.channel));
03181 
03182                 memset(g,0,g_size);
03183                 strncpy(g,(*i2).group.c_str(),g_size);
03184 
03185                 memset(pm,0,pm_size);
03186                 strncpy(pm,(*i2).plus_modes.c_str(),pm_size);
03187 
03188                 memset(mm,0,mm_size);
03189                 strncpy(mm,(*i2).minus_modes.c_str(),mm_size);
03190 
03191                 memcpy(c->command_data.cmd_repl_user_13_1.group,g,g_size); // !!!
03192                 memcpy(c->command_data.cmd_repl_user_13_1.plus_modes,pm,pm_size); // !!!
03193                 memcpy(c->command_data.cmd_repl_user_13_1.minus_modes,mm,mm_size); // !!!
03194 
03195                 botnet_send_command(bot,c);
03196             }
03197         }
03198         delete[] g;
03199         delete[] pm;
03200         delete[] mm;
03201         delete[] ch;
03202     }
03203 
03204     {
03205         int meta_key_size=sizeof(c->command_data.cmd_repl_user_14_1.meta_key); // !!!
03206         char* k=new char[meta_key_size+1];
03207 
03208         int meta_val_size=sizeof(c->command_data.cmd_repl_user_14_1.meta_val); // !!!
03209         char* v=new char[meta_val_size+1];
03210 
03211         map<string,string>::iterator i3;
03212         for(i3=u.meta.begin(); i3!=u.meta.end(); i3++) {
03213             c->packet_type=PACKET_TYPE_COMMAND;
03214             c->size=sizeof(c);
03215             c->version=1;
03216             c->command=CMD_REPL_USER_14_1; // !!!
03217 
03218             memcpy(c->command_data.cmd_repl_user_14_1.name,name,name_size); // !!!
03219 
03220             memset(k,0,meta_key_size);
03221             strncpy(k,(*i3).first.c_str(),meta_key_size);
03222             memcpy(c->command_data.cmd_repl_user_14_1.meta_key,k,sizeof(c->command_data.cmd_repl_user_14_1.meta_key));
03223 
03224             memset(v,0,meta_val_size);
03225             strncpy(v,(*i3).second.c_str(),meta_val_size);
03226             memcpy(c->command_data.cmd_repl_user_14_1.meta_val,v,sizeof(c->command_data.cmd_repl_user_14_1.meta_val));
03227 
03228             botnet_send_command(bot,c);
03229         }
03230 
03231         delete[] k;
03232         delete[] v;
03233     }
03234 
03235     {
03236         int data_size=sizeof(c->command_data.cmd_repl_user_15_1.access_usage_proc); // !!!
03237         char* data=new char[data_size+1];
03238 
03239         vector<string>::iterator i2;
03240         for(i2=u.access_usage_procedure.begin(); i2!=u.access_usage_procedure.end(); i2++) { // !!!
03241             c->hard_clear();
03242             c->packet_type=PACKET_TYPE_COMMAND;
03243             c->size=sizeof(c);
03244             c->version=1;
03245             c->command=CMD_REPL_USER_15_1; // !!!
03246 
03247             memcpy(c->command_data.cmd_repl_user_15_1.name,name,name_size); // !!!
03248 
03249             memset(data,0,data_size);
03250             strncpy(data,(*i2).c_str(),data_size);
03251 
03252             memcpy(c->command_data.cmd_repl_user_15_1.access_usage_proc,data,name_size); // !!!
03253 
03254             botnet_send_command(bot,c);
03255         }
03256         delete[] data;
03257     }
03258     if(bot->supported_proto_version>=5) {
03259         c->hard_clear();
03260         c->packet_type=PACKET_TYPE_COMMAND;
03261         c->size=sizeof(c);
03262         c->version=5;
03263         c->command=CMD_REPL_USER_16_5;
03264 
03265         memcpy(c->command_data.cmd_repl_user_16_5.name,name,name_size);
03266 
03267         c->command_data.cmd_repl_user_16_5.access_to_upgrade=u.access_to_upgrade;
03268         c->command_data.cmd_repl_user_16_5.access_grant_upgrade=u.access_grant_upgrade;
03269 
03270         botnet_send_command(bot,c);
03271     }
03272     if(bot->supported_proto_version>=9) {
03273         c->hard_clear();
03274         c->packet_type=PACKET_TYPE_COMMAND;
03275         c->size=sizeof(c);
03276         c->version=9;
03277         c->command=CMD_REPL_USER_17_9;
03278 
03279         memcpy(c->command_data.cmd_repl_user_17_9.name,name,name_size);
03280 
03281         c->command_data.cmd_repl_user_17_9.access_to_apply=u.access_to_apply;
03282         c->command_data.cmd_repl_user_17_9.access_grant_apply=u.access_grant_apply;
03283 
03284         botnet_send_command(bot,c);
03285     }
03286 
03287     {
03288         c->hard_clear();
03289         c->packet_type=PACKET_TYPE_COMMAND;
03290         c->size=sizeof(c);
03291         c->version=1;
03292         c->command=CMD_REPL_USER_99_1; // !!!
03293 
03294         memcpy(c->command_data.cmd_repl_user_99_1.name,name,name_size); // !!!
03295 
03296         botnet_send_command(bot,c);
03297     }
03298 
03299     delete[] name;
03300     delete c;
03301 
03302     string d="replication: PUSH of object ";
03303     d+="(user) ";
03304     d+=u.name;
03305     log_botnet_debug(botnet_botname,bot->botname.c_str(),-1,-1,d.c_str());
03306     log_botnet(botnet_botname,bot->botname.c_str(),d.c_str());
03307 
03308     {
03309         string obj_type="user";
03310         string reason="OK";
03311         string obj=u.name;
03312 
03313         logic_on_internal_event("@botnet_replication@",bot->botname,obj_type,obj,reason,PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,d,"PUSH");
03314     }
03315 }

Here is the call graph for this function:

bool botnet_query_disp_id uint32  id  ) 
 

Checks whether we have message ID in vector already (we already displayed this message).

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
id Message ID to test
Return values:
true We got
false We don't got

Definition at line 1548 of file botnet.cpp.

References msg_disp_ids.

Referenced by botnet_partyline_event().

01549 {
01550     vector<s_msg_id>::iterator i1;
01551     for(i1=msg_disp_ids.begin(); i1!=msg_disp_ids.end(); i1++)
01552         if((*i1).id==id)
01553             return true;
01554     return false;
01555 }

int botnet_receive s_bot bot,
int &  packet_type,
s_bot_command cmd,
s_bot_control control
 

Receives command or control packet.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Remote bot's data
packet_type Returns type of packet
cmd If packet_type == PACKET_TYPE_COMMAND, this contains command packet
control If packet_type == PACKET_TYPE_CONTROL, this contains control packet
Returns:
Returns status
Return values:
0 The buffer is empty
1 Got data
3 Got data, but connection closed
4 Don't have data and connection closed
5 Connection should be closed for error

Definition at line 2256 of file botnet.cpp.

References s_bot::botname, botnet_botname, botnet_check_for_buffer_overflow(), s_socket::clear(), s_bot_command::command_data, s_bot::command_receive_buffer, s_bot_control::control_data, s_bot::control_receive_buffer, s_bot_command::flip(), s_bot_control::flip_header(), s_bot_control::flip_rest(), s_bot::flipped, s_bot_control::hard_clear(), s_bot_command::hard_clear(), log_botnet(), log_debug(), s_bot_control::packet_type, PACKET_TYPE_COMMAND, PACKET_TYPE_CONTROL, s_bot::receive_buffer_pos, s_bot::rle_buffer, s_bot::rle_buffer_len, rle_decompress(), s_bot_control::size, s_bot_command::size, sock_close(), sock_read(), s_bot::socket, s_bot::ssl, ssl_client_read(), ssl_close(), s_bot::ssl_connection, and stats_botnet_bytes_received().

Referenced by botnet_loop().

02257 {
02258     int ec=0;
02259     bool closed=false;
02260     size_t len=0;
02261 
02262     if(bot->receive_buffer_pos<4*4) {
02263         bot->flipped=false;
02264         char* data=(char*)&bot->control_receive_buffer;
02265 
02266         if(!bot->ssl_connection) {
02267             len=sock_read(bot->socket,&data[bot->receive_buffer_pos],4*4-bot->receive_buffer_pos,ec,closed);
02268             stats_botnet_bytes_received(len);
02269             if(ec || closed) {
02270                 sock_close(bot->socket);
02271                 bot->socket.clear();
02272                 return 4;
02273             }
02274             bot->receive_buffer_pos+=len;
02275         } else {
02276             len=0;
02277             if(bot->ssl) {
02278                 char err_str[1024];
02279                 if(ssl_client_read(bot->ssl,&(bot->socket),err_str,&data[bot->receive_buffer_pos],4*4-bot->receive_buffer_pos,len)) {
02280                     ssl_close(bot->ssl,&(bot->socket));
02281                     bot->ssl=NULL;
02282                     sock_close(bot->socket);
02283                     bot->socket.clear();
02284                     ec=-1;
02285                     closed=true;
02286                     return 4;
02287                 }
02288                 bot->receive_buffer_pos+=len;
02289             }
02290         }
02291     }
02292 
02293     if(bot->receive_buffer_pos==4*4 && !bot->flipped) {
02294         bot->control_receive_buffer.flip_header();
02295         memcpy(&bot->command_receive_buffer,&bot->control_receive_buffer,4*4);
02296         bot->flipped=true;
02297     }
02298 
02299     if(bot->receive_buffer_pos>=4*4) {
02300         bool control_=false;
02301         bool command_=false;
02302 
02303         control_=bot->control_receive_buffer.packet_type==PACKET_TYPE_CONTROL;
02304         command_=bot->control_receive_buffer.packet_type==PACKET_TYPE_COMMAND;
02305 
02306         // sanity check
02307         if((!control_ && !command_) || bot->command_receive_buffer.size>sizeof(bot->command_receive_buffer.command_data)*2) {
02308             if(bot->ssl) {
02309                 ssl_close(bot->ssl,&(bot->socket));
02310                 bot->ssl=NULL;
02311             }
02312             sock_close(bot->socket);
02313             bot->socket.clear();
02314             return 5;
02315         }
02316 
02317         {
02318             for(;;) {
02319                 size_t partial_data_size=1024;
02320                 char* partial_data=new char[partial_data_size];
02321 
02322                 len=0;
02323                 if(bot->receive_buffer_pos<bot->control_receive_buffer.size+4*4) {
02324                     size_t want_bytes=bot->control_receive_buffer.size-bot->receive_buffer_pos+4*4;
02325                     if(want_bytes>partial_data_size)
02326                         want_bytes=partial_data_size;
02327 
02328                     if(!bot->ssl_connection) {
02329                         len=sock_read(bot->socket,partial_data,want_bytes,ec,closed);
02330                         stats_botnet_bytes_received(len);
02331                     } else {
02332                         char err_str[1024];
02333                         if(ssl_client_read(bot->ssl,&(bot->socket),err_str,partial_data,want_bytes,len)) {
02334                             ssl_close(bot->ssl,&(bot->socket));
02335                             bot->ssl=NULL;
02336                             ec=-1;
02337                             closed=true;
02338                             delete[] partial_data;
02339                             return 4;
02340                         }
02341                         stats_botnet_bytes_received(len);
02342                     }
02343                 }
02344                 if(ec) {
02345                     if(bot->ssl) {
02346                         ssl_close(bot->ssl,&(bot->socket));
02347                         bot->ssl=NULL;
02348                     }
02349                     sock_close(bot->socket);
02350                     bot->socket.clear();
02351                     delete[] partial_data;
02352                     return 4;
02353                 }
02354                 if(bot->rle_buffer==NULL && len!=0) {
02355                     bot->rle_buffer_len=(unsigned int)bot->receive_buffer_pos-4*4+len;
02356                     bot->rle_buffer=(char*)malloc(bot->rle_buffer_len);
02357                     if(!bot->rle_buffer) {
02358                         if(bot->ssl) {
02359                             ssl_close(bot->ssl,&(bot->socket));
02360                             bot->ssl=NULL;
02361                         }
02362                         sock_close(bot->socket);
02363                         bot->socket.clear();
02364                         log_debug("malloc() failed!");
02365                         log_botnet(botnet_botname,bot->botname.c_str(),"malloc() failed!");
02366                         delete[] partial_data;
02367                         return 4;
02368                     }
02369                     memcpy(bot->rle_buffer,partial_data,len);
02370                 } else if(len!=0) {
02371                     bot->rle_buffer=(char*)realloc(bot->rle_buffer,bot->rle_buffer_len+len);
02372                     if(!bot->rle_buffer) {
02373                         if(bot->ssl) {
02374                             ssl_close(bot->ssl,&(bot->socket));
02375                             bot->ssl=NULL;
02376                         }
02377                         sock_close(bot->socket);
02378                         bot->socket.clear();
02379                         log_debug("realloc() failed!");
02380                         log_botnet(botnet_botname,bot->botname.c_str(),"realloc() failed!");
02381                         delete[] partial_data;
02382                         return 4;
02383                     }
02384                     memcpy(&(bot->rle_buffer[bot->rle_buffer_len]),partial_data,len);
02385                     bot->rle_buffer_len+=(unsigned int)len;
02386                 }
02387                 bot->receive_buffer_pos+=len;
02388 
02389                 delete[] partial_data;
02390 
02391                 if(bot->receive_buffer_pos==bot->control_receive_buffer.size+4*4) {
02392                     cmd->hard_clear();
02393                     control->hard_clear();
02394 
02395                     int uncompress=0;
02396                     unsigned char* tmp=new unsigned char[sizeof(cmd->command_data)*2];
02397                     if(control_) {
02398                         uncompress=sizeof(control->control_data);
02399                     }
02400                     if(command_) {
02401                         uncompress=sizeof(cmd->command_data);
02402                     }
02403                     if(uncompress==0) {
02404                         // this should never occur since we tested it before
02405 
02406                         if(bot->ssl) {
02407                             ssl_close(bot->ssl,&(bot->socket));
02408                             bot->ssl=NULL;
02409                         }
02410                         sock_close(bot->socket);
02411                         bot->socket.clear();
02412 
02413                         log_debug("internal error!");
02414                         log_botnet(botnet_botname,bot->botname.c_str(),"internal error!");
02415                         delete[] tmp;
02416                         return 4;
02417                     }
02418                     if(rle_decompress((unsigned char*)bot->rle_buffer,bot->rle_buffer_len,tmp,uncompress)) {
02419                         if(bot->ssl) {
02420                             ssl_close(bot->ssl,&(bot->socket));
02421                             bot->ssl=NULL;
02422                         }
02423                         sock_close(bot->socket);
02424                         bot->socket.clear();
02425 
02426                         delete[] tmp;
02427                         return 5;
02428                     }
02429 
02430                     if(command_) {
02431                         memcpy(cmd,&(bot->command_receive_buffer),4*4);
02432 
02433                         memcpy(&(cmd->command_data),tmp,sizeof(cmd->command_data));
02434                         delete[] tmp;
02435                         tmp=NULL;
02436 
02437                         cmd->flip();
02438 
02439                         if(botnet_check_for_buffer_overflow(*cmd)) {
02440                             log_debug("Buffer overflow detected in commnad packet!");
02441                             log_botnet(botnet_botname,bot->botname.c_str(),"Buffer overflow detected in commnad packet!");
02442                             return 4;
02443                         }
02444 
02445                         packet_type=PACKET_TYPE_COMMAND;
02446                         if(!botnet_check_for_buffer_overflow(*cmd)) {
02447                             if(closed)
02448                                 return 3;
02449                             else
02450                                 return 1;
02451                         } else {
02452                             if(bot->ssl) {
02453                                 ssl_close(bot->ssl,&(bot->socket));
02454                                 bot->ssl=NULL;
02455                             }
02456                             sock_close(bot->socket);
02457                             bot->socket.clear();
02458 
02459                             log_debug("Buffer overflow detected in commnad packet!");
02460                             log_botnet(botnet_botname,bot->botname.c_str(),"Buffer overflow detected in commnad packet!");
02461                             return 4;
02462                         }
02463                     }
02464                     if(control_) {
02465                         memcpy(control,&(bot->control_receive_buffer),4*4);
02466 
02467                         memcpy(&(control->control_data),tmp,sizeof(control->control_data));
02468                         delete[] tmp;
02469                         tmp=NULL;
02470 
02471                         control->flip_rest();
02472 
02473                         packet_type=PACKET_TYPE_CONTROL;
02474                         if(closed)
02475                             return 3;
02476                         else
02477                             return 1;
02478                     }
02479                     if(tmp) {
02480                         delete[] tmp;
02481                         tmp=NULL;
02482                     }
02483                 }
02484                 if(len==0)
02485                     return 0;
02486             }
02487         }
02488     }
02489 
02490     return 0;
02491 }

Here is the call graph for this function:

void botnet_received_data_from_telnet s_socket socket,
string  botname,
char *  buff,
size_t  buff_size,
SSL *  ssl,
string  remote_ip
 

Called when remote bot connects via telnet.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
socket Socket handle of connection
botname Name of remote bot
buff Buffer which can be read
buff_size Size of buffer
ssl SSL descriptor of connection
remote_ip IP address of remote peer

Definition at line 8588 of file botnet.cpp.

References s_bot::auth_ok, s_bot::botip, s_bot::botname, s_bot::botport, bots, s_bot::buff_from_dcc, s_bot::buff_pos_from_dcc, s_bot::buff_size_from_dcc, s_bot::clean, s_bot::clear(), s_socket::clear(), dcc_get_password(), s_bot::got_bytes, s_bot::invoked_from_telnet, s_bot::last_try, s_bot::localip, s_bot::receive_buffer_pos, s_bot::received_bot_auth_1, s_bot::remote_MD5_password, s_bot::remote_pswd_ok, s_bot::sent_bot_auth_1, s_bot::socket, s_bot::ssl, s_bot::ssl_connection, stats_botnet_bytes_received(), stats_botnet_new_connection(), s_bot::unlink_proc, s_bot::unlink_proc_called, and s_bot::was_linked.

Referenced by dcc_loop().

08589 {
08590     stats_botnet_new_connection();
08591     stats_botnet_bytes_received(buff_size);
08592 
08593     vector<s_bot*>::iterator i1;
08594     bool got=false;
08595     for(i1=bots.begin(); i1!=bots.end(); i1++) {
08596         if(!(*i1)->botname.compare(botname))
08597             if((*i1)->socket==socket) {
08598                 got=true;
08599                 break;
08600             }
08601     }
08602     if(!got) {
08603         s_bot* s=new s_bot;
08604         s->clear();
08605         s->clean=false;
08606         s->ssl_connection=ssl?true:false;
08607         s->ssl=ssl;
08608         s->botname="";
08609         s->localip="";
08610         s->botip=remote_ip;
08611         s->botport=0;
08612         s->socket.clear();
08613         s->remote_MD5_password="";
08614         s->sent_bot_auth_1=false;
08615         s->received_bot_auth_1=false;
08616         s->receive_buffer_pos=0;
08617         s->botname=botname;
08618         s->socket=socket;
08619         s->remote_MD5_password=dcc_get_password(botname);
08620         s->buff_size_from_dcc=0;
08621         if(buff_size) {
08622             s->buff_size_from_dcc=buff_size;
08623             if(s->buff_size_from_dcc>sizeof(s->buff_from_dcc))
08624                 s->buff_size_from_dcc=sizeof(s->buff_from_dcc);
08625             memcpy(s->buff_from_dcc,buff,s->buff_size_from_dcc);
08626             s->buff_pos_from_dcc=0;
08627         }
08628 
08629         s->unlink_proc="";
08630         s->unlink_proc_called=true;
08631 
08632         s->got_bytes=0;
08633         s->auth_ok=false;
08634         s->remote_pswd_ok=false;
08635         s->last_try=0x7FFFFFFF;
08636         s->invoked_from_telnet=true;
08637         s->was_linked=false;
08638         bots.push_back(s);
08639     }
08640 }

Here is the call graph for this function:

void botnet_rehash s_bot bot,
string  botname
 

Causes bot to schedule rehash.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Bot handle
botname Name of the remote bot

Definition at line 1612 of file botnet.cpp.

References botnet_last_rehash_request.

Referenced by botnet_loop().

01613 {
01614     botnet_last_rehash_request=time(NULL);
01615 }

string botnet_remote_procedure_call string  botname,
string  proc_name_only,
list< string > &  args
 

Sends to other bot remote procedure call request.

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
botname Name of remote bot
proc_name_only Name of remote procedure only (without full declaration)
args List of arguments
Returns:
Returns string that should be passed to script as result for this command

Definition at line 1629 of file botnet.cpp.

References s_bot_command::u_commnd_data::s_cmd_remote_procedure_call_3::args_array, botnet_send_command(), bots, CMD_REMOTE_PROCEDURE_CALL_3, s_bot_command::u_commnd_data::cmd_remote_procedure_call_3, s_bot_command::command, s_bot_command::command_data, s_bot_command::hard_clear(), index(), s_bot_command::u_commnd_data::s_cmd_remote_procedure_call_3::num_args, s_bot_command::packet_type, PACKET_TYPE_COMMAND, s_bot_command::size, and s_bot_command::version.

Referenced by logic_exec().

01630 {
01631     bool got=false;
01632     vector<s_bot*>::iterator i1;
01633     for(i1=bots.begin(); i1!=bots.end(); i1++)
01634         if(!(*i1)->botname.compare(botname)) {
01635             got=true;
01636             break;
01637         }
01638     if(!got)
01639         return "@not_linked@";
01640     if(!(*i1)->auth_ok || !(*i1)->remote_pswd_ok)
01641         return "@not_linked@";
01642     if((*i1)->supported_proto_version<3)
01643         return "@remote_not_supported@";
01644 
01645     s_bot_command* c=new s_bot_command;
01646     c->hard_clear();
01647     c->packet_type=PACKET_TYPE_COMMAND;
01648     c->size=sizeof(c);
01649     c->version=3;
01650     c->command=CMD_REMOTE_PROCEDURE_CALL_3;
01651 
01652     unsigned int index=0;
01653 
01654     c->command_data.cmd_remote_procedure_call_3.num_args=1; // first "argument" is actually the name of procedure
01655     // +1 == binary zero delimiter/terminator
01656     if(index+proc_name_only.length()+1>=sizeof(c->command_data.cmd_remote_procedure_call_3.args_array)) {
01657         delete c;
01658         return "@args_too_long@";
01659     }
01660     memcpy(&(c->command_data.cmd_remote_procedure_call_3.args_array[index]),proc_name_only.c_str(),proc_name_only.length());
01661     index+=(unsigned int)proc_name_only.length();
01662     c->command_data.cmd_remote_procedure_call_3.args_array[index]=0;
01663     index++;
01664 
01665     list<string>::iterator i2;
01666     for(i2=args.begin(); i2!=args.end(); i2++) {
01667         c->command_data.cmd_remote_procedure_call_3.num_args++;
01668         // +1 == binary zero delimiter/terminator
01669         if(index+(*i2).length()+1>=sizeof(c->command_data.cmd_remote_procedure_call_3.args_array)) {
01670             delete c;
01671             return "@args_too_long@";
01672         }
01673         memcpy(&(c->command_data.cmd_remote_procedure_call_3.args_array[index]),(*i2).c_str(),(*i2).length());
01674         index+=(unsigned int)(*i2).length();
01675         c->command_data.cmd_remote_procedure_call_3.args_array[index]=0;
01676         index++;
01677     }
01678     botnet_send_command(*i1,c);
01679     delete c;
01680 
01681     return "@ok@";
01682 }

Here is the call graph for this function:

bool botnet_send_command s_bot bot,
s_bot_command cmd
 

Sends command to linked bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Bot handle
cmd Command to send
Returns:
True if I/O error occured

Definition at line 1777 of file botnet.cpp.

References s_bot::botname, botnet_botname, s_socket::cmp(), s_bot_command::command_data, s_bot_command::flip(), log_botnet_debug(), log_debug(), log_socket(), rle_compress(), s_bot_command::size, sleep(), sock_error(), sock_send(), s_bot::socket, s_bot::ssl, ssl_close(), s_bot::ssl_connection, ssl_write(), and stats_botnet_bytes_sent().

Referenced by botnet_loop(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), botnet_partyline_message(), botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), and botnet_remote_procedure_call().

01778 {
01779     s_bot_command* data=new s_bot_command;
01780     memcpy(data,cmd,sizeof(*cmd));
01781 
01782     data->flip();
01783 
01784     if(!bot->socket.cmp()) {
01785         log_debug("in file " __FILE__ " in function " __FUNC__ " occurred error: Attemp to use NULL socket handle");
01786         delete data;
01787         return true;
01788     }
01789     int ec=0;
01790     //int sent=sock_send(bot->socket,(char*)&cmd,sizeof(cmd),ec);
01791 
01792     int compressed=0;
01793     unsigned char* buf=rle_compress((unsigned char*)&data->command_data,sizeof(data->command_data),compressed);
01794     data->size=compressed;
01795     size_t sent=0;
01796     if(!bot->ssl_connection) {
01797         sent=sock_send(bot->socket,(const char*)data,4*4,ec);
01798         stats_botnet_bytes_sent(sent);
01799         sent=sock_send(bot->socket,(const char*)buf,compressed,ec);
01800         stats_botnet_bytes_sent(sent);
01801     } else {
01802         char err_str[1024];
01803         if(ssl_write(bot->ssl,&(bot->socket),err_str,(char*)data,4*4)) {
01804             ssl_close(bot->ssl,&(bot->socket));
01805             bot->ssl=NULL;
01806             ec=-1;
01807         }
01808         stats_botnet_bytes_sent(4*4);
01809         if(ssl_write(bot->ssl,&(bot->socket),err_str,(char*)buf,compressed)) {
01810             ssl_close(bot->ssl,&(bot->socket));
01811             bot->ssl=NULL;
01812             ec=-1;
01813         } else 
01814             sent=compressed;
01815         stats_botnet_bytes_sent(compressed);
01816     }
01817     delete[] buf;
01818 
01819     if(sent!=compressed || ec!=0) {
01820         log_socket(ec,sock_error(ec),"in file " __FILE__ " in function " __FUNC__ " (not all data had been sent)");
01821         delete data;
01822         return true;
01823     }
01824     log_botnet_debug(botnet_botname,bot->botname.c_str(),cmd->packet_type,cmd->command,"sent to remote bot - in file " __FILE__ " in function " __FUNC__);
01825     sleep(1);
01826     delete data;
01827     return false;
01828 }

Here is the call graph for this function:

bool botnet_send_control s_bot bot,
s_bot_control ctrl
 

Sends control packet to linked bot.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
bot Bot handle
ctrl Control packet to send
Returns:
True if I/O error occured
Warning:
On BIG-endian machines this code is destructive for argument "ctrl" - it flips bytes before sending

Definition at line 1840 of file botnet.cpp.

References s_bot::botname, botnet_botname, s_socket::cmp(), s_bot_control::control, s_bot_control::control_data, s_bot_control::flip_header(), s_bot_control::flip_rest(), log_botnet_debug(), log_debug(), log_socket(), s_bot_control::packet_type, rle_compress(), s_bot_control::size, sock_error(), sock_send(), s_bot::socket, s_bot::ssl, ssl_close(), s_bot::ssl_connection, ssl_write(), and stats_botnet_bytes_sent().

Referenced by botnet_loop().

01841 {
01842     ctrl->flip_header();
01843     ctrl->flip_rest();
01844 
01845     if(!bot->socket.cmp()) {
01846         log_debug("in file " __FILE__ " in function " __FUNC__ " occurred error: Attemp to use NULL socket handle");
01847         return true;
01848     }
01849     int ec=0;
01850     //int sent=sock_send(bot->socket,(char*)&ctrl,sizeof(ctrl),ec);
01851 
01852     int compressed=0;
01853     unsigned char* buf=rle_compress((unsigned char*)&ctrl->control_data,sizeof(ctrl->control_data),compressed);
01854     ctrl->size=compressed;
01855     size_t sent=0;
01856     if(!bot->ssl_connection) {
01857         sent=sock_send(bot->socket,(char*)ctrl,4*4,ec);
01858         stats_botnet_bytes_sent(sent);
01859         sent=sock_send(bot->socket,(const char*)buf,compressed,ec);
01860         stats_botnet_bytes_sent(sent);
01861     } else {
01862         char err_str[1024];
01863         if(ssl_write(bot->ssl,&(bot->socket),err_str,(char*)ctrl,4*4)) {
01864             ssl_close(bot->ssl,&(bot->socket));
01865             bot->ssl=NULL;
01866             ec=-1;
01867         }
01868         stats_botnet_bytes_sent(4*4);
01869         if(ssl_write(bot->ssl,&(bot->socket),err_str,(char*)buf,compressed)) {
01870             ssl_close(bot->ssl,&(bot->socket));
01871             bot->ssl=NULL;
01872             ec=-1;
01873         } else
01874             sent=compressed;
01875         stats_botnet_bytes_sent(compressed);
01876     }
01877     delete[] buf;
01878 
01879     if(sent!=compressed || ec!=0) {
01880         log_socket(ec,sock_error(ec),"in file " __FILE__ " in function " __FUNC__ " (not all data had been sent)");
01881         return true;
01882     }
01883     log_botnet_debug(botnet_botname,bot->botname.c_str(),ctrl->packet_type,ctrl->control,"sent to remote bot - in file " __FILE__ " in function " __FUNC__);
01884     return false;
01885 }

Here is the call graph for this function:

string botnet_showbots string  lang,
string  eol
 

Used for partyline to show connected bots (.showbots).

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
lang Output language
eol End of line sequence

Definition at line 8879 of file botnet.cpp.

References bots, and lang_get_string().

Referenced by dcc_loop().

08880 {
08881     string res;
08882     res+=lang_get_string(1,lang,649)+eol;
08883     vector<s_bot*>::iterator i1;
08884     for(i1=bots.begin(); i1!=bots.end(); i1++)
08885         if((*i1)->socket.cmp() && (*i1)->auth_ok && (*i1)->remote_pswd_ok) {
08886             res+=(*i1)->botname;
08887             res+=" ";
08888             res+=lang_get_string(1,lang,650)+eol;
08889         } else {
08890             res+=(*i1)->botname;
08891             res+=" ";
08892             res+=lang_get_string(1,lang,651)+eol;
08893         }
08894 
08895     res+=lang_get_string(1,lang,652)+eol;
08896 
08897     return res;
08898 }

Here is the call graph for this function:

bool logic_botnet_get_channel_def string  channel_name,
s_channel_def chd
 

Gets channel definition.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel_name Channel name
chd Returns channel definition
Returns:
Returns true if channel was found

Definition at line 13436 of file logic.cpp.

References r_channel_defs.

Referenced by botnet_loop().

13437 {
13438     vector<s_channel_def>::iterator i1;
13439     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
13440         if(!(*i1).channel_name.compare(channel_name)) {
13441             chd=*i1;
13442             return true;
13443         }
13444     }
13445     return false;
13446 }

bool logic_botnet_get_proc string  name,
s_procedure proc
 

Gets procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
name Procedure name (full declaration)
proc Returns procedure
Returns:
Returns true if procedure was found

Definition at line 13475 of file logic.cpp.

References r_procedures.

Referenced by botnet_loop().

13476 {
13477     vector<s_procedure>::iterator i1;
13478     for(i1=r_procedures.begin(); i1!=r_procedures.end(); i1++) {
13479         if(!(*i1).name.compare(name)) {
13480             proc=*i1;
13481             return true;
13482         }
13483     }
13484     return false;
13485 }

bool logic_botnet_get_user string  name,
s_user user
 

Gets user definition.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
name User name from "logic.txt"
user Returns user
Returns:
Returns true if user was found

Definition at line 13403 of file logic.cpp.

Referenced by botnet_loop(), irc_check_for_not_invited(), and irc_check_for_not_reopped().

13404 {
13405     vector<s_user>::iterator i1;
13406     for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
13407         if(!(*i1).name.compare(name)) {
13408             user=*i1;
13409             return true;
13410         }
13411     }
13412     for(i1=r_user_templates.begin(); i1!=r_user_templates.end(); i1++) {
13413         if(!(*i1).name.compare(name)) {
13414             user=*i1;
13415             return true;
13416         }
13417     }
13418     for(i1=r_terminators.begin(); i1!=r_terminators.end(); i1++) {
13419         if(!(*i1).name.compare(name)) {
13420             user=*i1;
13421             return true;
13422         }
13423     }
13424     return false;
13425 }

bool logic_botnet_get_user_channels string  name,
vector< s_channel > &  channels
 

Gets channels that user has defined properties to.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
name Channel name
channels Returns channels
Returns:
Returns true if user was found

Definition at line 13496 of file logic.cpp.

References r_channels, and r_users.

Referenced by botnet_push_user().

13497 {
13498     channels.clear();
13499 
13500     vector<s_user>::iterator i1;
13501     for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
13502         if(!(*i1).name.compare(name)) {
13503             vector<s_channel>::iterator i2;
13504             for(i2=r_channels.begin(); i2!=r_channels.end(); i2++) {
13505                 if(!(*i2).username.compare((*i1).name))
13506                     channels.push_back(*i2);
13507             }
13508             return true;
13509         }
13510     }
13511     return false;
13512 }

void logic_botnet_remove_channel_def string  channel_name  ) 
 

Removes channel definition.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel_name Channel name

Definition at line 13455 of file logic.cpp.

References r_channel_defs.

Referenced by botnet_loop().

13456 {
13457     vector<s_channel_def>::iterator i1;
13458     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
13459         if(!(*i1).channel_name.compare(channel_name)) {
13460             r_channel_defs.erase(i1);
13461             break;
13462         }
13463     }
13464 }

void logic_get_pull_chan_defs string  botname,
vector< s_channel_def > &  chans
 

Gets channel definition list to pull.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
chans Returns list of channels to pull

Definition at line 700 of file logic.cpp.

References r_channel_defs, REPL_PULL, and REPL_PUSHPULL.

00701 {
00702     chans.clear();
00703     vector<s_channel_def>::iterator i1;
00704     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
00705         vector<s_replication>::iterator i2;
00706         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00707             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
00708                 chans.push_back(*i1);
00709             }
00710         }
00711     }
00712 }

void logic_get_pull_procs string  botname,
vector< s_procedure > &  procs
 

Gets procedure list to pull.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
procs Returns list of procedures to pull

Definition at line 656 of file logic.cpp.

References r_procedures, REPL_PULL, and REPL_PUSHPULL.

00657 {
00658     procs.clear();
00659     vector<s_procedure>::iterator i1;
00660     for(i1=r_procedures.begin(); i1!=r_procedures.end(); i1++) {
00661         vector<s_replication>::iterator i2;
00662         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00663             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
00664                 procs.push_back(*i1);
00665             }
00666         }
00667     }
00668 }

void logic_get_pull_users string  botname,
vector< s_user > &  users
 

Gets user list to pull.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
users Returns list of users to pull

Definition at line 596 of file logic.cpp.

References r_user_templates, r_users, REPL_PULL, and REPL_PUSHPULL.

00597 {
00598     users.clear();
00599     vector<s_user>::iterator i1;
00600     for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
00601         vector<s_replication>::iterator i2;
00602         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00603             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
00604                 users.push_back(*i1);
00605             }
00606         }
00607     }
00608     for(i1=r_user_templates.begin(); i1!=r_user_templates.end(); i1++) {
00609         vector<s_replication>::iterator i2;
00610         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00611             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PULL || (*i2).type==REPL_PUSHPULL)) {
00612                 users.push_back(*i1);
00613             }
00614         }
00615     }
00616 }

void logic_get_push_chan_defs string  botname,
vector< s_channel_def > &  chans
 

Gets channel definition list to push.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
chans Returns list of channels to push

Definition at line 722 of file logic.cpp.

References r_channel_defs, REPL_PUSH, and REPL_PUSHPULL.

Referenced by botnet_loop().

00723 {
00724     chans.clear();
00725     vector<s_channel_def>::iterator i1;
00726     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
00727         vector<s_replication>::iterator i2;
00728         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00729             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
00730                 chans.push_back(*i1);
00731             }
00732         }
00733     }
00734 }

void logic_get_push_procs string  botname,
vector< s_procedure > &  procs
 

Gets procedure list to push.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
procs Returns list of procedures to push

Definition at line 678 of file logic.cpp.

References r_procedures, REPL_PUSH, and REPL_PUSHPULL.

Referenced by botnet_loop().

00679 {
00680     procs.clear();
00681     vector<s_procedure>::iterator i1;
00682     for(i1=r_procedures.begin(); i1!=r_procedures.end(); i1++) {
00683         vector<s_replication>::iterator i2;
00684         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00685             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
00686                 procs.push_back(*i1);
00687             }
00688         }
00689     }
00690 }

void logic_get_push_users string  botname,
vector< s_user > &  users
 

Gets user list to push.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
botname Name of remote bot
users Returns list of users to push

Definition at line 626 of file logic.cpp.

References r_user_templates, r_users, REPL_PUSH, and REPL_PUSHPULL.

Referenced by botnet_loop().

00627 {
00628     users.clear();
00629     vector<s_user>::iterator i1;
00630     for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
00631         vector<s_replication>::iterator i2;
00632         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00633             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
00634                 users.push_back(*i1);
00635             }
00636         }
00637     }
00638     for(i1=r_user_templates.begin(); i1!=r_user_templates.end(); i1++) {
00639         vector<s_replication>::iterator i2;
00640         for(i2=(*i1).replication.begin(); i2!=(*i1).replication.end(); i2++) {
00641             if(!(*i2).partner.compare(botname) && ((*i2).type==REPL_PUSH || (*i2).type==REPL_PUSHPULL)) {
00642                 users.push_back(*i1);
00643             }
00644         }
00645     }
00646 }

char* ltoa long  value,
char *  buffer,
int  radix
 

ltoa() emulation for compiler which doesn't have it

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
value Value to convert to string
buffer Output string
radix *MUST* be 10
Returns:
Returns buffer
Bug:
radix MUST be 10!

Definition at line 171 of file dcc.cpp.

Referenced by botnet_loop(), dcc_get_string(), dcc_loop(), dcc_loop_edit_chan(), dcc_loop_edit_proc(), dcc_loop_edit_rproc(), dcc_loop_edit_user1(), dcc_loop_edit_user2(), dcc_loop_replication(), dcc_notify(), dcc_send_file(), dcc_user_pong(), filesys_get_script(), identd_error_log(), irc_connect(), irc_loop_putserv(), irc_quoted_callback(), log_socket(), logic_check_mask(), logic_exec(), logic_exec_script(), logic_list_proc(), logic_on_flood(), logic_on_internal_event(), logic_partyline_backup(), logic_partyline_whois(), logic_process_script_output(), logic_rehash(), logic_script_esc(), main(), stats_display(), and stats_format_number().

00172 {
00173     sprintf(buffer,"%ld",value);
00174     return buffer;
00175 }

void sleep int  ms  ) 
 

Sleeps.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
ms Mili-seconds to sleep

Definition at line 226 of file irc_bot.cpp.

Referenced by botnet_loop(), botnet_send_command(), daemon(), irc_loop_process_input(), logic_exec(), and main().

00227 {
00228 #ifdef _WIN32
00229     ProcessMessages();
00230     sock_send_cache();
00231     if(ms) {
00232         if(ms<1000) {
00233             long ms_remain=ms;
00234             while(ms_remain>0) {
00235                 ProcessMessages();
00236                 sock_send_cache();
00237                 int s=ms_remain>50?50:ms_remain;
00238                 Sleep(s);
00239                 ms_remain-=s;
00240                 ProcessMessages();
00241                 sock_send_cache();
00242             }
00243         } else {
00244             time_t now=time(NULL);
00245             for(;;) {
00246                 Sleep(1);
00247                 ProcessMessages();
00248                 dcc_loop();
00249                 sock_send_cache();
00250                 if(now+ms/1000<time(NULL))
00251                     break;
00252             }
00253         }
00254     }
00255     ProcessMessages();
00256 #else
00257     sock_send_cache();
00258     if(ms) {
00259         if(ms<1000) {
00260             long ms_remain=ms;
00261             while(ms_remain>0) {
00262                 sock_send_cache();
00263                 int s=ms_remain>50?50:ms_remain;
00264                 timeval tv;
00265                 tv.tv_sec=0;
00266                 tv.tv_usec=ms*1000;
00267                 select(1,NULL,NULL,NULL,&tv);
00268                 ms_remain-=s;
00269                 sock_send_cache();
00270             }
00271         } else {
00272             time_t now=time(NULL);
00273             for(;;) {
00274                 timeval tv;
00275                 tv.tv_sec=0;
00276                 tv.tv_usec=1*1000;
00277                 select(1,NULL,NULL,NULL,&tv);
00278                 dcc_loop();
00279                 sock_send_cache();
00280                 if(now+ms/1000<time(NULL))
00281                     break;
00282             }
00283         }
00284     }
00285 #endif
00286 }


Variable Documentation

char botnet_botname[256]
 

Name of this bot.

Definition at line 241 of file botnet.cpp.

Referenced by botnet_admin_msg(), botnet_loop(), botnet_partyline_event(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), botnet_partyline_message(), botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), botnet_receive(), botnet_send_command(), botnet_send_control(), and logic_process_line().

vector<s_botnet_channel> botnet_channels
 

List of partyline channels.

Definition at line 1487 of file botnet.cpp.

Referenced by botnet_loop(), botnet_on_unlink(), botnet_partyline_join_channel(), and botnet_partyline_leave_channel().

time_t botnet_last_rehash_request = 0
 

Timestamp of the last rehash request from other bot.

Definition at line 1590 of file botnet.cpp.

Referenced by botnet_backup(), botnet_loop(), and botnet_rehash().

int botnet_penalty = -1
 

There will be penalty (in seconds) from configuration file.

Definition at line 243 of file botnet.cpp.

Referenced by botnet_loop().

vector<s_bot*> bots
 

List of connected bots.

Definition at line 1451 of file botnet.cpp.

Referenced by botnet_link(), botnet_loop(), botnet_partyline_join_channel(), botnet_partyline_leave_channel(), botnet_partyline_message(), botnet_received_data_from_telnet(), botnet_remote_procedure_call(), and botnet_showbots().

vector<s_msg_id> msg_disp_ids
 

List of displayed messages ID's.

Definition at line 1507 of file botnet.cpp.

Referenced by botnet_cleanup_ids(), botnet_get_unique_id(), botnet_partyline_event(), and botnet_query_disp_id().

vector<s_msg_id> msg_ids
 

List of message ID's.

Definition at line 1506 of file botnet.cpp.

Referenced by botnet_cleanup_ids(), botnet_get_unique_id(), botnet_loop(), and botnet_partyline_message().

MSVC_ALIGN1 struct s_bot_command PACK_STRUCT
 

Stores control packet.

Author:
VooDooMan
Version:
1
Date:
2004

int ping_time = 30
 

Number of seconds between two pings.

Definition at line 245 of file botnet.cpp.

Referenced by botnet_loop().

vector<s_channel_def> r_channel_defs
 

List of real channel definitions (not temporary / compilation!).

Definition at line 222 of file logic.cpp.

Referenced by botnet_loop(), dcc_loop_edit_dynbans(), dcc_loop_replication(), irc_loop_process_input(), logic_botnet_get_channel_def(), logic_botnet_remove_channel_def(), logic_ctcp(), logic_exec(), logic_get_pull_chan_defs(), logic_get_push_chan_defs(), logic_load_conf(), logic_on_ircop(), logic_on_notice(), logic_on_part(), logic_on_privmsg(), logic_on_server_msg(), logic_partyline_access(), logic_partyline_add_channel_def(), logic_partyline_backup(), logic_partyline_get_channel_def(), logic_partyline_remove_channel_def(), logic_validate_by_mask(), logic_validate_chan_key(), logic_validate_chan_limit(), logic_validate_chan_mode(), and logic_validate_topic().

vector<s_channel> r_channel_templates
 

List of channel templates for real usage (not temporary / compilation!).

Definition at line 219 of file logic.cpp.

Referenced by botnet_loop(), logic_load_conf(), logic_partyline_add_user(), logic_partyline_backup(), logic_partyline_get_channels(), logic_partyline_get_user_template(), and logic_partyline_remove_user().

vector<s_channel> r_channel_terminators
 

List of channel terminators for real usage (not temporary / compilation!).

Definition at line 220 of file logic.cpp.

Referenced by botnet_loop(), logic_load_conf(), logic_partyline_add_user(), logic_partyline_get_user(), and logic_partyline_remove_user().

vector<s_channel> r_channels
 

List of channels for real usage (not temporary / compilation!).

Definition at line 218 of file logic.cpp.

Referenced by botnet_loop(), dcc_loop_edit_user1(), dcc_loop_filesystem(), dcc_loop_msg(), irc_check_for_not_invited(), irc_check_for_not_reopped(), logic_botnet_get_user_channels(), logic_exec(), logic_exec_script(), logic_get_flood_limits(), logic_load_conf(), logic_on_banned(), logic_on_flood(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), logic_on_not_in_reop(), logic_on_not_invited(), logic_on_notice(), logic_on_privmsg(), logic_partyline_access(), logic_partyline_add_user(), logic_partyline_backup(), logic_partyline_get_channels(), logic_partyline_get_user(), logic_partyline_whois(), logic_set_dynamic(), logic_validate(), logic_validate_by_mask(), and logic_validate_kick().

s_private r_private
 

Informations about procedures when someone sends query message (not temporary / compilation!).

Definition at line 226 of file logic.cpp.

vector<s_procedure> r_procedures
 

List of procedures for real usage (not temporary / compilation!).

Definition at line 214 of file logic.cpp.

Referenced by botnet_loop(), dcc_loop_edit_proc(), dcc_loop_edit_rproc(), dcc_loop_replication(), logic_botnet_get_proc(), logic_call_proc_ex(), logic_call_proc_ex2(), logic_exec(), logic_execute(), logic_find_proc_by_name(), logic_get_pull_procs(), logic_get_push_procs(), logic_list_proc(), logic_load_conf(), logic_parse_proc(), logic_partyline_access(), logic_partyline_backup(), and logic_process_script_output().

vector<s_user> r_terminators
 

List of terminated users for real usage (not temporary / compilation!).

Definition at line 217 of file logic.cpp.

Referenced by botnet_loop(), logic_botnet_get_user(), logic_load_conf(), logic_partyline_add_user(), logic_partyline_backup(), logic_partyline_get_user(), and logic_partyline_remove_user().

vector<s_user> r_user_templates
 

List of users templates for real usage (not temporary / compilation!).

Definition at line 216 of file logic.cpp.

Referenced by botnet_loop(), dcc_loop_new_user(), dcc_loop_replication(), logic_botnet_get_user(), logic_get_pull_users(), logic_get_push_users(), logic_load_conf(), logic_partyline_add_user(), logic_partyline_backup(), and logic_partyline_get_user_template().

vector<s_user> r_users
 

List of users for real usage (not temporary / compilation!).

Definition at line 215 of file logic.cpp.

Referenced by botnet_loop(), dcc_loop_edit_dynbans(), dcc_loop_edit_rproc(), dcc_loop_filesystem(), dcc_loop_msg(), dcc_loop_replication(), irc_check_flood(), irc_RPL_324(), logic_access_to_filesystem(), logic_access_to_partyline(), logic_botnet_get_user(), logic_botnet_get_user_channels(), logic_exec(), logic_exec_script(), logic_find_user(), logic_get_dcc_host(), logic_get_pull_users(), logic_get_push_users(), logic_is_replication_partner(), logic_load_conf(), logic_on_banned(), logic_on_broadcast(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), logic_on_not_in_reop(), logic_on_not_invited(), logic_on_notice(), logic_on_privmsg_query(), logic_partyline_access(), logic_partyline_add_user(), logic_partyline_backup(), logic_partyline_get_user(), logic_partyline_remove_user(), logic_partyline_user_exists(), logic_partyline_whois(), logic_set_dynamic(), logic_validate(), logic_validate_by_mask(), and logic_validate_kick().

s_ssl_conf ssl_conf
 

Configuration of SSL.

Definition at line 66 of file ssl.cpp.


Generated on Sun Jul 10 03:37:11 2005 for VooDoo cIRCle by doxygen 1.4.3

Hosted by SourceForge.net Logo