示例#1
0
        public override void Set(IConfig cfg, vhAPI api)
        {
            Pause = () =>
            {
                hackTimer.Change(0, Timeout.Infinite);
                cfg.logger.Log("*** Stopping HackBotNet");
            };

            Resume = () =>
            {
                Set(cfg, api);
                cfg.logger.Log("*** Resuming HackBotNet");
            };

            InternalPause = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** PAUSING HackBotNet");
                    hackTimer.Change(TimeSpan.Zero, pause);
                }
            };

            InternalResume = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** RESUMING HackBotNet");
                    hackTimer.Change(TimeSpan.Zero, Period);
                }
            };

            if (hackTimer != null)
            {
                hackTimer.Dispose();
                hackTimer = null;
            }

            var upd = new Update(cfg);

            hackTimer = new Timer(async(o) =>
            {
                if (!Monitor.TryEnter(this))
                {
                    return;
                }

                try
                {
                    //await api.attackbotnetserver();
                    // TODO: BOTNET
                    await upd.removeSpyware();
                }
                finally
                {
                    Monitor.Exit(this);
                }
            }
                                  , null, TimeSpan.Zero, cfg.hackBotnetPolling);
        }
示例#2
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";
                }
            }
示例#3
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");
            }
示例#4
0
        public vhApiServer(IConfig cfg) : base(cfg.vhServerHost, cfg.vhServerPort)
        {
            config = cfg;

            try
            {
                var builder = new vhAPIBuilder().useConfig(cfg);
                api = builder.getAPI();
            }
            catch (Exception exc)
            {
                config.logger.Log($"Error creating vhAPI: {exc.Message}");
            }
        }
示例#5
0
        public override void Set(IConfig cfg, vhAPI api)
        {
            Pause = () =>
            {
                hackTimer.Change(0, Timeout.Infinite);
                cfg.logger.Log("*** Stopping IPAttack");
            };

            Resume = () =>
            {
                Set(cfg, api);
                cfg.logger.Log("*** Resuming IPAttack");
            };

            if (hackTimer != null)
            {
                hackTimer.Dispose();
                hackTimer = null;
            }

            config = cfg;

            Period = cfg.ipAttackPolling;

            var console = api.getConsole();

            hackTimer = new Timer(async(o) => await timerCallback(o), new object[] { cfg, api, console }, TimeSpan.Zero, Period);

            safeScan = cfg.safeScan;


            InternalPause = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** PAUSING IP ATTACK");
                    hackTimer.Change(TimeSpan.Zero, pause);
                }
            };

            InternalResume = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** RESUMING IP ATTACK");
                    hackTimer.Change(TimeSpan.Zero, Period);
                }
            };
        }
示例#6
0
        public static void Test(vhAPI api)
        {
            if (ci != null)
            {
                ci.DisposeClientTcp();
                ci = null;
            }

            ci = new ClientImpl("51.255.93.109", "7531");

            ci.OnConnect += () => ci.SendMessage(new vHackApi.Chat.Reqs.Join(api));

            ci.MessageReceived += (msg, err) =>
            {
                if (err != null)
                {
                    System.Console.WriteLine("Error: {0}", err.Message);
                }

                if (msg.Display().Contains("PRIVMSG " + vHackApi.Chat.Reqs.Message.vhackxy + " :"))
                {
                    System.Console.WriteLine(msg.Display());
                }
                else
                {
                    try
                    {
                        var req = new vHackApi.Chat.Reqs.Message(msg.Display(), api);
                        req.Validate();
                        ci.SendMessage(req);
                    }
                    catch (vHackApi.Chat.Reqs.Message.NotValidException)
                    {
                        System.Console.WriteLine(msg.Display());
                    }
                }
            };

            ci.OnConnectFailure += () => System.Console.WriteLine("Connection failure");
            ci.LogAction        += (s, parms) => System.Console.WriteLine(s, parms);

            ci.CreateClientTcp();
            ci.ClientTcp.Connect(TimeSpan.Zero);
        }
示例#7
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);
            }
        }
