예제 #1
0
 private void logoffbtn_Click(object sender, EventArgs e)
 {
     try
     {
         onLogout();
         SelectService = null;
     }
     catch { }
     Stop();
     Dispose();
 }
예제 #2
0
 public EnemyCompInterface(List <FileX> flistPlayer, EnemyComp eC, int speed)
 {
     InitializeComponent();
     ThisComp             = eC;
     EnemyComp.OnChanged += delegate
     {
         RefreshData();
     };
     listFilePlayer = flistPlayer;
     _speed         = speed;
     SelectService  = null;
 }
예제 #3
0
        public ServiceX PortToService(int port)
        {
            ServiceX result = null;

            foreach (var ser in Services)
            {
                if (ser.Port == port)
                {
                    result = ser;
                    break;
                }
            }
            return(result);
        }
예제 #4
0
 public void Start()
 {
     if (this.ListFile.Count > 0)
     {
         if (this.Type == TypeServiceX.FTP)
         {
             foreach (var f_run in ListFile)
             {
                 if (f_run.Name.Contains("autorun"))
                 {
                     LOG.Log(Parrent.Addr + "=> Autorun start...");
                     if (f_run is FileScriptX)
                     {
                         if (f_run.Body[0] == Parrent.Addr)
                         {
                             ResponseData data = (f_run as FileScriptX).Run(this);
                             if ((bool)data.Data[0])
                             {
                                 if (data.Data[2].ToString() == Parrent.Addr)
                                 {
                                     ServiceX nServ = data.Data[1] as ServiceX;
                                     if (Autorun != null)
                                     {
                                         Autorun(nServ, data.Data[2].ToString());
                                         this.ListFile.Remove(f_run);
                                         LOG.Log(Parrent.Addr + "=> File is deleted");
                                     }
                                 }
                                 else
                                 {
                                     LOG.Log(Parrent.Addr + "=> File is not Data to Computer");
                                 }
                             }
                         }
                         else
                         {
                             LOG.Log(Parrent.Addr + "=> File is not Data to Computer");
                         }
                     }
                     break;
                 }
             }
         }
     }
     isRun = true;
     Change?.Invoke();
     Parrent.Label.ServiceisOn();
 }
예제 #5
0
        void RefreshData()
        {
            addrlbl.Text   = ThisComp.Addr;
            moneylbl.Text  = ThisComp.Money.ToString();
            wantedlbl.Text = ThisComp.reWanted.ToString();
            layoutService.Controls.Clear();
            cBoxService.Items.Clear();
            foreach (ServiceX serV in ThisComp.Services)
            {
                cBoxService.Items.Add(string.Format("[{0}] - {1}", serV.Port, serV.Desc));
                Element.ECIPortElement se = new Element.ECIPortElement(serV);
                se.ChangedState += delegate(ServiceX serv, byte state)
                {
                    int i = ThisComp.Services.IndexOf(serv);
                    switch (state)
                    {
                    case 1:
                        ThisComp.Services[i].Restart();
                        if (serv.Port == SelectService.Port)
                        {
                            SelectService = null;
                        }
                        break;

                    case 2:
                        ThisComp.Services[i].Stop();
                        if (serv.Port == SelectService.Port)
                        {
                            SelectService = null;
                        }
                        break;

                    case 3:
                        ThisComp.Services[i].Restart();
                        if (serv.Port == SelectService.Port)
                        {
                            SelectService = null;
                        }
                        break;

                    default: break;
                    }
                    RefreshData();
                };
                layoutService.Controls.Add(se);
            }
            RefreshFileList();
        }
예제 #6
0
        public ServiceX FindServiceId(string id)
        {
            ServiceX serv = null;

            foreach (EnemyComp e in X_Enemies)
            {
                foreach (ServiceX s in e.Services)
                {
                    if (s.id == id)
                    {
                        return(s);
                    }
                }
            }
            return(serv);
        }
