Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Net.NetworkInformation;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp2{
- public partial class Form1 : MetroFramework.Forms.MetroForm
- {
- string mca; // global var, i will update it in future
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- /* Declaration of function GET MAC ADDRESS*/
- public void GetMACAddress()
- {
- NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
- String sMacAddress = string.Empty;
- foreach (NetworkInterface adapter in nics)
- {
- if (sMacAddress == String.Empty)// only return MAC Address from first card
- {
- IPInterfaceProperties properties = adapter.GetIPProperties();
- sMacAddress = adapter.GetPhysicalAddress().ToString();
- }
- }
- mca = sMacAddress;
- }
- /* End of declaration */
- /*Link to GitHub */
- private void metroLink1_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("https://github.com/Zenek-Hastro/Shadow-Hammer-MAC");
- }
- /*end link */
- /* Start fuction to check if infected */
- private void metroButton1_Click(object sender, EventArgs e)
- {
- NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
- List<string> sMacAddress = new List<string>(); //in questa lista ci andranno tutti i MAC Address del PC
- foreach (NetworkInterface adapter in nics)
- {
- string sMac = adapter.GetPhysicalAddress().ToString();
- if (sMac.Length == 0)
- break;
- sMacAddress.Add(sMac.Substring(0, 2) + ":" + sMac.Substring(2, 2) + ":" + sMac.Substring(4, 2) + ":" + sMac.Substring(6, 2) + ":" + sMac.Substring(8, 2) + ":" + sMac.Substring(10, 2));
- }
- using (StreamReader macList = new StreamReader("MAF.txt"))
- {
- string linea;
- bool inizio = false;
- bool infetto = false;
- while ((linea = macList.ReadLine()) != null)
- {
- if (linea.Contains("MAC - list")) //cerca nel file l'inizio della lista dei MAC Address
- {
- inizio = true;
- continue;
- }
- if (inizio == true)
- {
- foreach (string mca in sMacAddress)
- {
- if (linea.Contains(mca.ToLower()))
- {
- MetroFramework.MetroMessageBox.Show(this, "Your computer may be infected!!", "ATTENTION", MessageBoxButtons.OK, MessageBoxIcon.Error);
- infetto = true;
- break;
- }
- }
- }
- }
- if (infetto == false)
- {
- MetroFramework.MetroMessageBox.Show(this, "Your computer is clear :)", "All done !", MessageBoxButtons.OK, MessageBoxIcon.Question);
- }
- }
- }
- private void metroButton3_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /* QUESTA è LA FUNZIONE IN CUI COMPARE L'ERRORE */
- private void metroButton2_Click(object sender, EventArgs e)
- {
- StringBuilder sb = new StringBuilder();
- foreach (string mac in sMacAddress) // QUI COMPARE L'ERRORE!!!
- {
- sb.AppendLine(mac);
- }
- MetroFramework.MetroMessageBox.Show(this, sb.ToString(), "Your MAC ADDRESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- } /* form */
- } /* main */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement