Exemplo n.º 1
0
            public Message(string readLine, vhAPI api)
            {
                SyncRef = new object();

                if (readLine.ToLower().StartsWith("ping "))
                {
                    str = "PONG " + readLine.Substring(5) + "\r\n";
                    //sock.Send(Encoding.ASCII.GetBytes(str3));
                }
                if (readLine.Contains(":(channel is full) transfering you to #"))
                {
                    vhackxy = readLine
                              .Substring(readLine
                                         .IndexOf(":(channel is full) transfering you to", 1))
                              .Replace(":(channel is full) transfering you to ", "")
                              .Replace("\r", "")
                              .Replace("\n", "")
                              .Replace(" ", "");
                }
                if (readLine.Contains(" 433 *"))
                {
                    String str2 = "v[" + api.getUsername();
                    //var msg = ("NICK " + str2 + "\r\n");
                    //msg += ("USER " + api.getStats(Stats.id).Result + " 0 * : vHack XT@Android\r\n");

                    str = "NICK " + str2 + "_" + "\r\n";
                }
                if (readLine.Contains("376"))
                {
                    str = "PRIVMSG vHackXTGuard :.join " + api.getStats(Stats.id) + " " + api.getStats(Stats.hash) + "\r\n";
                }
            }
Exemplo n.º 2
0
            public Join(vhAPI api)
            {
                //String str2 = "v[" + api.getUsername();
                //String str2 = "v[" + api.getUsername() + "]";
                String str2 = api.getUsername();

                msg  = ("NICK " + str2 + "\r\n");
                msg += ("USER " + api.getStats(Stats.id).Result + " 0 * : vHack XT@Android\r\n");
            }
Exemplo n.º 3
0
        static async void procLine(string readLine, String str2, vhAPI api)
        {
            if (readLine.ToLower().StartsWith("ping "))
            {
                String str3 = "PONG " + readLine.Substring(5) + "\r\n";
                Client.Send(str3);
            }
            if (readLine.Contains(":(channel is full) transfering you to #"))
            {
                Vhackxy = readLine
                          .Substring(readLine
                                     .IndexOf(":(channel is full) transfering you to", 1))
                          .Replace(":(channel is full) transfering you to ", "")
                          .Replace("\r", "")
                          .Replace("\n", "")
                          .Replace(" ", "");
            }
            if (readLine.Contains(" 433 *"))
            {
                //bufferedWriter.write("NICK " + str2 + "_" + "\r\n");
                //bufferedWriter.flush();
                Client.Send("NICK " + str2 + "_" + "\r\n");
            }
            if (readLine.Contains("376"))
            {
                Client.Send("PRIVMSG vHackXTGuard :.join " + api.getStats(Stats.id) + " " + api.getStats(Stats.hash) + "\r\n");
                //bufferedWriter.write("PRIVMSG vHackXTGuard :.join " + api.getStats(Stats.id) + " " + api.getStats(Stats.hash) + "\r\n");
                //bufferedWriter.flush();
                //bufferedWriter.flush();
            }
            if (readLine.Contains("PRIVMSG " + Vhackxy + " :"))
            {
                //Chat chat = new Chat();
                //chat.chatMessage(readLine);

                OnChatMessage(readLine);
            }
        }