示例#8
0
                public void Init(IConfig cfg, IConfigParser parser)
                {
                    config       = cfg;
                    configParser = parser;

                    try
                    {
                        var builder = new vhAPIBuilder().useConfig(cfg);
                        api = builder.getAPI();

                        timerInfo = new Timer((o) =>
                        {
                            var info = MyInfo.Fetch(api.getConsole()).Result;
                            lock (this)
                            {
                                jsonInfo = info.Json;
                            }
                        }, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
                    }
                    catch (Exception exc)
                    {
                        config.logger.Log($"Error creating vhAPI: {exc.Message}");
                    }
                }
示例#9
0
        public override void Set(IConfig cfg, vhAPI api)
        {
            upd   = new Update(cfg);
            Pause = () =>
            {
                hackTimer.Change(0, Timeout.Infinite);
                cfg.logger.Log("*** STOPPING IP SCANNER");
            };

            Resume = () =>
            {
                Set(cfg, api);
                cfg.logger.Log("*** RESUMING IP SCANNER");
            };

            if (hackTimer != null)
            {
                hackTimer.Dispose();
                hackTimer = null;
            }

            config = cfg;
            var console = api.getConsole();

            Period = cfg.ipScannerPolling;

            InternalPause = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** PAUSING IP SCANNER");
                    hackTimer.Change(TimeSpan.Zero, pause);
                }
            };

            InternalResume = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** RESUMING IP SCANNER");
                    hackTimer.Change(TimeSpan.Zero, Period);
                }
            };



            hackTimer = new Timer(async(o) =>
            {
                //// TEST: skip during contest
                //if (vhUtils.IsContestRunning())
                //    return;

                // if not on upgrade we'll skip attack
                if (!vhUtils.IsContestRunning() && UpgradeMgr.Instance.CurStatus != UpgradeMgr.Status.Upgrade)
                {
                    return;
                }

                if (!Monitor.TryEnter(localSemaphore))
                {
                    return;
                }

                // wait a random bit
                Thread.Sleep(rand.Next(0, (int)Period.TotalSeconds / 5) * 1000);

                try
                {
                    // first make a search for new ips to hack
                    var img = await console.FindHostsAndAttack();

                    // then looks in the syslog if there's some ips that needs to be pwn3d
                    if (MyInfo.LastUpdInfo != null
                        // if contest running we don't attack syslog cause we don't know if they're watched
                        && !vhUtils.IsContestRunning())
                    {
                        var myIp   = MyInfo.LastUpdInfo.IP;
                        var sysLog = (await upd.getSysLog())["data"] as JArray;
                        foreach (var log in sysLog)
                        {
                            if ((string)log["from"] == myIp)
                            {
                                var newIp = (string)log["to"];
                                if (newIp != "Anonymous")
                                {
                                    IPs dbIp = null;
                                    if (!cfg.persistanceMgr.IpExist(newIp))
                                    {
                                        var js = await console.ScanIp(newIp);

                                        if (js == null)
                                        {
                                            cfg.logger.Log("********* BLOCKED BY FBI!!! **********");
                                            Log.ContestLogger.Log("ScanIp {0} error: BLOCKED BY FBI!!! ", newIp);
                                            return;
                                        }
                                        dbIp = new IPs(js);
                                        cfg.persistanceMgr.AddIp(dbIp);
                                    }
                                    else
                                    {
                                        dbIp = cfg.persistanceMgr.GetIp(newIp);
                                    }

                                    // we'll sit and wait 10 minutes before trying to attack, just to not stir up suspicions...
                                    dbIp.LastAttack = DateTime.Now - TimeSpan.FromMinutes(10);
                                    cfg.persistanceMgr.UpdateIp(dbIp);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    cfg.logger.Log(e.ToString());
                }
                finally
                {
                    Monitor.Exit(localSemaphore);
                }
            }
                                  , null, TimeSpan.Zero, Period);

            safeScan = cfg.safeScan;
        }
示例#10
0
 public abstract void Set(IConfig cfg, vhAPI api);
示例#11
0
 public static void Init(IConfig cfg, vhAPI api)
 {
     Api    = api;
     Config = cfg;
 }
示例#12
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());
                }
            }
        }
示例#13
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();
        }
