Exemple #1
0
        public IdenticalsForm(List <SumResult> list)
        {
            InitializeComponent();
            Options.ApplyTheme(this);
            helperMenu.Renderer = new MoonMenuRenderer();

            this.Text = Options.TranslationList["btnFindIdenticals"].ToString();
            copyToolStripMenuItem.Text       = Options.TranslationList["copyToolStripMenuItem"].ToString();
            saveAsJSONToolStripMenuItem.Text = Options.TranslationList["btnSaveJson"].ToString();

            ConfigureGUI();
            _identicals = list;

            if (boxSelectHash.Items.Count > 0)
            {
                boxSelectHash.SelectedIndex = 0;
            }

            SumView.Select();
            SumView.Focus();
            if (SumView.Nodes.Count > 0)
            {
                SumView.Nodes[0].EnsureVisible();
            }
        }
Exemple #2
0
        private void ListIdenticals()
        {
            foreach (SumResult sr in _identicals)
            {
                if (!_md5s.Contains(sr.MD5))
                {
                    _md5s.Add(sr.MD5);
                }
            }

            foreach (string x in _md5s)
            {
                TreeNode rootNode = new TreeNode(x);
                rootNode.ForeColor = Options.ForegroundColor;

                foreach (SumResult y in _identicals)
                {
                    if (y.MD5 == x)
                    {
                        rootNode.Nodes.Add(y.File);
                    }
                }

                SumView.Nodes.Add(rootNode);
            }

            SumView.ExpandAll();
        }
Exemple #3
0
        private void boxSelectHash_SelectedIndexChanged(object sender, EventArgs e)
        {
            SumView.Nodes.Clear();

            _helper = $"{boxSelectHash.SelectedItem}: ";
            SumResult tmp;

            switch (boxSelectHash.SelectedItem.ToString())
            {
            case "MD5":
                ListIdenticals(HashCode.MD5);
                break;

            case "SHA1":
                ListIdenticals(HashCode.SHA1);
                break;

            case "SHA256":
                ListIdenticals(HashCode.SHA256);
                break;

            case "SHA384":
                ListIdenticals(HashCode.SHA384);
                break;

            case "SHA512":
                ListIdenticals(HashCode.SHA512);
                break;

            case "RIPEMD160":
                ListIdenticals(HashCode.RIPEMD160);
                break;

            case "CRC32":
                ListIdenticals(HashCode.CRC32);
                break;

            case "SHA3-256":
                ListIdenticals(HashCode.SHA3_256);
                break;

            case "SHA3-384":
                ListIdenticals(HashCode.SHA3_384);
                break;

            case "SHA3-512":
                ListIdenticals(HashCode.SHA3_512);
                break;
            }

            SumView.Select();
            SumView.Focus();
            if (SumView.Nodes.Count > 0)
            {
                SumView.Nodes[0].EnsureVisible();
            }
        }
Exemple #4
0
        private void RefreshSumList()
        {
            if ((SumResult.Sums != null) && (SumResult.Sums.Count > 0))
            {
                SumView.Nodes.Clear();

                foreach (SumResult sr in SumResult.Sums)
                {
                    TreeNode rootNode = new TreeNode(sr.File);

                    rootNode.ForeColor = Options.ForegroundColor;
                    rootNode.Tag       = Options.ThemeFlag;

                    if (Options.CurrentOptions.HashOptions.MD5)
                    {
                        rootNode.Nodes.Add("MD5: " + sr.MD5);
                    }
                    if (Options.CurrentOptions.HashOptions.SHA1)
                    {
                        rootNode.Nodes.Add("SHA1: " + sr.SHA1);
                    }
                    if (Options.CurrentOptions.HashOptions.SHA256)
                    {
                        rootNode.Nodes.Add("SHA256: " + sr.SHA256);
                    }
                    if (Options.CurrentOptions.HashOptions.SHA384)
                    {
                        rootNode.Nodes.Add("SHA384: " + sr.SHA384);
                    }
                    if (Options.CurrentOptions.HashOptions.SHA512)
                    {
                        rootNode.Nodes.Add("SHA512: " + sr.SHA512);
                    }
                    if (Options.CurrentOptions.HashOptions.CRC32)
                    {
                        rootNode.Nodes.Add("CRC32: " + sr.CRC32);
                    }
                    if (Options.CurrentOptions.HashOptions.RIPEMD160)
                    {
                        rootNode.Nodes.Add("RIPEMD160: " + sr.RIPEMD160);
                    }

                    SumView.Nodes.Add(rootNode);
                    SumView.ExpandAll();
                }
            }
        }
