Exemple #1
0
        private void EditSelected()
        {
            if (lvKeys.SelectedItems.Count <= 0 || lvKeys.SelectedItems[0] == null)
            {
                return;
            }

            Key k = m_Keys.FindLast(key => key.FileName.ToLower() == lvKeys.SelectedItems[0].Text.ToLower());

            if (k == null)
            {
                return;
            }

            EditKeyDlg Dlg = new EditKeyDlg();

            Dlg.Title("Edit");
            Dlg.Set(k);

            if (Dlg.ShowDialog() == DialogResult.OK)
            {
                Key res = Dlg.Get();
                int ind = m_Keys.IndexOf(k);
                m_Keys.Remove(k);
                m_Keys.Insert(ind, res);
            }
            ReloadItems();
            KeyDatabase.Save();
        }
Exemple #2
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (lvKeys.SelectedItems.Count <= 0 || lvKeys.SelectedItems[0] == null)
            {
                return;
            }

            Key k = m_Keys.FindLast(key => key.FileName.ToLower() == lvKeys.SelectedItems[0].Text.ToLower());

            if (k == null)
            {
                return;
            }

            if (MessageBox.Show(String.Format("Are you sure you want to delete the key for {0}?", k.FileName)
                                , "Attention!"
                                , MessageBoxButtons.YesNo
                                , MessageBoxIcon.Question) == DialogResult.Yes)
            {
                m_Keys.Remove(k);
            }

            ReloadItems();
            KeyDatabase.Save();
        }
Exemple #3
0
        public KeyDbDlg()
        {
            InitializeComponent();

            m_Keys = KeyDatabase.Get();

            ReloadItems();
        }
Exemple #4
0
 void ResetKeyList()
 {
     KeyDatabase.Clear();
     if (File.Exists(Strings.XorKeyFile))
     {
         File.Delete(Strings.XorKeyFile);
     }
     KeyDatabase.Save();
 }
Exemple #5
0
        public MainDlg()
        {
            InitializeComponent();

            SetupColors();
            SetLoadedState(false);

            if (Extensions.IsAdministrator())
            {
                lbStatus.Image = Properties.Resources.Admin;
            }

            KeyDatabase.Load();

            pbPreview.Width    = 0;
            pbPreview.Visible  = false;
            rtbPreview.Width   = 0;
            rtbPreview.Visible = false;
            pnlPreview.Visible = false;
            splitContainer.SplitterDistance = this.Width;

            comboEncrypt.SelectedIndex = (int)Properties.Settings.Default.EncryptionType;

            string[] args = Environment.GetCommandLineArgs();

            string sFile = "";

            if (args.Length >= 2)
            {
                sFile = args[1];
            }
            if (args.Length >= 3)
            {
                m_XorKey = args[2];
            }

            if (File.Exists(sFile))
            {
                LoadZipFile(sFile);
            }
        }
Exemple #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            EditKeyDlg Dlg = new EditKeyDlg();

            Dlg.Title("Add");
            if (Dlg.ShowDialog() == DialogResult.OK)
            {
                Key k = Dlg.Get();

                if (!m_Keys.Exists(k.FileName))
                {
                    m_Keys.Add(Dlg.Get());
                }
                else
                {
                    MessageBox.Show("A key already exists for this file!", "Error!");
                }

                ReloadItems();

                KeyDatabase.Save();
            }
        }
Exemple #7
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        //
        //          ZIP Handlers
        //
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        public void LoadZipFile(string path, bool breakOnFail = false)
        {
            m_File    = path;
            this.Text = String.Format(Strings.WindowNameLoaded, m_File, "");

            m_Archive = new Archive(m_File, true, (EncryptionType)comboEncrypt.SelectedIndex);
            List <ArchiveEntry> entries = m_Archive.getEntries();

            if (m_Archive == null || entries == null)
            {
                if (breakOnFail)
                {
                    MessageBox.Show("The file is not a valid zip file or the Xor key is wrong!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CloseCurrentFile();
                    return;
                }

                if (!KeyDatabase.SearchKey(Path.GetFileName(path), out m_XorKey) ||
                    MessageBox.Show(String.Format("The Key {0} was found for {1} in our database, would you like to use it?", m_XorKey, Path.GetFileName(path))
                                    , "A key was found!"
                                    , MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                {
                    XorDlg xor = new XorDlg();
                    xor.SetType(XorType.Decrypt);

                    if (xor.ShowDialog() != DialogResult.OK)
                    {
                        CloseCurrentFile();
                        return;
                    }

                    m_XorKey = xor.XorKey;
                }

                if (String.IsNullOrEmpty(m_XorKey))
                {
                    CloseCurrentFile();
                    return;
                }

                string decryptedPath = String.Format("{0}{1}", Path.GetTempPath(), Path.GetFileName(path));

                if (File.Exists(decryptedPath))
                {
                    File.Delete(decryptedPath);
                }

                File.Copy(path, decryptedPath);

                // Decrypt here
                XorFile(decryptedPath, m_XorKey);

                LoadZipFile(decryptedPath, true);

                File.Delete(decryptedPath);
                return;
            }

            // Load associated icons


            foreach (ArchiveEntry entry in entries)
            {
                AddFile(entry.getNameExtension(), entry.getExtension(), entry.getSizeData(), entry.getId(), path + "\\" + entry.getName());
            }

            SetLoadedState(true);
        }