示例#14
0
        public override void Set(IConfig cfg, vhAPI api)
        {
            logger = cfg.logger;
            _api   = api;

            Pause = () =>
            {
                hackTimer.Change(0, Timeout.Infinite);
                cfg.logger.Log("*** STOPPING UPGRADE MANAGER");
            };

            Resume = () =>
            {
                Set(cfg, api);
                cfg.logger.Log("*** RESUMING UPGRADE MANAGER");
            };


            if (hackTimer != null)
            {
                hackTimer.Dispose();
                hackTimer = null;
            }

            var console = api.getConsole();
            var upd     = new Update(cfg);

            hackTimer = new Timer(
                async(o) =>
            {
                if (!Monitor.TryEnter(localSemaphore))
                {
                    return;
                }

                try
                {
                    var info  = await MyInfo.Fetch(console);
                    var tasks = await upd.getTasks();

                    // upgrade botnet PCs anyway
                    await doUpgradePc(info, upd);

                    var curStatus = CurrentStatus(info, tasks);

                    if (curStatus == Status.Idle)
                    {
                        return;
                    }

                    if (curStatus == Status.Upgrade)
                    {
                        await doUpgrade(info, upd, cfg, tasks);
                    }

                    if (curStatus == Status.EndTasks)
                    {
                        await doBoost(info, upd, cfg, tasks);
                    }
                }
                catch (Exception e)
                {
                    cfg.logger.Log(e.ToString());
                }
                finally
                {
                    Monitor.Exit(localSemaphore);
                }
            }
                , null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
        }
示例#15
0
 public void Init(IConfig config, vhAPI api)
 {
     console = api.getConsole();
     cfg     = config;
     ProportionalUpgradeStrategy.api = api;
 }
示例#16
0
 public vhChat(IConfig cfg, vhAPI api)
 {
     _api = api;
     _cfg = cfg;
 }
示例#17
0
        private static void Run(IConfig cfg)
        {
            try
            {
                //if (!DbManager.Instance.Initialize(cfg))
                //    return;

                //try
                //{
                //    foreach (var ip in DbManager.Instance.GetIps())
                //    {
                //        XmlMgr.Default.IPs.Add(ip);
                //    }
                //}
                //catch (Exception e)
                //{

                //}

                //XmlMgr.Default.Save();
                XmlMgr.Default.Load();

                DbManager.Instance.Initialize(cfg);

                IPSelectorRandom.Default.Init(cfg);

                vhUtils.config = cfg;

                var builder = new vhAPIBuilder()
                              .useConfig(cfg);

                vhAPI api  = builder.getAPI();
                var   upd  = new vHackApi.Update(cfg);
                var   info = upd.botnetInfo();

                //var career = upd.getCareerStatus(api.UserHash);


                //GlobalConfig.Init(cfg, api);

                ProportionalUpgradeStrategy.Default.Init(cfg, api);



                // sets and starts timers
                timers = new List <IHackTimer>
                {
                    HackTheDev.Instance,
                    IPScanner.Instance,
                    HackBotNet.Instance,
                    IPAttack.Instance,
                    UpgradeMgr.Instance,
                };


                // sets the timers
                //timers.ForEach(tm => tm.Set(GlobalConfig.Config, GlobalConfig.Api));
                timers.ForEach(tm => tm.Set(cfg, api));

                log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.xml"));

                vHackApi.Bot.Log.ContestLogger = new ContestLogger();
                vHackApi.Bot.Log.ContestLogger.Log("**** START");
                //var logger = log4net.LogManager.GetLogger(typeof(Program)).Logger.Repository.GetAppenders()
                //    .FirstOrDefault(app => app.Name == "RollingChat");
                var logger = log4net.LogManager.GetLogger("ChatLogger");
                HackTheDev.Instance.Chat.MessageReceived += (s) =>
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        return;
                    }

                    logger.Info(s.Trim());
                };


                // HTTP server
                var cfgParser = new ConfigParser();
                cfgParser.ConfigParsed += (c) =>
                {
                    if (c != null)
                    {
                        cfg.logger.Log($"New config received from remote client:\n{c.ToString()}");
                        if (c.maxAntivirus > 0)
                        {
                            Properties.Settings.Default.maxAntivirus = c.maxAntivirus;
                        }
                        if (c.winchance > 0)
                        {
                            Properties.Settings.Default.WinChance = c.winchance;
                        }
                        if (c.waitstep > 0)
                        {
                            Properties.Settings.Default.WaitStep = c.waitstep;
                        }
                        if (c.maxFirewall > 0)
                        {
                            Properties.Settings.Default.maxFirewall = c.maxFirewall;
                        }
                        if (c.maxAntivirus > 0)
                        {
                            Properties.Settings.Default.maxAntivirus = c.maxAntivirus;
                        }
                        if (c.finishAllFor > 0)
                        {
                            Properties.Settings.Default.finishAllFor = c.finishAllFor;
                        }
                        if (c.pcOrAttack > 0)
                        {
                            Properties.Settings.Default.pcOrAttack = c.pcOrAttack;
                        }

                        cfg.hackTheDevPaused = c.hackTheDevPaused;
                        cfg.hackBotNetPaused = c.hackBotNetPaused;
                        cfg.ipScannerPaused  = c.ipScannerPaused;
                        cfg.ipAttackPaused   = c.ipAttackPaused;

                        cfg.getImgBy = c.getImgBy;

                        Properties.Settings.Default.hackIfNotAnonymous = c.hackIfNotAnonymous;
                        Properties.Settings.Default.Save();
                    }
                    else
                    {
                        cfg.logger.Log($"Null config received from remote client");
                    }
                };

                cfgParser.ParseError += (e) =>
                {
                    cfg.logger.Log($"Error parsing config from remote client: {e.Message}");
                };

                var srv = new vhApiServer(cfg, cfgParser);

                new Thread(() => srv.Listen()).Start();


                // wait for exit
                Thread.Sleep(Timeout.Infinite); // TODO: waits for CTRL + C
            }
            catch (Exception e)
            {
                cfg.logger.Log(e.ToString());
            }
        }
示例#18
0
        public override void Set(IConfig cfg, vhAPI api)
        {
            Pause = () =>
            {
                hackTimer.Change(0, Timeout.Infinite);
                cfg.logger.Log("*** Pausing HackTheDev");
            };

            Resume = () =>
            {
                Set(cfg, api);
                cfg.logger.Log("*** Resuming HackTheDev");
            };

            InternalPause = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** PAUSING HackTheDev");
                    hackTimer.Change(TimeSpan.Zero, pause);
                }
            };

            InternalResume = () =>
            {
                if (hackTimer != null)
                {
                    cfg.logger.Log("*** RESUMING HackTheDev");
                    hackTimer.Change(TimeSpan.Zero, Period);
                }
            };

            if (hackTimer != null)
            {
                hackTimer.Dispose();
                hackTimer = null;
            }

            var console = api.getConsole();

            var lastAttackTm = DateTime.MinValue;

            hackTimer = new Timer(
                async(o) =>
            {
                if (DateTime.Now - lastAttackTm <= TimeSpan.FromHours(1))
                {
                    return;
                }

                if (!Monitor.TryEnter(this))
                {
                    return;
                }

                try
                {
                    var s = await console.AttackIp("127.0.0.1");
                    if (s == 0)
                    {
                        lastAttackTm = DateTime.Now;
                    }
                }
                catch (Exception e)
                {
                    cfg.logger.Log(e.ToString());
                }
                finally
                {
                    Monitor.Exit(this);
                }
            }
                , null, TimeSpan.Zero, cfg.hackDevPolling);

            _chat = new vhChat(cfg, api);
            _chat.PrivateMessage += async(rule, email, nick, msg) =>
            {
                System.Console.ForegroundColor = ConsoleColor.Blue;
                //cfg.logger.Log($"{DateTime.Now} {nick}({rule}): {msg}");
                cfg.logger.Log($"VHCHAT - {nick}[{email}]({rule}): {msg}");
                System.Console.ResetColor();

                // if message from bot try to hack the dev (maybe it has been reset)
                if (nick == "vHackXTBot")
                {
                    var s = await console.AttackIp("127.0.0.1");

                    if (s == 0)
                    {
                        lastAttackTm = DateTime.Now;
                    }
                }
            };

            _chat.Run();
        }