Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Net.NetworkInformation;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12.  
  13. namespace WindowsFormsApp2{
  14.  
  15.     public partial class Form1 : MetroFramework.Forms.MetroForm
  16.     {
  17.         string mca; // global var, i will update it in future
  18.        
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.  
  25.  
  26.         private void Form1_Load(object sender, EventArgs e)
  27.         {
  28.  
  29.         }
  30.  
  31.  
  32.  
  33.         /* Declaration of function GET MAC ADDRESS*/
  34.         public void GetMACAddress()
  35.         {
  36.            
  37.             NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
  38.             String sMacAddress = string.Empty;
  39.             foreach (NetworkInterface adapter in nics)
  40.             {
  41.                 if (sMacAddress == String.Empty)// only return MAC Address from first card  
  42.                 {
  43.                     IPInterfaceProperties properties = adapter.GetIPProperties();
  44.                     sMacAddress = adapter.GetPhysicalAddress().ToString();
  45.                 }
  46.             }
  47.             mca = sMacAddress;
  48.         }
  49.         /* End of declaration */
  50.  
  51.  
  52.  
  53.         /*Link to GitHub */
  54.         private void metroLink1_Click(object sender, EventArgs e)
  55.         {
  56.             System.Diagnostics.Process.Start("https://github.com/Zenek-Hastro/Shadow-Hammer-MAC");
  57.         }
  58.         /*end link */
  59.  
  60.  
  61.  
  62.         /* Start fuction to check if infected */
  63.         private void metroButton1_Click(object sender, EventArgs e)
  64.         {
  65.             NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
  66.             List<string> sMacAddress = new List<string>();  //in questa lista ci andranno tutti i MAC Address del PC      
  67.             foreach (NetworkInterface adapter in nics)
  68.             {
  69.                 string sMac = adapter.GetPhysicalAddress().ToString();
  70.                 if (sMac.Length == 0)
  71.                     break;
  72.                 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));
  73.             }
  74.  
  75.             using (StreamReader macList = new StreamReader("MAF.txt"))
  76.             {
  77.                 string linea;
  78.                 bool inizio = false;
  79.                 bool infetto = false;
  80.                 while ((linea = macList.ReadLine()) != null)
  81.                 {
  82.                     if (linea.Contains("MAC - list"))   //cerca nel file l'inizio della lista dei MAC Address
  83.                     {
  84.                         inizio = true;
  85.                         continue;
  86.                     }
  87.                     if (inizio == true)
  88.                     {
  89.                         foreach (string mca in sMacAddress)
  90.                         {
  91.                             if (linea.Contains(mca.ToLower()))
  92.                             {
  93.                                 MetroFramework.MetroMessageBox.Show(this, "Your computer may be infected!!", "ATTENTION", MessageBoxButtons.OK, MessageBoxIcon.Error);
  94.                                 infetto = true;
  95.                                 break;
  96.                             }
  97.                         }
  98.                     }
  99.                 }
  100.                 if (infetto == false)
  101.                 {
  102.                     MetroFramework.MetroMessageBox.Show(this, "Your computer is clear :)", "All done !", MessageBoxButtons.OK, MessageBoxIcon.Question);
  103.                 }
  104.             }
  105.         }
  106.  
  107.  
  108.  
  109.  
  110.  
  111.         private void metroButton3_Click(object sender, EventArgs e)
  112.         {
  113.             this.Close();
  114.         }
  115.  
  116.  
  117.  
  118. /* QUESTA è LA FUNZIONE IN CUI COMPARE L'ERRORE */
  119.         private void metroButton2_Click(object sender, EventArgs e)
  120.         {
  121.             StringBuilder sb = new StringBuilder();
  122.             foreach (string mac in sMacAddress) // QUI COMPARE L'ERRORE!!!
  123.             {
  124.                 sb.AppendLine(mac);
  125.             }
  126.             MetroFramework.MetroMessageBox.Show(this, sb.ToString(), "Your MAC ADDRESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
  127.         }
  128.     } /* form */
  129. } /* main */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement