Turkıye anlasması
Kilopat
- Katılım
- 12 Mayıs 2016
- Mesajlar
- 1.117
- Çözümler
- 4
C#:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Security.Cryptography;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Linq;
using System.Data.SQLite;
using System.Threading;
using System.ComponentModel;
using Timer = System.Timers.Timer;
using System.Management;
using System.Net.Sockets;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace Antimalware
{
public partial class Form1 : Form
{
private bool blink;
private Timer timer;
private string currentDirectory;
// Initialize the BackgroundWorker outside the button click event
BackgroundWorker worker = new BackgroundWorker();
public Form1()
{
currentDirectory = Directory.GetCurrentDirectory();
// Open connections to the databases
OpenDatabaseConnection("MD5basedatabase.db");
OpenDatabaseConnection("SHA256VirusInfo.db");
OpenDatabaseConnection("main.db");
OpenDatabaseConnection("daily.db");
OpenDatabaseConnection("SHA256databasesqlite.db");
OpenDatabaseConnection("full_sha256.db");
OpenDatabaseConnection("IOC_Emotet.db");
OpenDatabaseConnection("Hash.db");
OpenDatabaseConnection("vxugfakedomain.db");
OpenDatabaseConnection("full_sha256.db");
OpenDatabaseConnection("Hash.db");
OpenDatabaseConnection("batchvirusbase.db");
OpenDatabaseConnection("SHA256hashes.db");
OpenDatabaseConnection("oldvirusbase.db");
OpenDatabaseConnection("virusbase.db");
// Wire up event handlers
worker.DoWork += Worker_DoWorkForHydra;
worker.RunWorkerCompleted += Worker_RunWorkerCompletedHydra;
InitializeComponent();
InitializeUI();
timer = new Timer();
timer.Interval = 100;
}
private void OpenDatabaseConnection(string databaseName)
{
string databasePath = Path.Combine(currentDirectory, databaseName);
SQLiteConnection connection = new SQLiteConnection($"Data Source={databasePath};Version=3;");
connection.Open();
// Save the connection to a list or use as needed
// For example: connectionsList.Add(connection);
}
public string GetMD5FromFile(string filePath)
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(filePath))
{
var hash = md5.ComputeHash(stream);
return BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();
}
}
}
private void InitializeUI()
{
// Form
this.Text = "HydraAV";
this.StartPosition = FormStartPosition.CenterScreen;
this.Size = new Size(1300, 770); // Form boyutunu ayarla
Controls.Add(listView1);
// Labels
var lblTitle = new Label();
lblTitle.Text = "HydraAV";
lblTitle.Font = new Font(lblTitle.Font.FontFamily, 16, FontStyle.Bold);
lblTitle.AutoSize = true;
lblTitle.Location = new Point(20, 20);
var lblFilePath = new Label();
lblFilePath.Text = "File Path:";
lblFilePath.AutoSize = true;
lblFilePath.Location = new Point(20, 60);
var lblStatus = new Label();
lblStatus.Name = "lblStatus"; // Eklenen satır
lblStatus.Text = "Status:";
lblStatus.AutoSize = true;
lblStatus.Location = new Point(20, 100);
// TextBoxes
var txtFilePath = new TextBox();
txtFilePath.Name = "txtFilePath"; // Eklenen satır
txtFilePath.Location = new Point(100, 60);
txtFilePath.Width = 200;
var txtStatus = new TextBox();
txtStatus.Name = "txtStatus"; // Eklenen satır
txtStatus.Location = new Point(100, 100);
txtStatus.Width = 200;
txtStatus.ReadOnly = true; // Sadece okunabilir olarak ayarlandı
// Buttons
var btnScan = new Button();
btnScan.Text = "Scan";
btnScan.Location = new Point(20, 140);
var btnDelete = new Button();
btnDelete.Text = "Delete";
btnDelete.Location = new Point(100, 140);
var btnExit = new Button();
btnExit.Text = "Exit";
btnExit.Location = new Point(180, 140);
// Add controls to form
this.Controls.Add(lblTitle);
this.Controls.Add(lblFilePath);
this.Controls.Add(lblStatus);
this.Controls.Add(txtFilePath);
this.Controls.Add(txtStatus);
this.Controls.Add(btnScan);
this.Controls.Add(btnDelete);
this.Controls.Add(btnExit);
// Event handlers
btnScan.Click += BtnScan_Click;
btnDelete.Click += BtnDelete_Click;
btnExit.Click += BtnExit_Click;
}
private async void BtnScan_Click(object sender, EventArgs e)
{
TextBox txtStatus = this.Controls.Find("txtStatus", true).FirstOrDefault() as TextBox;
Label IblStatus = this.Controls.Find("IblStatus", true).FirstOrDefault() as Label;
string filePath = textBox1.Text;
if (await Task.Run(() => IsFileInfected(filePath)))
{
IblStatus.Text = "Infected!";
IblStatus.ForeColor = Color.Red;
txtStatus.Text = "Infected!";
txtStatus.ForeColor = Color.Red;
DialogResult dialogResult = MessageBox.Show("The file is infected. Do you want to delete it?", "Warning", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
try
{
using (var md5 = MD5.Create())
{
using (var fileStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Delete))
{
var hash = md5.ComputeHash(fileStream);
var hashString = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
if (await Task.Run(() => IsFileInfected(hashString)))
{
fileStream.Close();
File.Delete(filePath);
MessageBox.Show("The file has been deleted successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
catch (UnauthorizedAccessException ex)
{
MessageBox.Show("Failed to delete the file. You do not have permission to delete this file. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (IOException ex)
{
MessageBox.Show("Failed to delete the file. The file is in use by another process. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show("Failed to delete the file. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
// Yanıp sönme animasyonunu başlat
await AnimateInfectedLabel();
}
else
{
IblStatus.Text = "Clean!";
IblStatus.ForeColor = Color.Green;
txtStatus.Text = "Clean!";
txtStatus.ForeColor = Color.Green;
}
}
private void BtnDelete_Click(object sender, EventArgs e)
{
TextBox txtFilePath = this.Controls.Find("txtFilePath", true).FirstOrDefault() as TextBox;
Label lblStatus = this.Controls.Find("lblStatus", true).FirstOrDefault() as Label;
string filePath = txtFilePath.Text;
if (File.Exists(filePath))
{
File.Delete(filePath);
lblStatus.Text = "File deleted successfully!";
}
else
{
lblStatus.Text = "File not found!";
}
}
private void BtnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private async void browseToolStripMenuItem_Click_1(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "All files|*.*|Text files|*.txt|Executable files|*.exe";
if (ofd.ShowDialog() == DialogResult.OK)
{
textBox1.Text = "Computing...";
textBox7.Text = "Computing...";
IblStatus.Text = "";
IblStatus.ForeColor = Color.Black;
button1.Enabled = false;
textBox1.Enabled = false;
textBox7.Enabled = false;
string md5Signature = await Task.Run(() =>
{
return GetMD5FromFile(ofd.FileName);
});
string sha256Signature = await Task.Run(() =>
{
return GetSHA256FromFile(ofd.FileName);
});
textBox1.Text = md5Signature;
textBox7.Text = sha256Signature;
button1.Enabled = true;
textBox1.Enabled = true;
textBox7.Enabled = true;
// Dosya tam adını göster
TextBox txtFilePath = this.Controls.Find("txtFilePath", true).FirstOrDefault() as TextBox;
if (txtFilePath != null)
{
txtFilePath.Text = ofd.FileName;
}
// Dosya tam adını göster
TextBox textBox2 = this.Controls.Find("textBox2", true).FirstOrDefault() as TextBox;
if (textBox2 != null)
{
textBox2.Text = ofd.FileName;
}
}
}
private async void button2_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
listView2.Items.Clear();
textBox5.Text = "";
textBox6.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox7.Text = "";
textBox1.Text = "";
textBox2.Text = "";
label4.Text = "Viruses";
label5.Text = "Clean files";
IblStatus.Text = "Status N/A";
IblStatus.ForeColor = Color.Black;
using (var folderDialog = new FolderBrowserDialog())
{
if (folderDialog.ShowDialog() != DialogResult.OK)
{
return;
}
var files = Directory.GetFiles(folderDialog.SelectedPath, "*", SearchOption.AllDirectories);
progressBar1.Maximum = files.Length;
progressBar1.Value = 0;
// Animation variables
string[] scanningFrames = { ".", "..", "..." };
int currentFrameIndex = 0;
label10.Visible = true;
Dictionary<string, string> infectedWithFileNameList = new Dictionary<string, string>();
Dictionary<string, string> cleanWithFileNameList = new Dictionary<string, string>();
// Start the animation and progress percentage
label10.Text = $"Scanning (0%)";
currentFrameIndex = (currentFrameIndex + 1) % scanningFrames.Length;
timer.Start();
await Task.Run(async () =>
{
int batchSize = 100; // Number of files to process in a batch
int filesProcessed = 0;
while (filesProcessed < files.Length)
{
var batchFiles = files.Skip(filesProcessed).Take(batchSize).ToArray();
await Task.WhenAll(batchFiles.Select(filePath => ProcessFileAsync(filePath)));
filesProcessed += batchFiles.Length;
// Update the animation
label10.Invoke(new Action(() => label10.Text += scanningFrames[currentFrameIndex]));
currentFrameIndex = (currentFrameIndex + 1) % scanningFrames.Length;
}
});
async Task ProcessFileAsync(string filePath)
{
bool isInfected;
string md5HashString;
using (var md5 = MD5.Create())
{
using (var fileStream = File.OpenRead(filePath))
{
var md5Hash = await Task.Run(() => md5.ComputeHash(fileStream));
md5HashString = BitConverter.ToString(md5Hash).Replace("-", "").ToLowerInvariant();
isInfected = IsFileInfected(md5HashString);
}
}
var item = new ListViewItem(new[] { filePath, isInfected ? "Infected!" : "Clean!" });
if (isInfected)
{
item.ForeColor = Color.Red;
infectedWithFileNameList[filePath] = md5HashString;
// Check if the file is locked by another process
bool isFileLocked = IsFileLocked(filePath);
if (isFileLocked)
{
string processName = GetProcessNameOfFile(filePath);
if (!string.IsNullOrEmpty(processName))
{
KillProcessUsingTaskkill(processName);
}
}
}
else
{
item.ForeColor = Color.Green;
cleanWithFileNameList[filePath] = md5HashString;
}
progressBar1.Invoke(new Action(() => progressBar1.Increment(1)));
int progressPercentage = (int)(((double)progressBar1.Value / progressBar1.Maximum) * 100);
label10.Invoke(new Action(() => label10.Text = $"Scanning ({progressPercentage}%)"));
}
foreach (var kvp in infectedWithFileNameList)
{
listView1.Items.Add(new ListViewItem(new[] { kvp.Key, kvp.Value })).ForeColor = Color.Red;
}
foreach (var kvp in cleanWithFileNameList)
{
listView2.Items.Add(new ListViewItem(new[] { kvp.Key, kvp.Value })).ForeColor = Color.Green;
}
textBox5.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Select(kvp => kvp.Value + " " + kvp.Key));
textBox6.Text = string.Join(Environment.NewLine, cleanWithFileNameList.Select(kvp => kvp.Value + " " + kvp.Key));
textBox3.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Values);
textBox4.Text = string.Join(Environment.NewLine, cleanWithFileNameList.Values);
textBox7.Text = CalculateCombinedSHA256(infectedWithFileNameList.Keys.Concat(cleanWithFileNameList.Keys));
textBox1.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Values);
textBox2.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Keys.Concat(cleanWithFileNameList.Keys));
label10.Text = "Scan complete.";
if (infectedWithFileNameList.Count > 0)
{
IblStatus.Text = "Infected!";
IblStatus.ForeColor = Color.Red;
await AnimateInfectedLabel();
}
else
{
IblStatus.Text = "Clean!";
IblStatus.ForeColor = Color.Green;
}
}
}
private string CalculateCombinedSHA256(IEnumerable<string> filePaths)
{
StringBuilder sb = new StringBuilder();
foreach (string filePath in filePaths)
{
string content = ReadFileContent(filePath);
string hash = CalculateSHA256(content);
sb.AppendLine(hash);
}
return sb.ToString();
}
private string ReadFileContent(string filePath)
{
try
{
return File.ReadAllText(filePath);
}
catch (Exception ex)
{
Console.WriteLine($"Error reading file: {ex.Message}");
return string.Empty;
}
}
private string CalculateSHA256(string content)
{
try
{
using (SHA256 algorithm = SHA256.Create())
{
byte[] hashBytes = algorithm.ComputeHash(Encoding.UTF8.GetBytes(content));
string hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
return hash;
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
return string.Empty;
}
}
private async void button10_Click(object sender, EventArgs e)
{
using (var dialog = new FolderBrowserDialog())
{
if (dialog.ShowDialog() == DialogResult.OK)
{
string selectedFolder = dialog.SelectedPath;
string[] files = Directory.GetFiles(selectedFolder, "*", SearchOption.AllDirectories);
textBox1.Clear();
textBox7.Clear();
// Set the maximum value of the progress bar
progressBar1.Maximum = files.Length;
await Task.Run(() =>
{
int processedFiles = 0;
int totalFiles = files.Length;
// Process files
foreach (string file in files)
{
// Calculate the SHA256 hash
string sha256Hash = CalculateSHA256(file);
// Calculate the MD5 hash
string md5Hash = CalculateMD5Hash(file);
// Update the text boxes and progress bar on the UI thread
Invoke((MethodInvoker)delegate
{
if (sha256Hash != null)
textBox7.AppendText(sha256Hash + Environment.NewLine);
if (md5Hash != null)
textBox1.AppendText(md5Hash + Environment.NewLine);
// Increment the processed files count
processedFiles++;
// Update the progress bar value
progressBar1.Value = processedFiles;
});
}
});
}
}
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
DialogResult result = MessageBox.Show("Are you sure you want to close the antivirus application?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
{
e.Cancel = true; // Cancel the form closing event
}
}
base.OnFormClosing(e);
}
private string CalculateMD5Hash(string filePath)
{
try
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(filePath))
{
byte[] hashBytes = md5.ComputeHash(stream);
return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
}
}
}
catch (Exception)
{
return null;
}
}
private bool IsFileLocked(string filePath)
{
try
{
using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None))
{
fileStream.Close();
}
}
catch (IOException)
{
return true;
}
return false;
}
private string GetProcessNameOfFile(string filePath)
{
string processName = string.Empty;
try
{
using (var searcher = new ManagementObjectSearcher($"SELECT * FROM Win32_Process WHERE ExecutablePath = '{filePath}'"))
{
foreach (var queryObj in searcher.Get())
{
processName = queryObj["Name"].ToString();
break;
}
}
}
catch (ManagementException)
{
// Handle the exception if necessary
}
return processName;
}
private void KillProcessUsingTaskkill(string processName)
{
ProcessStartInfo psi = new ProcessStartInfo("taskkill", $"/F /IM {processName}");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);
}
private void Timer_Tick(object sender, EventArgs e)
{
blink = !blink;
if (blink)
{
label10.Visible = true;
}
else
{
label10.Visible = false;
}
}
private async void button1_Click(object sender, EventArgs e)
{
TextBox txtStatus = this.Controls.Find("txtStatus", true).FirstOrDefault() as TextBox;
Label IblStatus = this.Controls.Find("IblStatus", true).FirstOrDefault() as Label;
string filePath = textBox1.Text;
if (await Task.Run(() => IsFileInfected(filePath)))
{
IblStatus.Text = "Infected!";
IblStatus.ForeColor = Color.Red;
txtStatus.Text = "Infected!";
txtStatus.ForeColor = Color.Red;
DialogResult dialogResult = MessageBox.Show("The file is infected. Do you want to delete it?", "Warning", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
try
{
// Dosyanın çalışan sürecini sonlandır
Process.Start("taskkill", $"/F /IM {Path.GetFileName(filePath)}");
// Dosyanın oluşturduğu ve kendisine ait diğer dosyaları sonlandır
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
string fileExtension = Path.GetExtension(filePath);
Process.Start("taskkill", $"/F /FI \"WINDOWTITLE eq {fileNameWithoutExtension}*{fileExtension}\"");
// Dosyayı sil
File.Delete(filePath);
// Oluşturulan diğer dosyaları sil
string fileDirectory = Path.GetDirectoryName(filePath);
string[] createdFiles = Directory.GetFiles(fileDirectory, $"{fileNameWithoutExtension}*{fileExtension}", SearchOption.AllDirectories);
foreach (string createdFile in createdFiles)
{
File.Delete(createdFile);
}
MessageBox.Show("The infected file and its created files have been successfully deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (UnauthorizedAccessException ex)
{
MessageBox.Show("Failed to delete the file. You do not have permission to delete this file. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (IOException ex)
{
MessageBox.Show("Failed to delete the file. The file is in use by another process. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show("Failed to delete the file. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
// Yanıp sönme animasyonunu başlat
await AnimateInfectedLabel();
}
else
{
IblStatus.Text = "Clean!";
IblStatus.ForeColor = Color.Green;
txtStatus.Text = "Clean!";
txtStatus.ForeColor = Color.Green;
}
}
private async Task AnimateInfectedLabel()
{
const int blinkInterval = 500; // Yanıp sönme aralığı (ms)
while (true)
{
await Task.Delay(blinkInterval);
// Label'ın görünürlüğünü tersine çevir
IblStatus.Visible = !IblStatus.Visible;
}
}
private string GetSHA256FromFile(string filePath)
{
using (FileStream stream = File.OpenRead(filePath))
{
using (SHA256 sha256 = SHA256.Create())
{
byte[] hashBytes = sha256.ComputeHash(stream);
return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
}
}
}
private bool IsFileInfected(string md5)
{
using (var md5Connection = new SQLiteConnection("Data Source=MD5basedatabase.db;Version=3;"))
{
md5Connection.Open();
// Check in the MD5base table
var md5baseCommand = new SQLiteCommand("SELECT COUNT(*) FROM MD5base WHERE field1 = @md5;", md5Connection);
md5baseCommand.Parameters.AddWithValue("@md5", md5);
var md5baseResult = (long)md5baseCommand.ExecuteScalar();
if (md5baseResult > 0)
return true;
}
// Check in the main.db file and main table
using (var mainConnection = new SQLiteConnection("Data Source=main.db;Version=3;"))
{
mainConnection.Open();
var mainCommand = new SQLiteCommand("SELECT COUNT(*) FROM main WHERE field2 = @md5;", mainConnection);
mainCommand.Parameters.AddWithValue("@md5", md5);
var mainResult = (long)mainCommand.ExecuteScalar();
if (mainResult > 0)
return true;
}
// Check in the daily.db file and daily table
using (var dailyConnection = new SQLiteConnection("Data Source=daily.db;Version=3;"))
{
dailyConnection.Open();
var dailyCommand = new SQLiteCommand("SELECT COUNT(*) FROM daily WHERE field2 = @md5;", dailyConnection);
dailyCommand.Parameters.AddWithValue("@md5", md5);
var dailyResult = (long)dailyCommand.ExecuteScalar();
if (dailyResult > 0)
return true;
}
// Check in the remaining tables in oldvirusbase.db
using (var oldVirusBaseConnection = new SQLiteConnection("Data Source=oldvirusbase.db;Version=3;"))
{
oldVirusBaseConnection.Open();
// Check in the oldvirusbase table
var oldVirusBaseCommand = new SQLiteCommand("SELECT COUNT(*) FROM oldvirusbase WHERE field2 = @md5;", oldVirusBaseConnection);
oldVirusBaseCommand.Parameters.AddWithValue("@md5", md5);
var oldVirusBaseResult = (long)oldVirusBaseCommand.ExecuteScalar();
if (oldVirusBaseResult > 0)
return true;
// Check in the oldvirusbase2 table
var oldVirusBase2Command = new SQLiteCommand("SELECT COUNT(*) FROM oldvirusbase2 WHERE field1 = @md5;", oldVirusBaseConnection);
oldVirusBase2Command.Parameters.AddWithValue("@md5", md5);
var oldVirusBase2Result = (long)oldVirusBase2Command.ExecuteScalar();
if (oldVirusBase2Result > 0)
return true;
// Check in the oldvirusbase3 table
var oldVirusBase3Command = new SQLiteCommand("SELECT COUNT(*) FROM oldvirusbase3 WHERE field2 = @md5;", oldVirusBaseConnection);
oldVirusBase3Command.Parameters.AddWithValue("@md5", md5);
var oldVirusBase3Result = (long)oldVirusBase3Command.ExecuteScalar();
if (oldVirusBase3Result > 0)
return true;
}
// Check in the remaining tables in virusbase.db
using (var virusBaseConnection = new SQLiteConnection("Data Source=virusbase.db;Version=3;"))
{
virusBaseConnection.Open();
// Check in the virusbase table
var virusBaseCommand = new SQLiteCommand("SELECT COUNT(*) FROM virusbase WHERE field1 = @md5;", virusBaseConnection);
virusBaseCommand.Parameters.AddWithValue("@md5", md5);
var virusBaseResult = (long)virusBaseCommand.ExecuteScalar();
if (virusBaseResult > 0)
return true;
// Check in the virusbase2 table
var virusBase2Command = new SQLiteCommand("SELECT COUNT(*) FROM virusbase2 WHERE field1 = @md5;", virusBaseConnection);
virusBase2Command.Parameters.AddWithValue("@md5", md5);
var virusBase2Result = (long)virusBase2Command.ExecuteScalar();
if (virusBase2Result > 0)
return true;
}
return false;
}
private async void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
{
await Task.Run(() => Application.Exit());
}
private void RemoveItemsFromListView(List<ListViewItem> itemsToRemove)
{
if (listView1.InvokeRequired)
{
listView1.Invoke((MethodInvoker)(() => RemoveItemsFromListView(itemsToRemove)));
}
else
{
foreach (ListViewItem itemToRemove in itemsToRemove)
{
listView1.Items.Remove(itemToRemove);
}
}
}
private void ShowErrorMessage(string message)
{
if (listView1.InvokeRequired)
{
listView1.Invoke((MethodInvoker)(() => ShowErrorMessage(message)));
}
else
{
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private async void button3_Click_1(object sender, EventArgs e)
{
await DeleteInfectedFilesAsync();
}
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetProcessShutdownParameters(int level, uint flags);
private string GetVirusName(string md5Hash)
{
string dbFilePath = "MD5basedatabase.db";
if (File.Exists(dbFilePath))
{
using (var connection = new SQLiteConnection($"Data Source={dbFilePath};Version=3;"))
{
connection.Open();
using (var command = new SQLiteCommand(connection))
{
command.CommandText = "SELECT field1 FROM MD5base WHERE field1 = @hash";
command.Parameters.AddWithValue("@hash", md5Hash);
using (var reader = command.ExecuteReader())
{
if (reader.Read())
{
return reader.GetString(0)?.Trim();
}
}
}
connection.Close();
}
}
return null;
}
private async Task DeleteInfectedFilesAsync()
{
// Get the list of infected files
List<string> infectedFilesPaths = new List<string>();
foreach (ListViewItem item in listView1.Items)
{
infectedFilesPaths.Add(item.SubItems[1].Text);
}
progressBar1.Maximum = infectedFilesPaths.Count;
progressBar1.Value = 0;
foreach (string filePath in infectedFilesPaths)
{
string md5Hash = CalculateMd5Hash(filePath);
string virusName = GetVirusName(md5Hash);
// Kill the virus process if it is running
Process[] processes = Process.GetProcessesByName(virusName);
foreach (Process process in processes)
{
process.Kill();
}
// Delete the infected file
File.Delete(filePath);
// Delete the other files created by the virus based on MD5 hash
string fileDirectory = Path.GetDirectoryName(filePath);
string[] createdFiles = Directory.GetFiles(fileDirectory, "*", SearchOption.AllDirectories);
foreach (string createdFile in createdFiles)
{
string createdFileMd5Hash = CalculateMd5Hash(createdFile);
if (createdFileMd5Hash == md5Hash)
{
File.Delete(createdFile);
}
}
progressBar1.PerformStep();
await Task.Delay(100); // Simulate some processing time
}
// Display a message box after the deletion process is complete
MessageBox.Show("Infected files and their associated files have been deleted.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private string CalculateMd5Hash(string filePath)
{
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(filePath))
{
byte[] hashBytes = md5.ComputeHash(stream);
string hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();
return hash;
}
}
}
// Custom task scheduler with limited concurrency level
public class LimitedConcurrencyLevelTaskScheduler : TaskScheduler
{
private readonly object _lock = new object();
private readonly int _maxDegreeOfParallelism;
private int _currentCount = 0;
public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
{
if (maxDegreeOfParallelism < 1)
throw new ArgumentOutOfRangeException("maxDegreeOfParallelism");
_maxDegreeOfParallelism = maxDegreeOfParallelism;
}
protected override IEnumerable<Task> GetScheduledTasks()
{
return Enumerable.Empty<Task>();
}
protected override void QueueTask(Task task)
{
lock (_lock)
{
if (_currentCount < _maxDegreeOfParallelism)
{
_currentCount++;
Task.Run(() =>
{
TryExecuteTask(task);
}).ContinueWith(t =>
{
lock (_lock)
{
_currentCount--;
if (_currentCount == 0)
{
OnAllTasksCompleted();
}
}
});
}
else
{
base.TryExecuteTask(task);
}
}
}
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
{
if (taskWasPreviouslyQueued)
return false;
return TryExecuteTask(task);
}
protected virtual void OnAllTasksCompleted()
{
// Override this method if you need to perform any action
// when all tasks have been completed
}
}
private void button6_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
private async void button7_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
listView2.Items.Clear();
textBox5.Text = "";
textBox6.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox7.Text = "";
textBox1.Text = "";
textBox2.Text = "";
label4.Text = "Viruses";
label5.Text = "Clean files";
IblStatus.Text = "Status N/A";
IblStatus.ForeColor = Color.Black;
using (var folderDialog = new FolderBrowserDialog())
{
if (folderDialog.ShowDialog() != DialogResult.OK)
{
return;
}
var files = Directory.GetFiles(folderDialog.SelectedPath, "*.exe", SearchOption.AllDirectories);
progressBar1.Maximum = files.Length;
progressBar1.Value = 0;
// Animation variables
string[] scanningFrames = { ".", "..", "..." };
int currentFrameIndex = 0;
label10.Visible = true;
Dictionary<string, string> infectedWithFileNameList = new Dictionary<string, string>();
Dictionary<string, string> cleanWithFileNameList = new Dictionary<string, string>();
// Start the animation and progress percentage
label10.Text = $"Scanning (0%)";
currentFrameIndex = (currentFrameIndex + 1) % scanningFrames.Length;
timer.Start();
await Task.Run(async () =>
{
int batchSize = 100; // Number of files to process in a batch
int filesProcessed = 0;
while (filesProcessed < files.Length)
{
var batchFiles = files.Skip(filesProcessed).Take(batchSize).ToArray();
await Task.WhenAll(batchFiles.Select(filePath => ProcessFileAsync(filePath)));
filesProcessed += batchFiles.Length;
// Update the animation
label10.Invoke(new Action(() => label10.Text += scanningFrames[currentFrameIndex]));
currentFrameIndex = (currentFrameIndex + 1) % scanningFrames.Length;
}
});
async Task ProcessFileAsync(string filePath)
{
bool isInfected;
string md5HashString;
string sha256HashString;
using (var md5 = MD5.Create())
using (var sha256 = SHA256.Create())
using (var fileStream = File.OpenRead(filePath))
{
var md5Hash = await Task.Run(() => md5.ComputeHash(fileStream));
md5HashString = BitConverter.ToString(md5Hash).Replace("-", "").ToLowerInvariant();
var sha256Hash = await Task.Run(() => sha256.ComputeHash(fileStream));
sha256HashString = BitConverter.ToString(sha256Hash).Replace("-", "").ToLowerInvariant();
isInfected = IsFileInfected(md5HashString);
}
var item = new ListViewItem(new[] { filePath, isInfected ? "Infected!" : "Clean!" });
if (isInfected)
{
item.ForeColor = Color.Red;
infectedWithFileNameList[filePath] = md5HashString;
}
else
{
item.ForeColor = Color.Green;
cleanWithFileNameList[filePath] = md5HashString;
}
progressBar1.Invoke(new Action(() => progressBar1.Increment(1)));
int progressPercentage = (int)(((double)progressBar1.Value / progressBar1.Maximum) * 100);
label10.Invoke(new Action(() => label10.Text = $"Scanning ({progressPercentage}%)"));
}
foreach (var kvp in infectedWithFileNameList)
{
listView1.Items.Add(new ListViewItem(new[] { kvp.Key, kvp.Value })).ForeColor = Color.Red;
}
foreach (var kvp in cleanWithFileNameList)
{
listView2.Items.Add(new ListViewItem(new[] { kvp.Key, kvp.Value })).ForeColor = Color.Green;
}
textBox5.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Select(kvp => kvp.Value + " " + kvp.Key));
textBox6.Text = string.Join(Environment.NewLine, cleanWithFileNameList.Select(kvp => kvp.Value + " " + kvp.Key));
textBox3.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Values);
textBox4.Text = string.Join(Environment.NewLine, cleanWithFileNameList.Values);
textBox7.Text = CalculateCombinedSHA256(infectedWithFileNameList.Keys.Concat(cleanWithFileNameList.Keys));
textBox1.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Values);
textBox2.Text = string.Join(Environment.NewLine, infectedWithFileNameList.Keys.Concat(cleanWithFileNameList.Keys));
label10.Text = "Scan complete.";
if (infectedWithFileNameList.Count > 0)
{
IblStatus.Text = "Infected!";
IblStatus.ForeColor = Color.Red;
await AnimateInfectedLabel();
}
else
{
IblStatus.Text = "Clean!";
IblStatus.ForeColor = Color.Green;
}
}
}
private bool isAnimationRunning = false;
private void AddItemsToListView(CheckedListBox checkedListBox, List<string> items)
{
if (checkedListBox.InvokeRequired)
{
checkedListBox.Invoke(new MethodInvoker(() => AddItemsToListView(checkedListBox, items)));
}
else
{
foreach (string item in items)
{
checkedListBox.Items.Add(item);
}
}
}
private async void button8_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
listView2.Items.Clear();
textBox5.Text = "";
textBox6.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox7.Text = "";
textBox1.Text = "";
textBox2.Text = "";
string username = Environment.UserName;
string userProfile = Environment.GetEnvironmentVariable("USERPROFILE").ToUpper();
// Start the animation
StartAnimation();
await Task.Run(async () =>
{
List<string> paths = new List<string>();
// Scan the C:\ directory
await ScanDirectory("C:\\", paths); // Assuming ScanDirectory is an asynchronous method
int totalCount = paths.Count;
int scannedCount = 0;
List<string> infectedFiles = new List<string>();
foreach (string path in paths)
{
if (path.StartsWith($"C:\\Users\\{username}\\AppData\\") ||
path.StartsWith($"C:\\Users\\{username.Substring(0, 1)}~1\\") ||
path.StartsWith("C:\\Windows\\Prefetch\\") ||
path.StartsWith("C:\\Windows\\Temp") ||
path.StartsWith("C:\\$Recycle.Bin") ||
path.StartsWith("C:\\ProgramData") ||
path.StartsWith("C:\\Windows\\ServiceState") ||
path.StartsWith("C:\\Windows\\Logs") ||
path.StartsWith("C:\\Windows\\ServiceProfiles") ||
path.StartsWith("C:\\Windows\\System32") ||
path.StartsWith("C:\\Program Files\\CUAssistant") ||
path.StartsWith("C:\\Windows\\bootstat.dat") ||
path.StartsWith("C:\\Documents and Settings"))
{
continue;
}
// File scanning operations
// Add the desired operations here
// For example, add the file name to the infectedFiles list
infectedFiles.Add(Path.GetFileName(path));
scannedCount++;
// Update the progress
UpdateProgress(scannedCount, totalCount);
}
// Collect the scan results
ScanResult scanResult = new ScanResult
{
InfectedFiles = infectedFiles,
InfectedWithFileName = string.Join(Environment.NewLine, infectedFiles),
CleanWithFileName = string.Empty,
Infected = string.Join(Environment.NewLine, infectedFiles),
Clean = string.Empty,
SHA256 = string.Empty,
MD5 = string.Empty,
FileNames = string.Empty
};
// Update the UI with the scan results
SetTextBoxText(textBox5, scanResult.InfectedWithFileName);
SetTextBoxText(textBox6, scanResult.CleanWithFileName);
SetTextBoxText(textBox3, scanResult.Infected);
SetTextBoxText(textBox4, scanResult.Clean);
SetTextBoxText(textBox7, scanResult.SHA256);
SetTextBoxText(textBox1, scanResult.MD5);
SetTextBoxText(textBox2, scanResult.FileNames);
// Add infected files to the ListView
AddItemsToListView(listView1, infectedFiles);
// Stop the animation
StopAnimation();
});
}
private void AddItemsToListView(ListView listView, List<string> items)
{
if (listView.InvokeRequired)
{
listView.Invoke(new Action(() => AddItemsToListView(listView, items)));
}
else
{
foreach (string item in items)
{
listView.Items.Add(new ListViewItem(item));
}
}
}
private void SetTextBoxText(TextBoxBase textBox, string text)
{
if (textBox.InvokeRequired)
{
textBox.Invoke(new Action(() => { textBox.Text = text; }));
}
else
{
textBox.Text = text;
}
}
private void StartAnimation()
{
progressBar1.Value = 0;
isAnimationRunning = true;
Thread animationThread = new Thread(() =>
{
while (isAnimationRunning)
{
for (int i = 0; i < 4; i++)
{
string animation = new string('.', i);
SetLabel10Text($"Scanning(0%){animation}");
Thread.Sleep(500);
}
}
});
animationThread.Start();
}
private void SetLabel10Text(string text)
{
if (label10.InvokeRequired)
{
label10.Invoke(new Action(() => { label10.Text = text; }));
}
else
{
label10.Text = text;
}
}
private void StopAnimation()
{
// İlerleme metnini güncelle
SetLabel10Text("Scanning completed");
// İlerleme çubuğunu tamamlanmış hale getir
progressBar1.Invoke(new Action(() => { progressBar1.Value = 100; }));
}
private async Task ScanDirectory(string path, List<string> fileList)
{
try
{
// Get files in the directory
string[] files = Directory.GetFiles(path);
fileList.AddRange(files);
// Scan subdirectories
string[] directories = Directory.GetDirectories(path);
foreach (string directory in directories)
{
await ScanDirectory(directory, fileList);
}
}
catch (UnauthorizedAccessException)
{
}
}
private void UpdateProgress(int scannedCount, int totalCount)
{
int progressPercentage = (int)((float)scannedCount / totalCount * 100);
progressBar1.BeginInvoke(new Action(() => { progressBar1.Value = progressPercentage; }));
SetLabel10Text($"Scanning({progressPercentage}%)");
}
public class ScanResult
{
public List<string> InfectedFiles { get; set; }
public string InfectedWithFileName { get; set; }
public string CleanWithFileName { get; set; }
public string Infected { get; set; }
public string Clean { get; set; }
public string SHA256 { get; set; }
public string MD5 { get; set; }
public string FileNames { get; set; }
public ScanResult()
{
InfectedFiles = new List<string>();
}
}
// PictureBox5'in tıklanma olayı
private void pictureBox5_Click(object sender, EventArgs e)
{
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
ListView listView = (ListView)sender;
List<ListViewItem> selectedItems = new List<ListViewItem>();
foreach (ListViewItem item in listView.CheckedItems)
{
selectedItems.Add(item);
}
if (selectedItems.Count > 0)
{
if (IsKeyPressed(Keys.Up))
{
ListViewItem firstItem = selectedItems[0];
int index = firstItem.Index;
if (index > 0)
{
listView.Items[index].Selected = false;
listView.Items.RemoveAt(index);
listView.Items.Insert(index - 1, firstItem);
listView.Items[index - 1].Selected = true;
}
}
if (IsKeyPressed(Keys.Down))
{
ListViewItem lastItem = selectedItems[selectedItems.Count - 1];
int index = lastItem.Index;
if (index < listView.Items.Count - 1)
{
listView.Items[index].Selected = false;
listView.Items.RemoveAt(index);
listView.Items.Insert(index + 1, lastItem);
listView.Items[index + 1].Selected = true;
}
}
if (IsKeyPressed(Keys.Left))
{
foreach (ListViewItem item in selectedItems)
{
int index = item.Index;
if (index > 0)
{
listView.Items[index].Selected = false;
listView.Items.RemoveAt(index);
listView.Items.Insert(index - 1, item);
listView.Items[index - 1].Selected = true;
}
}
}
if (IsKeyPressed(Keys.Right))
{
foreach (ListViewItem item in selectedItems)
{
int index = item.Index;
if (index < listView.Items.Count - 1)
{
listView.Items[index].Selected = false;
listView.Items.RemoveAt(index);
listView.Items.Insert(index + 1, item);
listView.Items[index + 1].Selected = true;
}
}
}
}
}
private bool IsKeyPressed(Keys key)
{
return (Control.ModifierKeys & key) == key;
}
private void button9_Click(object sender, EventArgs e)
{
List<string> filesToDelete = new List<string>();
// Seçili dosyaları bulma
for (int i = 0; i < VirusList.CheckedItems.Count; i++)
{
string filePath = VirusList.CheckedItems[i].ToString();
filesToDelete.Add(filePath);
}
// Dosyaları silme
foreach (string filePath in filesToDelete)
{
File.Delete(filePath);
// veya dosya silme işlemini gerçekleştirmek için başka bir yöntem kullanabilirsiniz.
}
// Kontrolü temizleme
VirusList.Items.Clear();
}
private void listView2_SelectedIndexChanged(object sender, EventArgs e)
{
VirusList.Items.Clear(); // VirusList kontrolünü temizle
// listView2'de seçili olan öğeleri VirusList kontrolüne aktar
foreach (ListViewItem selectedItem in listView2.SelectedItems)
{
VirusList.Items.Add(selectedItem.Text);
}
}
private void listView1_SelectedIndexChanged_1(object sender, EventArgs e)
{
VirusList.Items.Clear(); // VirusList kontrolünü temizle
// listView1'de seçili olan öğeleri VirusList kontrolüne aktar
foreach (ListViewItem selectedItem in listView1.SelectedItems)
{
VirusList.Items.Add(selectedItem.Text);
}
}
private void label2_Click(object sender, EventArgs e)
{
}
private string CalculateMD5(string filePath)
{
try
{
using (FileStream fileStream = File.OpenRead(filePath))
{
using (MD5 algorithm = MD5.Create())
{
byte[] hashBytes = algorithm.ComputeHash(fileStream);
string hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
return hash;
}
}
}
catch (Exception ex)
{
// Hata oluştuğunda buraya gelir
Console.WriteLine($"H: {ex.Message}");
return string.Empty; // Hata durumunda boş bir değer döndürüyoruz veya isteğinize göre başka bir değer döndürebilirsiniz.
}
}
private List<string> GetAllFiles(string directory)
{
List<string> files = new List<string>();
try
{
files.AddRange(Directory.GetFiles(directory));
foreach (string subdirectory in Directory.GetDirectories(directory))
{
files.AddRange(GetAllFiles(subdirectory));
}
}
catch (Exception)
{
// Hata durumunda gerekli işlemleri yapabilirsiniz
}
return new List<string>(files); // Dosya listesinin kopyasını döndürüyoruz
}
private void CountFiles(string folderPath, ref int totalFiles)
{
string[] files = Directory.GetFiles(folderPath);
string[] subFolders = Directory.GetDirectories(folderPath);
// Increment the total files count
totalFiles += files.Length;
// Count files in subfolders recursively
foreach (string subFolder in subFolders)
{
CountFiles(subFolder, ref totalFiles);
}
}
private void ProcessFolder(string folderPath, List<string> sha256Hashes, List<string> md5Hashes, ref int processedFiles, ref int totalFiles)
{
string[] files = Directory.GetFiles(folderPath);
string[] subFolders = Directory.GetDirectories(folderPath);
// Process files in the current folder
foreach (string file in files)
{
// Calculate the SHA256 hash
string sha256Hash = CalculateSHA256(file);
sha256Hashes.Add(sha256Hash);
// Calculate the MD5 hash
string md5Hash = CalculateMd5Hash(file);
md5Hashes.Add(md5Hash);
// Increment the processed files count
processedFiles++;
// Calculate the progress percentage
int progressPercentage = (processedFiles * 100) / totalFiles;
// Update the progress bar value within the valid range
if (progressPercentage <= progressBar1.Maximum)
{
Invoke((MethodInvoker)delegate
{
progressBar1.Value = progressPercentage;
});
}
}
// Process subfolders recursively
foreach (string subFolder in subFolders)
{
ProcessFolder(subFolder, sha256Hashes, md5Hashes, ref processedFiles, ref totalFiles);
}
}
private async void Worker_DoWorkForHydra(object sender, DoWorkEventArgs e)
{
string[] files = (string[])e.Argument;
// Process files asynchronously
await Task.Run(() =>
{
foreach (string file in files)
{
// Calculate the SHA256 hash
string sha256Hash = CalculateSHA256(file);
// Calculate the MD5 hash
string md5Hash = CalculateMD5(file);
// Update the text boxes on the UI thread
Invoke((MethodInvoker)delegate
{
textBox7.AppendText(sha256Hash + Environment.NewLine);
textBox1.AppendText(md5Hash + Environment.NewLine);
});
}
});
}
private void Worker_RunWorkerCompletedHydra(object sender, RunWorkerCompletedEventArgs e)
{
// Perform any UI updates or post-processing tasks here
if (e.Error != null)
{
// Handle any errors that occurred during processing
MessageBox.Show("An error occurred: " + e.Error.Message);
}
else if (e.Cancelled)
{
// Handle cancellation if needed
}
else
{
// Processing completed successfully
MessageBox.Show("Processing completed!");
}
}
private void Worker_DoWork(object sender, DoWorkEventArgs e)
{
string[] files = (string[])e.Argument;
List<string> md5Hashes = new List<string>();
List<string> sha256Hashes = new List<string>();
foreach (var file in files)
{
string md5Hash = GetMD5FromFile(file);
string sha256Hash = GetSHA256FromFile(file);
md5Hashes.Add(md5Hash);
sha256Hashes.Add(sha256Hash);
}
// İşlem sonuçlarını argüman olarak döndür
e.Result = new List<List<string>> { md5Hashes, sha256Hashes };
}
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
List<List<string>> results = (List<List<string>>)e.Result;
textBox1.Text = string.Join(" ", results[0]);
textBox7.Text = string.Join(" ", results[1]);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void label5_Click(object sender, EventArgs e)
{
}
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
}
private void pictureBox1_Click_1(object sender, EventArgs e)
{
}
private void pictureBox6_Click(object sender, EventArgs e)
{
}
private void PictureBox1_Click_2(object sender, EventArgs e)
{
string antivirusPath = "Antivirus.exe"; // Replace with the actual path to Antivirus.exe
Process.Start(antivirusPath);
}
private void label27_Click(object sender, EventArgs e)
{
}
private async void button11_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
DialogResult result = folderBrowserDialog.ShowDialog();
if (result == DialogResult.OK)
{
string selectedFolder = $"\"{folderBrowserDialog.SelectedPath}\"";
// Get the path to the executable
string exePath = Application.ExecutablePath;
string clamscanPath = Path.Combine(Path.GetDirectoryName(exePath), "clamscan.exe");
progressBar1.Style = ProgressBarStyle.Marquee; // Set progress bar style to Marquee
progressBar1.MarqueeAnimationSpeed = 30; // Set the animation speed (adjust as needed)
label10.Text = "Please wait..."; // Display "Please wait" message
await Task.Run(() =>
{
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = clamscanPath;
processInfo.WorkingDirectory = Environment.CurrentDirectory;
// Add pause command to the arguments
processInfo.Arguments = $"{selectedFolder} -r --heuristic-alert --detect-pua --remove";
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = processInfo;
process.OutputDataReceived += (s, args) =>
{
if (args.Data != null)
{
Console.WriteLine(args.Data); // Write output to the console
// Append output to the file
using (StreamWriter outputFile = new StreamWriter("scan_results.txt", true))
{
outputFile.WriteLine(args.Data);
}
}
};
process.EnableRaisingEvents = true;
process.Exited += (s, args) =>
{
MessageBox.Show("Scan completed. Check the scan_results.txt file for the results.");
// Restore progress bar and label to their original state
progressBar1.Invoke(new Action(() =>
{
progressBar1.Style = ProgressBarStyle.Blocks;
label10.Text = string.Empty;
}));
};
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
});
}
}
private void UpdateProgressBar(int value)
{
if (progressBar1.InvokeRequired)
{
progressBar1.Invoke(new Action<int>(UpdateProgressBar), value);
}
else
{
progressBar1.Value = value;
progressBar1.Update();
label10.Text = $"{value}%"; // Update the label with the progress value
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
private void label10_Click(object sender, EventArgs e)
{
}
private void Label15_Click(object sender, EventArgs e)
{
}
}
}