예제 #1
0
        /// <summary>
        /// Creates a node
        /// </summary>
        /// <param name="opt">The option</param>
        /// <returns>The node</returns>
        private static unsafe Node byID(OPT opt)
        {
            Node node = new Node();

            node.Flags   = NodeFlags.DIRECTORY;
            node.FindDir = findDirImpl;

            IDCookie cookie = new IDCookie((int)opt);

            node.Cookie = cookie;

            return(node);
        }
예제 #2
0
파일: Data.cs 프로젝트: sunnyxie49/Grimoire
        public void TS_File_Load_Click(object sender, EventArgs e)
        {
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");

            string filePath = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                return;
            }

            load(filePath);
        }
예제 #3
0
        static void Main(string[] args)
        {
            OPT.LoadSettings();
            DesCipher = new XDes(OPT.GetString("des.key"));

            clientList = new Dictionary <int, Client>();

            Console.WriteLine("Indexing legacy file names...");
            OPT.LoadLegacyFiles();
            Console.WriteLine("\t- {0} legacy files indexed!", OPT.LegacyCount);

            Console.WriteLine("Indexing delete file names...");
            OPT.LoadDeleteFiles();
            Console.WriteLine("\t- {0} delete files indexed!", OPT.DeleteCount);

            IndexManager.Build(false);

            Console.Write("Checking for tmp directory...");
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            Console.Write("[OK]\n\t- Cleaning up temp files...");

            int cleanedCount = 0;

            foreach (string filePath in Directory.GetFiles(tmpPath))
            {
                File.Delete(filePath);
                cleanedCount++;
            }
            Console.WriteLine("[OK] ({0} files cleared!)", cleanedCount);

            Console.Write("Initializing client listener... ");
            if (ClientManager.Instance.Start())
            {
                Console.WriteLine("[OK]");
            }

            Console.Write("Initializing Index Rebuild Service...");
            int rebuildInterval = OPT.GetInt("rebuild.interval") * 1000;

            indexTimer = new Timer(indexTick, null, rebuildInterval, rebuildInterval);
            Console.WriteLine("[OK]");

            Console.Write("Initializing OTP Reset Service...");
            otpTimer = new Timer(otpTick, null, 0, 300000);
            Console.WriteLine("[OK]");

            Console.ReadLine();
        }