예제 #7
0
 public void AddService(ServiceX serv)
 {
     if (serv.Crypt == CryptBit.Bit0)
     {
         serv.isDecrypt = true;
     }
     if (serv.Type == TypeServiceX.FTP)
     {
         serv.Autorun += delegate(ServiceX servadd, string addr)
         {
             if (this.Addr == addr)
             {
                 this.AddService(servadd);
             }
         };
     }
     serv.Parrent = this;
     Services.Add(serv);
 }
예제 #8
0
        private void cBoxService_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox box = (ComboBox)sender;

            if (box != null)
            {
                int select = box.SelectedIndex;
                if (select != -1)
                {
                    if (ThisComp.Services[select].isDecrypt != false && ThisComp.Services[select].isHackPass != false &&
                        ThisComp.Services[select].isRun != false)
                    {
                        SelectService = ThisComp.Services[select];
                    }
                    else
                    {
                        MessageBox.Show("Этот сервис ещё не взломан или не запущен.");
                    }
                    RefreshFileList();
                }
            }
        }
예제 #9
0
        public void ReadEnemy(string path)
        {
            try
            {
                XDocument xDoc = XDocument.Load(path);
                foreach (XElement enem in xDoc.Root.Elements())
                {
                    EnemyComp x_enemy = new EnemyComp();
                    x_enemy.id   = enem.Attribute("id").Value;
                    x_enemy.Addr = enem.Attribute("address").Value;
                    RePoint r = new RePoint();
                    x_enemy.Position  = r.Point(float.Parse(enem.Element("position").Attribute("x").Value), float.Parse(enem.Element("position").Attribute("y").Value));
                    x_enemy.isScaning = bool.Parse(enem.Element("isscan").Value);
                    x_enemy.isVisible = bool.Parse(enem.Element("isvisible").Value);
                    x_enemy.Money     = int.Parse(enem.Element("money").Value);
                    foreach (XElement sx in enem.Element("services").Elements("service"))
                    {
                        ServiceX service = new ServiceX(int.Parse(sx.Element("timestart").Value), int.Parse(sx.Element("port").Value));
                        service.id   = sx.Attribute("id").Value;
                        service.Desc = sx.Element("name").Value;
                        switch (sx.Element("type").Value)
                        {
                        case "NONE": service.Type = TypeServiceX.NONE;
                            break;

                        case "FTP": service.Type = TypeServiceX.FTP;
                            break;

                        case "FIREWALL": service.Type = TypeServiceX.FIREWALL;
                            break;

                        case "ATM": service.Type = TypeServiceX.ATM;
                            break;

                        case "PROXY": service.Type = TypeServiceX.PROXY;
                            break;

                        case "SSH": service.Type = TypeServiceX.SSH;
                            break;

                        default: service.Type = TypeServiceX.NONE;
                            break;
                        }
                        service.Pass       = sx.Element("pass").Value;
                        service.isHackPass = bool.Parse(sx.Element("ishackpass").Value);
                        foreach (XElement fx in sx.Element("files").Elements("file"))
                        {
                            FileX file = null;
                            switch (fx.Attribute("type").Value)
                            {
                            case "TXT": file = new FileTxtX();
                                break;

                            case "SCRIPT": file = new FileScriptX();
                                break;

                            case "EXPLOIT": file = new FileExploitX();
                                break;

                            case "DATA": file = new FileDataX();
                                break;

                            case "SSHKEY": file = new FileSSHKeyX();
                                break;

                            default: file = new FileX();
                                break;
                            }
                            file.id       = fx.Attribute("id").Value;
                            file.Capacity = int.Parse(fx.Attribute("capacity").Value);
                            file.Name     = fx.Attribute("name").Value;
                            file.AddText(fx.Value);
                            service.AddFile(file);
                        }
                        x_enemy.AddService(service);
                    }
                    X_Enemies.Add(x_enemy);
                }
            }
            catch (Exception ex) { LOG.Error("ERROR LOAD comp.xml: {" + ex.Message + "}"); }
        }
