C# Antivirüs programında "Hata CS0103 geçerli bağlamda yok" hatası

Katılım
12 Mayıs 2016
Mesajlar
1.547
Çözümler
5
Öncelikle 2 tane basit Antivirüs programı yaptım. Birisi tamamlandı. Diğeri bir türlü olmadı. Kod şu:
Bu içeriği görüntülemek için üçüncü taraf çerezlerini yerleştirmek için izninize ihtiyacımız olacak.
Daha detaylı bilgi için, çerezler sayfamıza bakınız.

İlk hata:
Önem Derecesi Kod Açıklama Proje Dosya Çizgi Gizleme Durumu
Hata CS1061 'ContextMenuStrip' bir 'OpenRead' tanımı içermiyor ve 'ContextMenuStrip' türünde bir ilk bağımsız değişken kabul eden hiçbir erişilebilir 'OpenRead' genişletme yöntemi bulunamadı (bir kullanma yönergeniz veya derleme başvurunuz eksik olabilir mi?) Antimalware C:\Users\Siber Güvenlik\source\repos\Antimalware\Antimalware\Form1.cs 25 Etkin

İkinci hata:
Önem Derecesi Kod Açıklama Proje Dosya Çizgi Gizleme Durumu
Hata CS1061 'ContextMenuStrip' bir 'ReadAllLines' tanımı içermiyor ve 'ContextMenuStrip' türünde bir ilk bağımsız değişken kabul eden hiçbir erişilebilir 'ReadAllLines' genişletme yöntemi bulunamadı (bir kullanma yönergeniz veya derleme başvurunuz eksik olabilir mi?) Antimalware C:\Users\Siber Güvenlik\source\repos\Antimalware\Antimalware\Form1.cs 34 Etkin

Üçüncü hata:
Önem Derecesi Kod Açıklama Proje Dosya Çizgi Gizleme Durumu
Hata CS0103 'tbMD5' adı geçerli bağlamda yok Antimalware C:\Users\Siber Güvenlik\source\repos\Antimalware\Antimalware\Form1.cs 35 Etkin

Dördüncü hata:
Önem Derecesi Kod Açıklama Proje Dosya Çizgi Gizleme Durumu
Hata CS0103 'tbMD5' adı geçerli bağlamda yok Antimalware C:\Users\Siber Güvenlik\source\repos\Antimalware\Antimalware\Form1.cs 78 Etkin

Beşinci hata:
Önem Derecesi Kod Açıklama Proje Dosya Çizgi Gizleme Durumu
Hata CS0103 'GetMD5FromFile' adı geçerli bağlamda yok Antimalware C:\Users\Siber Güvenlik\source\repos\Antimalware\Antimalware\Form1.cs 78 Etkin
Mesaj otomatik birleştirildi:

Kod şu:
C#:
using System;
using System.Drawing;
using System.IO;
using System.Security.Cryptography;
using System.Windows.Forms;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMDSFromFile(string filenPath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filenPath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream));
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt");
            if (md5signatures.Contains(tbMD5.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
                 ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                tbMD5.Text = GetMD5FromFile(ofd.FileName).Replace("-", string.Empty).ToLower();
            }
        }
private void fileToolStripMenuItem_Click(object sender, EventArgs e)
{
   
    }
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
  }
 }

YARA ve ClamAV üzerinden mi yapsam acaba?

Aslında Anti Malware demem daha doğru olur.

GetMDSFromFile yazdım 4 hata oldu.

C++:
using System;
using System;
using System.IO;
using System.Security.Cryptography;

namespace Antivirus
{
    class Program
    {
        static void Main(string[] args)
        {
            // Antivirüs programı çalıştığında taranacak klasör
            string folderPath = @"C:\Users\Username\Desktop\SampleFolder";

            // Log dosyası adı ve yolu
            string logFilePath = @"C:\Users\Username\Desktop\ScanLog.txt";

            // Klasördeki tüm dosyaları al
            string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);

            // MD5 karma değerleri için hash nesnesi oluştur
            using (var md5 = MD5.Create())
            {
                // Log dosyasını oluştur veya varsa üzerine yaz
                using (StreamWriter sw = File.CreateText(logFilePath))
                {
                    // Tüm dosyaları tarayarak MD5 hash değerlerini hesapla ve log dosyasına kaydet
                    foreach (string filePath in files)
                    {
                        using (var stream = File.OpenRead(filePath))
                        {
                            string hash = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
                            sw.WriteLine(filePath + ": " + hash);
                        }
                    }
                }
            }

            Console.WriteLine("Tarama tamamlandı. Log dosyası oluşturuldu.");
            Console.ReadLine();
        }
    }
}
ChatGPT onun yerine bunu gösterdi.

GetMD5 yapınca 4 oldu. GetMDS yazmayın.

C#:
sing System;
using System.Drawing;
using System.Security.Cryptography;
using System.Windows.Forms;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMD5FromFile(string filenPath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filenPath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream));
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt");
            if (md5signatures.Contains(tbMD5.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                tbMD5.Text = GetMD5FromFile(ofd.FileName).Replace("-", string.Empty).ToLower();
            }
        }
        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
Son durum.

ContextMenuStript'i silince 3 oldu.