Exemplo n.º 4
0
        public void Run()
        {
            var sock = new Socket(SocketType.Stream, ProtocolType.Tcp);

            //sock.Connect("51.255.93.109", 7531);
            sock.Connect(_cfg.chatIp, _cfg.chatPort);

            String str2 = "v[" + _cfg.chatUser;
            var    myId = _api.getStats(Stats.id).Result;
            //String str2 = "v[" + api.getUsername();
            var msg = ("NICK " + str2 + "\r\n");

            msg += ("USER " + myId + " 0 * : vHack XT@Android\r\n");

            sock.Send(_encoding.GetBytes(msg));

            var vhackxy = "#vHackXT";

            var procLine = new Action <string>((readLine) =>
            {
                if (readLine.ToLower().StartsWith("ping "))
                {
                    String str3 = "PONG " + readLine.Substring(5) + "\r\n";

                    sock.Send(_encoding.GetBytes(str3));
                }
                if (readLine.Contains(":(channel is full) transfering you to #"))
                {
                }
                if (readLine.Contains(" 433 *"))
                {
                    var str = "NICK " + str2 + "_" + "\r\n";
                    sock.Send(_encoding.GetBytes(str));
                }
                if (readLine.Contains("376"))
                {
                    var str = "PRIVMSG vHackXTGuard :.join " + _api.getStats(Stats.id).Result + " " +
                              _api.getStats(Stats.hash).Result +
                              "\r\n";
                    sock.Send(_encoding.GetBytes(str));
                }
                if (readLine.Contains("PRIVMSG " + vhackxy + " :"))
                {
                    //System.Console.WriteLine(readLine);


                    var m = Regex.Match(readLine, @"\:([^\!]*)\!([^\@]*)\@([^ ]*) PRIVMSG \#vHackXT \:([^\n]*)");
                    if (m.Success)
                    {
                        var nick  = m.Groups[1].Value;
                        var id    = m.Groups[2].Value;
                        var email = m.Groups[3].Value;
                        var rule  = Rule.User;
                        if (email.Contains("mod.vhack.biz"))
                        {
                            rule = Rule.Mod;
                        }
                        else if (email.Contains("bot.vhack.biz"))
                        {
                            rule = Rule.Bot;
                        }
                        else if (email.Contains("admin.vhack.biz"))
                        {
                            rule = Rule.Admin;
                        }
                        else if (email.Contains("vip.vhack.biz"))
                        {
                            rule = Rule.Vip;
                        }

                        var pmsg = m.Groups.Cast <Group>().Last().Value;
                        var m1   = Regex.Match(pmsg, @"(\p{Cs})");
                        PrivateMessage(rule, $"{id}@{email}", nick, pmsg);
                    }
                    else
                    {
                        PrivateMessage(Rule.None, null, null, readLine);
                    }
                }
            });

            _sendMessage = (s) =>
            {
                sock.Send(_encoding.GetBytes("PRIVMSG " + vhackxy + " :" + s + "\r\n"));
                PrivateMessage(Rule.Me, myId, _cfg.chatUser, s);
            };

            Task.Run(() =>
            {
                while (run)
                {
                    lock (_semaphore)
                    {
                        try
                        {
                            var bytes = new byte[1024];
                            var count = sock.Receive(bytes);

                            // conversion to get unicode chars (emoji and special chars)
                            var ubytes = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, bytes);
                            var lines  = Encoding.Unicode.GetString(ubytes);


                            foreach (var l in lines.Split(new[] { "\r\n" }, StringSplitOptions.None))
                            {
                                var line = l.Replace("\0", "").Trim();
                                if (string.IsNullOrEmpty(line))
                                {
                                    continue;
                                }

                                try
                                {
                                    MessageReceived(line);
                                    procLine(line);
                                }
                                catch (Exception exc)
                                {
                                    _cfg.logger.Log("Error parsing chat lines: {0}", exc.ToString());
                                }
                            }
                        }
                        catch (Exception exc)
                        {
                            _cfg.logger.Log("Error in chat client: {0}", exc.ToString());
                        }
                    }
                }
            });
        }