예제 #4
0
파일: Data.cs 프로젝트: odasm/Grimoire
        private async void extensions_cs_export_Click(object sender, EventArgs e)
        {
            string buildDirectory = OPT.GetString("build.directory");

            string ext = extensions.SelectedNode.Text;

            if (ext.Length == 3)
            {
                List <IndexEntry> entries = core.GetEntriesByExtension(ext);

                ts_status.Text = string.Format("Exporting: {0}...", ext);

                tab_disabled = true;

                try
                {
                    await Task.Run(() =>
                    {
                        if (ext == "all")
                        {
                            core.ExportAllEntries(buildDirectory);
                        }
                        else
                        {
                            buildDirectory += string.Format(@"\{0}\", ext);

                            if (!Directory.Exists(buildDirectory))
                            {
                                Directory.CreateDirectory(buildDirectory);
                            }

                            core.ExportExtEntries(buildDirectory, ext);
                        }
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Extension Export Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
                }
                finally
                {
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, "Exported {0} Rows from Tab: {1}", entries.Count, tManager.Text);
                }

                ts_status.Text = string.Empty;

                tab_disabled = false;
            }
        }
예제 #5
0
파일: Item.cs 프로젝트: sunnyxie49/Grimoire
        public Item()
        {
            InitializeComponent();
            imageList           = new ImageList();
            imageList.ImageSize = new Size(34, 34);
            bool     backup   = OPT.GetBool("data.backup");
            int      codepage = OPT.GetInt("data.encoding");
            Encoding encoding = Encoding.GetEncoding(codepage);

            Core = new Core(backup, encoding);
            spr  = new SPR();
            loadCore();
            itemList.LargeImageList = imageList;
            setEnums();
        }
예제 #6
0
        private void TelnetSendSubopt(OPT option, string val)
        {
            byte[] bval = (new System.Text.ASCIIEncoding()).GetBytes(val);
            byte[] data = new byte[6 + val.Length];
            int    i    = 0;

            data[i++] = (byte)CMD.IAC;
            data[i++] = (byte)CMD.SB;
            data[i++] = (byte)option;
            data[i++] = 0;
            bval.CopyTo(data, i); i += bval.Length;
            data[i++] = (byte)CMD.IAC;
            data[i++] = (byte)CMD.SE;
            _RequestData(data);
        }
예제 #7
0
        private void CS_RequestSendType(Client client, PacketStream stream)
        {
            if (debug)
            {
                Output.Write(new Message()
                {
                    Text = string.Format("Client [{0}] requested send.type", client.Id), AddBreak = true
                });
            }

            PacketStream outStream = new PacketStream(0x0040);

            outStream.WriteInt32(OPT.GetInt("send.type"));
            ClientManager.Instance.Send(client, outStream);
        }
예제 #8
0
        /// <summary>
        /// FS readdir
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="index">The index</param>
        /// <returns>The directory entry</returns>
        private static unsafe DirEntry* readDirImpl(Node node, uint index)
        {
            IDCookie cookie = (IDCookie)node.Cookie;
            OPT opt = (OPT)cookie.ID;

            // Do list ;)
            if (opt == OPT.LIST)
            {
                if (index == 0)
                    return makeByName("bind");
                else if (index == 1)
                    return makeByName("connect");
            }

            return null;
        }
예제 #9
0
        private void TelnetSendSubopt(OPT option, string val)
        {
            byte[] bval = (new ASCIIEncoding()).GetBytes(val);
            byte[] data = new byte[6 + val.Length];
            int    i    = 0;

            data[i++] = (byte)CMD.IAC;
            data[i++] = (byte)CMD.SB;
            data[i++] = (byte)option;
            data[i++] = 0;
            bval.CopyTo(data, i);
            i        += bval.Length;
            data[i++] = (byte)CMD.IAC;
            data[i++] = (byte)CMD.SE;
            this.stream.Write(data, 0, data.Length);
        }
예제 #10
0
        static void Main(string[] args)
        {
            string processName_1 = "launcher";
            string processName_2 = "client";

            Console.Write("Loading configuration info from config.opt...");
            OPT.Read();
            Console.WriteLine("[OK]");

            Console.Write("Checking for open Launcher...");

            if (Process.GetProcessesByName(processName_1).Length > 0)
            {
                foreach (var process in Process.GetProcessesByName(processName_1))
                {
                    process.Kill();
                }
            }

            if (Process.GetProcessesByName(processName_2).Length > 0)
            {
                foreach (var process in Process.GetProcessesByName(processName_2))
                {
                    process.Kill();
                }
            }

            Console.Write("[OK]\nConnecting to the Portal Server...");
            try
            {
                if (ServerManager.Instance.Start(OPT.GetString("ip"), OPT.GetInt("port")))
                {
                    Console.Write("[OK]\nRequesting communication key...");
                    ServerPackets.Instance.US_RequestDesKey();
                }
                else
                {
                    Console.WriteLine("[FAIL]");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Errors:\n\t{0}", ex.ToString());
            }

            Console.ReadLine();
        }
예제 #11
0
        public void TS_Load_File_Click(object sender, EventArgs e)
        {
            if (!structLoaded)
            {
                MessageBox.Show("You can not do that until a structure has been loaded!", "Structure Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            Paths.DefaultDirectory = OPT.GetString("rdb.load.directory");
            string fileName = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "User cancelled file load on tab: {0}", tManager.Text);
                return;
            }

            load_file(fileName);
        }
예제 #12
0
        public AutoMapperProfiles()
        {
            CreateMap <AppUser, MemberDTO>()
            .ForMember(
                dest => dest.PhotoUrl,
                opt => opt.MapFrom(
                    src => src.Photos.FirstOrDefault(
                        x => x.IsMain
                        ).Url))
            .ForMember(
                dest => dest.Age,
                OPT => OPT.MapFrom(
                    src => src.DateOfBirth.CalculateAge()
                    ));

            CreateMap <Photo, PhotoDTO>();

            CreateMap <MemberUpdateDTO, AppUser>();
        }
예제 #13
0
        private void updatesGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            int    saveType = 99;
            string fileName = updatesGrid.Rows[e.RowIndex].Cells[0].Value.ToString();
            bool   state    = (bool)updatesGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

            if (e.ColumnIndex == updatesGrid.Columns[2].Index && e.RowIndex != -1) // Legacy
            {
                OPT.AlterLegacyIndex(fileName, state);
                saveType = 0;
            }
            else if (e.ColumnIndex == updatesGrid.Columns[3].Index && e.RowIndex != -1) // Delete
            {
                OPT.AlterDeleteIndex(fileName, state);
                saveType = 1;
            }

            OPT.SaveIndex(saveType);
        }
예제 #14
0
        public ClientPackets()
        {
            debug = OPT.GetBool("debug");

            // Loads PacketsDb
            PacketsDb = new Dictionary <ushort, PacketAction>();

            #region Packets
            PacketsDb.Add(0x0001, CS_RequestUpdateDateTime);
            PacketsDb.Add(0x0002, CS_RequestSelfUpdate);
            PacketsDb.Add(0x0003, CS_RequestUpdater);
            PacketsDb.Add(0x0010, CS_RequestUpdateIndex);
            PacketsDb.Add(0x0040, CS_RequestSendType);
            PacketsDb.Add(0x0041, CS_RequestFileTransfer);
            PacketsDb.Add(0x0030, CS_RequestArguments);
            PacketsDb.Add(0x0100, CS_RequestValidation);
            PacketsDb.Add(0x00DC, CS_RequestDisconnect);
            PacketsDb.Add(0x9999, CS_RequestDesKey);
            #endregion
        }
예제 #15
0
        public MappingUserProfile()
        {
            CreateMap <M.Request.UsuarioRequest, M.Entidades.USER_LAB>()
            .ForMember(DEST => DEST.EMAIL, OPT => OPT.MapFrom(input => input.correo))
            .ForMember(DEST => DEST.FIRST_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoPaterno))
            .ForMember(DEST => DEST.SECOND_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoMaterno))
            .ForMember(DEST => DEST.FIRST_NAME, OPT => OPT.MapFrom(input => input.primerNombre))
            .ForMember(DEST => DEST.SECOND_NAME, OPT => OPT.MapFrom(input => input.segundoNombre))
            .ForMember(DEST => DEST.PASSWORD, OPT => OPT.MapFrom(input => input.contrasena))
            .ForMember(DEST => DEST.USR, OPT => OPT.MapFrom(input => input.usuario))
            .ForMember(DEST => DEST.ID_USER_ROL, OPT => OPT.MapFrom(input => input.idRol)).ReverseMap();

            CreateMap <M.Response.UsuarioResponse, M.Entidades.USER_LAB>()
            .ForMember(DEST => DEST.EMAIL, OPT => OPT.MapFrom(input => input.correo))
            .ForMember(DEST => DEST.FIRST_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoPaterno))
            .ForMember(DEST => DEST.SECOND_LAST_NAME, OPT => OPT.MapFrom(input => input.apellidoMaterno))
            .ForMember(DEST => DEST.FIRST_NAME, OPT => OPT.MapFrom(input => input.primerNombre))
            .ForMember(DEST => DEST.SECOND_NAME, OPT => OPT.MapFrom(input => input.segundoNombre))
            .ForMember(DEST => DEST.PASSWORD, OPT => OPT.MapFrom(input => input.contrasena))
            .ForMember(DEST => DEST.USR, OPT => OPT.MapFrom(input => input.usuario))
            .ForMember(DEST => DEST.ID_USER_ROL, OPT => OPT.MapFrom(input => input.idRol)).ReverseMap();
        }