Exemple #5
0
        private void CalculateSums(bool analyzeJson = false)
        {
            Task.Factory.StartNew(() =>
            {
                lblCalculating.Invoke((MethodInvoker) delegate
                {
                    btnClear.Enabled          = false;
                    btnOptions.Enabled        = false;
                    btnSaveJson.Enabled       = false;
                    btnFindIdenticals.Enabled = false;
                    btnCompare.Enabled        = false;
                    btnBrowse.Enabled         = false;
                    btnCalculate.Enabled      = false;
                    txtPath.Enabled           = false;
                    lblCalculating.Text       = "Calculating...";
                    lblCalculating.Visible    = true;
                }
                                      );

                foreach (string f in _fileList)
                {
                    if (File.Exists(f))
                    {
                        SumResult.Sums.Add(Utilities.CalculateSums(f));
                    }
                }
            }
                                  )
            .ContinueWith((prevTask) =>
            {
                if ((SumResult.Sums != null) && (SumResult.Sums.Count > 0))
                {
                    SumView.Nodes.Clear();

                    TreeNode rootNode = null;
                    _analyzedFiles    = new List <string>();

                    if (analyzeJson)
                    {
                        for (int i = 0; i < SumResult.Sums.Count; i++)
                        {
                            rootNode = new TreeNode(SumResult.Sums[i].File);

                            rootNode.ForeColor = Options.ForegroundColor;
                            rootNode.Tag       = Options.ThemeFlag;

                            if (Options.CurrentOptions.HashOptions.MD5)
                            {
                                rootNode.Nodes.Add("MD5: " + SumResult.Sums[i].MD5);
                                if (SumResult.Sums[i].MD5 == _fileSummaries[i].MD5)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            if (Options.CurrentOptions.HashOptions.SHA1)
                            {
                                rootNode.Nodes.Add("SHA1: " + SumResult.Sums[i].SHA1);
                                if (SumResult.Sums[i].SHA1 == _fileSummaries[i].SHA1)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            if (Options.CurrentOptions.HashOptions.SHA256)
                            {
                                rootNode.Nodes.Add("SHA256: " + SumResult.Sums[i].SHA256);
                                if (SumResult.Sums[i].SHA256 == _fileSummaries[i].SHA256)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            if (Options.CurrentOptions.HashOptions.SHA384)
                            {
                                rootNode.Nodes.Add("SHA384: " + SumResult.Sums[i].SHA384);
                                if (SumResult.Sums[i].SHA384 == _fileSummaries[i].SHA384)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            if (Options.CurrentOptions.HashOptions.SHA512)
                            {
                                rootNode.Nodes.Add("SHA512: " + SumResult.Sums[i].SHA512);
                                if (SumResult.Sums[i].SHA512 == _fileSummaries[i].SHA512)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            if (Options.CurrentOptions.HashOptions.CRC32)
                            {
                                rootNode.Nodes.Add("CRC32: " + SumResult.Sums[i].CRC32);
                                if (SumResult.Sums[i].CRC32 == _fileSummaries[i].CRC32)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            if (Options.CurrentOptions.HashOptions.RIPEMD160)
                            {
                                rootNode.Nodes.Add("RIPEMD160: " + SumResult.Sums[i].RIPEMD160);
                                if (SumResult.Sums[i].RIPEMD160 == _fileSummaries[i].RIPEMD160)
                                {
                                    _analyzedFiles.Add(_fileSummaries[i].File);
                                }
                            }

                            SumView.Invoke((MethodInvoker) delegate
                            {
                                SumView.Nodes.Add(rootNode);
                            });
                        }
                    }
                    else
                    {
                        for (int i = 0; i < SumResult.Sums.Count; i++)
                        {
                            rootNode = new TreeNode(SumResult.Sums[i].File);

                            rootNode.ForeColor = Options.ForegroundColor;
                            rootNode.Tag       = Options.ThemeFlag;

                            if (Options.CurrentOptions.HashOptions.MD5)
                            {
                                rootNode.Nodes.Add("MD5: " + SumResult.Sums[i].MD5);
                            }
                            if (Options.CurrentOptions.HashOptions.SHA1)
                            {
                                rootNode.Nodes.Add("SHA1: " + SumResult.Sums[i].SHA1);
                            }
                            if (Options.CurrentOptions.HashOptions.SHA256)
                            {
                                rootNode.Nodes.Add("SHA256: " + SumResult.Sums[i].SHA256);
                            }
                            if (Options.CurrentOptions.HashOptions.SHA384)
                            {
                                rootNode.Nodes.Add("SHA384: " + SumResult.Sums[i].SHA384);
                            }
                            if (Options.CurrentOptions.HashOptions.SHA512)
                            {
                                rootNode.Nodes.Add("SHA512: " + SumResult.Sums[i].SHA512);
                            }
                            if (Options.CurrentOptions.HashOptions.CRC32)
                            {
                                rootNode.Nodes.Add("CRC32: " + SumResult.Sums[i].CRC32);
                            }
                            if (Options.CurrentOptions.HashOptions.RIPEMD160)
                            {
                                rootNode.Nodes.Add("RIPEMD160: " + SumResult.Sums[i].RIPEMD160);
                            }

                            SumView.Invoke((MethodInvoker) delegate
                            {
                                SumView.Nodes.Add(rootNode);
                            });
                        }
                    }

                    SumView.Invoke((MethodInvoker) delegate
                    {
                        SumView.ExpandAll();
                    });

                    lblCalculating.Invoke((MethodInvoker) delegate
                    {
                        lblCalculating.Text       = "Calculating...";
                        lblCalculating.Visible    = false;
                        btnClear.Enabled          = true;
                        btnOptions.Enabled        = true;
                        btnSaveJson.Enabled       = true;
                        btnFindIdenticals.Enabled = true;
                        btnCompare.Enabled        = true;
                        btnBrowse.Enabled         = true;
                        btnCalculate.Enabled      = true;
                        txtPath.Enabled           = true;
                    }
                                          );

                    try
                    {
                        SumView.Nodes[0].EnsureVisible();
                    }
                    catch { }

                    // opening VirusTotal, after enabling SHA256 hash
                    if (_tempIndex > -1)
                    {
                        Utilities.SearchVirusTotal(SumResult.Sums[_tempIndex].SHA256);
                        _tempIndex = -1;
                    }
                }

                // if JSON analyzation is enabled, show results
                if (analyzeJson)
                {
                    if (_analyzedFiles.Distinct().Count() > 0)
                    {
                        AnalyzedForm f = new AnalyzedForm(_analyzedFiles.Distinct());
                        f.ShowDialog();
                    }
                    else
                    {
                        TopMostMessageBox.Show("All files analyzed by JSON are corrupted!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
                          );
        }
Exemple #6
0
        private void ListIdenticals(HashCode algo)
        {
            List <TreeNode> nodes = new List <TreeNode>();

            if (algo == HashCode.MD5)
            {
                _uniqueHashes = _identicals.Select(x => x.MD5).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.MD5 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA1)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA1).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA1 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA256)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA256).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA256 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA384)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA384).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA384 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA512)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA512).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA512 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.RIPEMD160)
            {
                _uniqueHashes = _identicals.Select(x => x.RIPEMD160).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.RIPEMD160 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.CRC32)
            {
                _uniqueHashes = _identicals.Select(x => x.CRC32).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.CRC32 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA3_256)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA3_256).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA3_256 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA3_384)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA3_384).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA3_384 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            if (algo == HashCode.SHA3_512)
            {
                _uniqueHashes = _identicals.Select(x => x.SHA3_512).Distinct();

                foreach (string x in _uniqueHashes)
                {
                    TreeNode fileNode = new TreeNode(x);
                    fileNode.ForeColor = Options.ForegroundColor;

                    _identicals.FindAll(z => z.SHA3_512 == x).ForEach(y =>
                    {
                        fileNode.Nodes.Add(y.File);
                    });

                    nodes.Add(fileNode);
                }
            }

            SumView.Nodes.AddRange(nodes.ToArray());
            SumView.ExpandAll();
        }