예제 #10
0
        public void ReadEvent(string path)
        {
            XDocument  xDoc = XDocument.Load(path);
            GameScript game = new GameScript();

            foreach (XElement ev in xDoc.Root.Elements("outs"))
            {
                EventGame Event = new EventGame(TypeInEventX.None, TypeOutEventX.None);
                foreach (XElement file in ev.Element("files").Elements("file"))
                {
                    FileX f = null;
                    switch (file.Attribute("type").Value)
                    {
                    case "TXT": f = new FileTxtX();
                        break;

                    case "SCRIPT": f = new FileScriptX();
                        break;

                    case "EXPLOIT": f = new FileExploitX();
                        break;

                    case "DATA": f = new FileDataX();
                        break;

                    case "SSHKEY": f = new FileSSHKeyX();
                        break;

                    default: f = new FileX();
                        break;
                    }
                    f.id       = file.Attribute("id").Value;
                    f.Capacity = int.Parse(file.Attribute("capacity").Value);
                    f.Name     = file.Attribute("name").Value;
                    f.AddText(file.Value);
                    Ev_File.Add(f);
                }
                foreach (XElement enem in ev.Element("enemies").Elements("enemy"))
                {
                    EnemyComp x_enemy = new EnemyComp();
                    x_enemy.id   = enem.Attribute("id").Value;
                    x_enemy.Addr = enem.Attribute("address").Value;
                    RePoint r = new RePoint();
                    x_enemy.Position  = r.Point(float.Parse(enem.Element("position").Attribute("x").Value), float.Parse(enem.Element("position").Attribute("y").Value));
                    x_enemy.isScaning = bool.Parse(enem.Element("isscan").Value);
                    x_enemy.isVisible = bool.Parse(enem.Element("isvisible").Value);
                    x_enemy.Money     = int.Parse(enem.Element("money").Value);
                    foreach (XElement sx in enem.Element("services").Elements("service"))
                    {
                        ServiceX service = new ServiceX(int.Parse(sx.Element("timestart").Value), int.Parse(sx.Element("port").Value));
                        service.id   = sx.Attribute("id").Value;
                        service.Desc = sx.Element("name").Value;
                        switch (sx.Element("type").Value)
                        {
                        case "NONE": service.Type = TypeServiceX.NONE;
                            break;

                        case "FTP": service.Type = TypeServiceX.FTP;
                            break;

                        case "FIREWALL": service.Type = TypeServiceX.FIREWALL;
                            break;

                        case "ATM": service.Type = TypeServiceX.ATM;
                            break;

                        case "PROXY": service.Type = TypeServiceX.PROXY;
                            break;

                        case "SSH": service.Type = TypeServiceX.SSH;
                            break;

                        default: service.Type = TypeServiceX.NONE;
                            break;
                        }
                        service.Pass       = sx.Element("pass").Value;
                        service.isHackPass = bool.Parse(sx.Element("ishackpass").Value);
                        foreach (XElement fx in sx.Element("files").Elements("file"))
                        {
                            FileX file = null;
                            switch (fx.Attribute("type").Value)
                            {
                            case "TXT": file = new FileTxtX();
                                break;

                            case "SCRIPT": file = new FileScriptX();
                                break;

                            case "EXPLOIT": file = new FileExploitX();
                                break;

                            case "DATA": file = new FileDataX();
                                break;

                            case "SSHKEY": file = new FileSSHKeyX();
                                break;

                            default: file = new FileX();
                                break;
                            }
                            file.id       = fx.Attribute("id").Value;
                            file.Capacity = int.Parse(fx.Attribute("capacity").Value);
                            file.Name     = fx.Attribute("name").Value;
                            file.AddText(fx.Value);
                            service.AddFile(file);
                        }
                        x_enemy.AddService(service);
                    }
                    Ev_Enemy.Add(x_enemy);
                }
                foreach (XElement m in ev.Element("mails").Elements("mail"))
                {
                    MailX mail = new MailX(m.Attribute("name").Value);
                    mail.ids = m.Attribute("id").Value;
                    mail.AddText(m.Value);
                    Ev_Mail.Add(mail);
                }
                foreach (XElement w in ev.Element("wanteds").Elements("wanted"))
                {
                    Ev_Wanted.Add(new E_Wanted(w.Attribute("id").Value, int.Parse(w.Value)));
                }
                foreach (XElement even in xDoc.Root.Element("ev").Elements("event"))
                {
                    TypeInEventX t_in    = TypeInEventX.None;
                    object       obj_inn = null;
                    switch (even.Element("in").Attribute("type").Value)
                    {
                    case "E_Scan":
                    {
                        t_in    = TypeInEventX.E_Scan;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "E_Crack":
                    {
                        t_in    = TypeInEventX.E_Crack;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "Time":
                    {
                        t_in    = TypeInEventX.Time;
                        obj_inn = int.Parse(even.Element("in").Element("time").Value);
                        break;
                    }

                    case "File":
                    {
                        t_in    = TypeInEventX.File;
                        obj_inn = FindFileId(even.Element("in").Element("file").Value);
                        break;
                    }

                    case "Wanted":
                    {
                        t_in    = TypeInEventX.Wanted;
                        obj_inn = int.Parse(even.Element("in").Element("wanted").Value);
                        break;
                    }

                    case "Connected":
                    {
                        t_in    = TypeInEventX.Connected;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "Service_off":
                    {
                        t_in    = TypeInEventX.Service_off;
                        obj_inn = FindServiceId(even.Element("in").Element("service").Value);
                        break;
                    }

                    default: t_in = TypeInEventX.None;
                        break;
                    }
                    object        obj_out = null;
                    TypeOutEventX t_out   = TypeOutEventX.None;
                    obj_out = FindEventOut(even.Element("out").Attribute("id").Value, out t_out);
                    X_Event.Add(game.AddEvent(t_in, t_out, obj_inn, obj_out));
                }
            }
        }
예제 #11
0
        public override ResponseData CheckedEvent(GameScript handle)
        {
            ResponseData result = new ResponseData("event");

            if (!isEvented)
            {
                try
                {
                    switch (this.TypeInEvent)
                    {
                    case TypeInEventX.E_Crack:
                    {
                        EnemyComp e = inEventData as EnemyComp;
                        IEnumerable <EnemyComp> query = from ec in handle.ListEnemy
                                                        where ec.Addr == e.Addr
                                                        where ec.IsAllHack == true && ec.IsOffFirewall == true
                                                        select ec;
                        if (query.Count() > 0)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.E_Scan:
                    {
                        EnemyComp e = inEventData as EnemyComp;
                        IEnumerable <EnemyComp> query = from ec in handle.ListEnemy
                                                        where ec.Addr == e.Addr
                                                        where ec.isScaning == true
                                                        select ec;
                        if (query.Count() > 0)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.File:
                    {
                        FileX file = inEventData as FileX;
                        IEnumerable <FileX> query = from f in handle.player.Computer.FileList
                                                    where f.Name == file.Name
                                                    select f;
                        if (query.Count() > 0)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.Time:
                    {
                        if (isOk)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.Wanted:
                    {
                        int wanted = int.Parse(inEventData.ToString());
                        if (handle.player.Wanted >= wanted)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.Connected:
                    {
                        EnemyComp eComp = inEventData as EnemyComp;
                        if (eComp.isScaning)
                        {
                            if (handle.player.isConnected)
                            {
                                if ((handle.player.ConnectedEnemy.IsOffFirewall) && (handle.player.ConnectedEnemy.IsAllHack))
                                {
                                    if (handle.player.ConnectedEnemy.Addr == eComp.Addr)
                                    {
                                        result = EventedData(handle);
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case TypeInEventX.Service_off:
                    {
                        ServiceX serv    = inEventData as ServiceX;
                        var      servOff = from ec in handle.ListEnemy
                                           where ec.Addr == serv.Parrent.Addr
                                           select ec into enC
                                           from ser in enC.Services
                                           where ser.Port == serv.Port
                                           select ser;
                        if (servOff.Count() > 0)
                        {
                            ServiceX s = servOff.ElementAt <ServiceX>(0);
                            if (s.isRun == false)
                            {
                                result = EventedData(handle);
                            }
                        }


                        break;
                    }
                    }
                }
                catch (Exception ex) { LOG.Error("Error event to: " + ex.Message); }
            }

            return(result);
        }