예제 #16
0
        /// <summary>
        /// Triggered when a client tries to connect
        /// </summary>
        /// <param name="ar"></param>
        private void AcceptCallback(IAsyncResult ar)
        {
            Socket listener = (Socket)ar.AsyncState;
            Socket socket   = listener.EndAccept(ar);

            // Starts to accept another connection
            listener.BeginAccept(new AsyncCallback(AcceptCallback), listener);

            Client client = new Client(socket);

            if (OPT.GetBool("debug"))
            {
                Console.WriteLine("Client [{0}] connected from: {1} [{2}]", client.Id, client.Ip, client.Port);
            }

            clientList.Add(client);

            socket.BeginReceive(
                client.Buffer, 0, PacketStream.MaxBuffer, SocketFlags.None,
                new AsyncCallback(ReadCallback), client
                );
        }
예제 #17
0
        /// <summary>
        /// FS finddir
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="name">The name to look for</param>
        /// <returns>The node</returns>
        private static unsafe Node findDirImpl(Node node, string name)
        {
            IDCookie cookie = (IDCookie)node.Cookie;
            OPT opt = (OPT)cookie.ID;
            
            if (opt == OPT.LIST)
            {
                if (name.Equals("bind"))
                    return byID(OPT.BIND);
                else if (name.Equals("connect"))
                    return byID(OPT.SOCK);
            }
            else if (opt == OPT.SOCK)
            {
                return UDPSocketDevice.Open(name);
            }
            else if (opt == OPT.BIND)
            {
                return UDPBindSocketDevice.Open(name);
            }

            return null;
        }
