Пример #1
0
        private void newToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // create a new signature form
            using (frmSignature sig = new frmSignature())
            {
                // set the id of the signature
                sig.numId.Text = Signatures.NextId().ToString();

                // if the signature dialog was closed okay
                if (sig.ShowDialog() == DialogResult.OK)
                {
                    // add the new signature
                    var s = new Signature()
                    {
                        Id          = Convert.ToInt32(sig.numId.Text),
                        Definition  = sig.txtDefinition.Text,
                        Description = sig.txtDescription.Text,
                        DateFound   = sig.txtDate.Text
                    };

                    // update the sig pattern
                    s.SetPatternBytes(sig.txtPattern.Text);

                    // add the signature to the controller
                    Signatures.AddOne(s);

                    // update listview item
                    this.lstSignatures.Items.Add(new ListViewItem(new string[] { s.Id.ToString(), s.Definition, s.GetPatternHex(), s.Description, s.DateFound }));

                    // update sig count
                    updateStats();
                }
            }
        }
Пример #2
0
        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Signatures = new SignatureController("test.sdb");
            Signatures.SetDbVersion(3.3);
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                using (System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName))
                {
                    while (sr.Peek() > 0)
                    {
                        string   line = sr.ReadLine();
                        string[] data = line.Split('=');
                        this.lstSignatures.Items.Add(new ListViewItem(new string[]
                        {
                            (lstSignatures.Items.Count + 1).ToString(),
                            data[0],
                            format(data[1].ToUpper()),
                            "TEST",
                            DateTime.Now.ToShortDateString()
                        }));

                        var sig = new Signature()
                        {
                            Id          = Signatures.NextId(),
                            DateFound   = DateTime.Now.ToShortDateString(),
                            Definition  = data[0],
                            Description = "Imported"
                        };

                        sig.SetPatternBytes(format(data[1].ToUpper()));

                        Signatures.AddOne(sig);
                    }
                }
            }
        }