Exemplo n.º 5
0
        public static void RunChat(vhAPI api)
        {
            var sock = new Socket(SocketType.Stream, ProtocolType.Tcp);

            //sock.Connect("chat.vhackxt.com", 7531); // ip: 85.25.237.247
            sock.Connect("51.255.93.109", 7531);


            String str2 = "v[" + "wonderboy"; //api.getUsername();
            //String str2 = "v[" + api.getUsername();
            var msg = ("NICK " + str2 + "\r\n");

            msg += ("USER " + api.getStats(Stats.id).Result + " 0 * : vHack XT@Android\r\n");

            sock.Send(Encoding.ASCII.GetBytes(msg));

            var vhackxy = "#vHackXT";

            var procLine = new Action <string>((readLine) =>
            {
                if (readLine.ToLower().StartsWith("ping "))
                {
                    String str3 = "PONG " + readLine.Substring(5) + "\r\n";
                    System.Console.WriteLine($"{counter++} {str3}");
                    sock.Send(Encoding.ASCII.GetBytes(str3));
                }
                if (readLine.Contains(":(channel is full) transfering you to #"))
                {
                }
                if (readLine.Contains(" 433 *"))
                {
                    var str = "NICK " + str2 + "_" + "\r\n";
                    sock.Send(Encoding.ASCII.GetBytes(str));
                    System.Console.WriteLine($"{counter++} {str}");
                }
                if (readLine.Contains("376"))
                {
                    var str = "PRIVMSG vHackXTGuard :.join " + api.getStats(Stats.id).Result + " " + api.getStats(Stats.hash).Result +
                              "\r\n";
                    sock.Send(Encoding.ASCII.GetBytes(str));
                    System.Console.WriteLine($"{counter++} {str}");
                }
                if (readLine.Contains("PRIVMSG " + vhackxy + " :"))
                {
                    System.Console.WriteLine(readLine);

                    var m = Regex.Match(readLine, @"\:v\[(\w*)!(\d*)@([\d|\w]*\.)*IP PRIVMSG \#vHackXT \:(.*)");
                    if (m.Success)
                    {
                        var nick = m.Groups[1].Value;
                        var id   = m.Groups[2].Value;
                        var pmsg = m.Groups[4].Value;
                        PrivateMessage(Convert.ToInt16(id), nick, pmsg);
                    }
                }
            });

            while (true)
            {
                var bytes = new byte[1024];
                var count = sock.Receive(bytes);
                var lines = Encoding.ASCII.GetString(bytes, 0, count);

                foreach (var line in lines.Split(new[] { "\r\n" }, StringSplitOptions.None))
                {
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    System.Console.ForegroundColor = ConsoleColor.Green;
                    System.Console.WriteLine(line.Trim());
                    System.Console.ForegroundColor = ConsoleColor.Blue;
                    procLine(line.Trim());
                }
            }
        }
Exemplo n.º 6
0
        public static void ConnectToChat(vhAPI api)
        {
            _threadA = new Thread(() =>
            {
                try
                {
                    Client = new Client("51.255.93.109", 7531);


                    //bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                    //BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    //String str2 = "v[" + api.getUsername();
                    //bufferedWriter.write("NICK " + str2 + "\r\n");
                    //bufferedWriter.write("USER " + api.getStats(Stats.id) + " 0 * : vHack XT@Android\r\n");
                    //bufferedWriter.flush();


                    String str2 = "v[" + api.getUsername();

                    Client.OnResponse += (s) =>
                    {
                        var lines = s.sb.ToString();
                        foreach (var line in lines.Split(new[] { "\r\n" }, StringSplitOptions.None))
                        {
                            if (string.IsNullOrEmpty(line))
                            {
                                continue;
                            }

                            procLine(line.Trim(), str2, api);
                        }
                    };



                    // starts connection
                    Client.Connect();
                    Client.WaitConnect();


                    // handshake message
                    var id  = api.getStats(Stats.id).Result;
                    var msg = $"NICK {str2}\r\nUSER {id} 0 * : vHack XT@Android\r\n";
                    Client.Send(msg);

                    var t = new Thread(() =>
                    {
                        while (true)
                        {
                            Client.Receive();
                            Client.WaitReceive();
                        }
                    });
                    t.Start();
                }
                catch (System.Net.WebException e)
                {
                    // TODO Auto-generated catch block
                    vhConsole.config.logger.Log(e.StackTrace);
                }
                catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    vhConsole.config.logger.Log(e.StackTrace);
                }
            });
            _threadA.Start();
            _threadA.Join();
        }