예제 #18
0
파일: GUI.cs 프로젝트: odasm/rMOD
        private async void saveFileBtn_Click(object sender, EventArgs e)
        {
            DataCore.Core dCore = new DataCore.Core();

            if (RDBControls.GridRows > 0)
            {
                string savePath = OPT.GetString("save.directory");
                if (string.IsNullOrEmpty(savePath))
                {
                    string structFileName = structFileName = string.Format(@"{0}.{1}", StructureManager.FileName(RDBControls.StructureListValue), rCore.Extension);
                    string fileName       = OPT.GetBool("save.hashed") ? dCore.EncodeName(structFileName) : structFileName;

                    using (SaveFileDialog sfDlg = new SaveFileDialog()
                    {
                        Filter = "All files (*.*)|*.*|RDB files (*.rdb)|*.rdb|REF files (*.ref)|*.ref", Title = "Define the name of your rdb", FileName = fileName
                    })
                    {
                        if (sfDlg.ShowDialog(this) == DialogResult.OK)
                        {
                            if (!string.IsNullOrEmpty(sfDlg.FileName))
                            {
                                savePath = sfDlg.FileName;
                            }
                        }
                    }
                }
                else
                {
                    savePath += GuessName.Result(RDBControls.StructureListValue, NameType.File);
                }

                if (!string.IsNullOrEmpty(savePath))
                {
                    await Task.Run(() => { rdbCores[tabIdx].WriteRDB(savePath); });
                }
            }
        }