C#:
using System;
using System.Drawing;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.IO;
using System.Linq;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMD5FromFile(string filePath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filePath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty).ToLower();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt").ToList();
            if (md5signatures.Contains(tbMD5.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                tbMD5.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
Şimdi 2 hata oldu.

Form1Designer.cs
C#:
namespace Antimalware
{
    partial class Form1
    {
        /// <summary>
        ///Gerekli tasarımcı değişkeni.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        ///Kullanılan tüm kaynakları temizleyin.
        /// </summary>
        ///<param name="disposing">yönetilen kaynaklar dispose edilmeliyse doğru; aksi halde yanlış.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer üretilen kod

        /// <summary>
        /// Tasarımcı desteği için gerekli metot - bu metodun
        ///içeriğini kod düzenleyici ile değiştirmeyin.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.browseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.label1 = new System.Windows.Forms.Label();
            this.IblStatus = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.menuStrip1.SuspendLayout();
            this.SuspendLayout();
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(151, 101);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(577, 26);
            this.textBox1.TabIndex = 0;
            this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
            //
            // textBox2
            //
            this.textBox2.Location = new System.Drawing.Point(151, 127);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(577, 26);
            this.textBox2.TabIndex = 2;
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(629, 159);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(99, 34);
            this.button1.TabIndex = 3;
            this.button1.Text = "Scan";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // menuStrip1
            //
            this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2);
            this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(820, 33);
            this.menuStrip1.TabIndex = 4;
            this.menuStrip1.Text = "menuStrip1";
            //
            // fileToolStripMenuItem
            //
            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.browseToolStripMenuItem,
            this.exitToolStripMenuItem});
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 29);
            this.fileToolStripMenuItem.Text = "File";
            this.fileToolStripMenuItem.Click += new System.EventHandler(this.fileToolStripMenuItem_Click);
            //
            // browseToolStripMenuItem
            //
            this.browseToolStripMenuItem.Name = "browseToolStripMenuItem";
            this.browseToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
            this.browseToolStripMenuItem.Text = "Browse";
            
            //
            // exitToolStripMenuItem
            //
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
            this.exitToolStripMenuItem.Text = "Exit";
            this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click_1);
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(111, 101);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(34, 20);
            this.label1.TabIndex = 5;
            this.label1.Text = "File";
            this.label1.Click += new System.EventHandler(this.label1_Click);
            //
            // IblStatus
            //
            this.IblStatus.AutoSize = true;
            this.IblStatus.Location = new System.Drawing.Point(161, 159);
            this.IblStatus.Name = "IblStatus";
            this.IblStatus.Size = new System.Drawing.Size(86, 20);
            this.IblStatus.TabIndex = 6;
            this.IblStatus.Text = "Status N/A";
            this.IblStatus.Click += new System.EventHandler(this.IblStatus_Click);
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(102, 133);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(43, 20);
            this.label3.TabIndex = 7;
            this.label3.Text = "MD5";
      
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(820, 243);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.IblStatus);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.menuStrip1);
            this.Controls.Add(this.textBox1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "Form1";
            this.Text = "Turko Antimalware Hash Test";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.TextBox textBox2;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem browseToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label IblStatus;
        private System.Windows.Forms.Label label3;
    }
}

Form1.cs Şimdi tek browse çalışmıyor.
C#:
using System;
using System.Drawing;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.IO;
using System.Linq;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMD5FromFile(string filePath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filePath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty).ToLower();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt");
            if (md5signatures.Contains(textBox1.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void IblStatus_Click(object sender, EventArgs e)
        {

        }

        

        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
      
        private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

Tamam hatayı çözdüm.

Çözüldü olarak işaretlenebilir mi? Github'a atacağım linki ve sonra kapatabilirsiniz. Hayır ya. Çok fazla false-positive veriyor.

.txt tarıyor sadece birde.

C#:
using System;
using System.Drawing;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.IO;
using System.Linq;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMD5FromFile(string filePath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filePath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty).ToLower();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt");
            if (md5signatures.Contains(textBox1.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void IblStatus_Click(object sender, EventArgs e)
        {

        }



        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void browseToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
Bunu yazınca düzeldi.

C#:
using System;
using System.Drawing;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.IO;
using System.Linq;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMD5FromFile(string filePath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filePath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty).ToLower();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt");
            if (md5signatures.Contains(textBox1.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void IblStatus_Click(object sender, EventArgs e)
        {

        }



        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void browseToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
Bunu yazınca düzeldi.

C#:
using System;
using System.Drawing;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.IO;
using System.Linq;

namespace Antimalware
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string GetMD5FromFile(string filePath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filePath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty).ToLower();
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var md5signatures = File.ReadAllLines("MD5base.txt");
            if (md5signatures.Contains(textBox1.Text))
            {
                IblStatus.Text = "Infected!";
                IblStatus.ForeColor = Color.Red;
            }
            else
            {
                IblStatus.Text = "Clean!";
                IblStatus.ForeColor = Color.Green;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void browseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Textfiles | *.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void IblStatus_Click(object sender, EventArgs e)
        {

        }



        private void fileToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Executable files|*.exe|Text files|*.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = GetMD5FromFile(ofd.FileName);
            }
        }

        private void browseToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

Şimdi tek iş kaldı o da hash dosyalarını kopyalamak.

1683362429241.png
 
Son düzenleme:

Technopat Haberler

Yeni konular

Geri
Yukarı