예제 #19
0
        private void insert_files(string[] filePaths)
        {
            using (GUI.MessageListBox msgbox = new GUI.MessageListBox("Review Files", "You are about to import the following files!\r\n\r\nAre you sure you want to do that?", filePaths))
            {
                msgbox.ShowDialog(GUI.Main.Instance);
                if (msgbox.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            try
            {
                foreach (string filePath in filePaths)
                {
                    tab_disabled = true;
                    string msg = string.Format("Importing: {0}...", Path.GetFileName(filePath));
                    ts_status.Text = msg;
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, msg);

                    core.ImportFileEntry(filePath);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Import Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
            }
            finally
            {
                core.Save(OPT.GetString("build.directory"));

                tab_disabled   = false;
                ts_status.Text = string.Empty;
            }
        }
예제 #20
0
 private void networkListenerMaintenance_Click(object sender, EventArgs e)
 {
     OPT.UpdateSetting("maintenance", (OPT.GetBool("maintenance") ? "0" : "1"));
 }
예제 #21
0
 private void TelnetSendSubopt(OPT option, string val)
 {
     byte[] bval = (new ASCIIEncoding()).GetBytes(val);
     byte[] data = new byte[6 + val.Length];
     int i = 0;
     data[i++] = (byte) CMD.IAC;
     data[i++] = (byte) CMD.SB;
     data[i++] = (byte) option;
     data[i++] = 0;
     bval.CopyTo(data, i);
     i += bval.Length;
     data[i++] = (byte) CMD.IAC;
     data[i++] = (byte) CMD.SE;
     this._RequestData(data);
 }
예제 #22
0
파일: GUI.cs 프로젝트: odasm/rMOD
 private void useASCIIBtn_Click(object sender, EventArgs e)
 {
     useASCIIBtn.Checked = (useASCIIBtn.Checked) ? false : true;
     OPT.UpdateSetting("use.ascii", Convert.ToInt32(useASCIIBtn.Checked).ToString());
 }
예제 #23
0
        private async void GUI_Shown(object sender, EventArgs e)
        {
            OPT.LoadSettings();
            DesCipher = new XDes(OPT.GetString("des.key"));

            Statistics.SetIO();
            Statistics.StartUptime();

            clientList = new Dictionary <int, Client>();

            Output.Write(new Structures.Message()
            {
                Text = "Indexing legacy file names..."
            });
            OPT.LoadLegacyIndex();
            Output.Write(new Structures.Message()
            {
                Text = string.Format("[OK]\n\t- {0} legacy files indexed!", OPT.LegacyCount), AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Indexing delete file names..."
            });
            OPT.LoadDeleteFiles();
            Output.Write(new Structures.Message()
            {
                Text = string.Format("[OK]\n\t- {0} delete files indexed!", OPT.DeleteCount), AddBreak = true
            });

            await Task.Run(() => { IndexManager.Build(false); });

            Output.Write(new Structures.Message()
            {
                Text = "Checking for tmp directory..."
            });
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            clearTmp();

            Output.Write(new Structures.Message()
            {
                Text = string.Format("Initializing client listener...{0}", (ClientManager.Instance.Start()) ? "[OK]" : "[FAIL]"), AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Initializing Index Rebuild Service..."
            });
            int rebuildInterval = OPT.GetInt("rebuild.interval") * 1000;

            indexTimer = new Timer()
            {
                Enabled = true, Interval = rebuildInterval
            };
            indexTimer.Tick += indexTick;
            indexTimer.Start();
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Initializing OTP Reset Service..."
            });
            otpTimer = new Timer()
            {
                Enabled = true, Interval = 300000
            };
            otpTimer.Tick += otpTick;
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Initializing Statistics Update Service..."
            });
            Statistics.StartUpdating();
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            toolTip.SetToolTip(setWTBtn, "Sets the Updates folder last write time to the current time");
        }
예제 #24
0
 private void TelnetSendSubopt(OPT option, string val)
 {
     byte[] bval = (new System.Text.ASCIIEncoding()).GetBytes(val);
     byte[] data = new byte[6+val.Length];
     int i=0;
     data[i++] = (byte)CMD.IAC;
     data[i++] = (byte)CMD.SB;
     data[i++] = (byte)option;
     data[i++] = 0;
     bval.CopyTo(data, i); i += bval.Length;
     data[i++] = (byte)CMD.IAC;
     data[i++] = (byte)CMD.SE;
     stream.Write(data, 0, data.Length);
 }