예제 #1
0
 public T Load <T>()
 {
     try
     {
         string folder = ConfigurationManagement.Instance.ConfigurationPath;
         folder = folder + Path.DirectorySeparatorChar + "modules";
         if (!Directory.Exists(folder))
         {
             Directory.CreateDirectory(folder);
         }
         folder = folder + Path.DirectorySeparatorChar + "configs";
         if (!Directory.Exists(folder))
         {
             Directory.CreateDirectory(folder);
         }
         string file = folder + Path.DirectorySeparatorChar + adapter.GetAdapterInformation().Id + "-" + MetaData.GetMeta().Name + ".cfg";
         if (File.Exists(file))
         {
             XmlSerializer serializer = new XmlSerializer(typeof(T));
             TextReader    reader     = new StreamReader(file);
             T             ret        = (T)serializer.Deserialize(reader);
             reader.Close();
             return(ret);
         }
     }
     catch (Exception e)
     {
         LogCenter.Instance.LogException(e);
     }
     return(default(T));
 }
예제 #2
0
        public void SaveModuleOrder()
        {
            string folder = ConfigurationManagement.Instance.ConfigurationPath;

            folder = folder + Path.DirectorySeparatorChar + "Adapters";
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = folder + Path.DirectorySeparatorChar + na.GetAdapterInformation().Id;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            string file = folder + Path.DirectorySeparatorChar + "modules.cfg";

            List <ModuleOrder.ModulePair> pairs = new List <ModuleOrder.ModulePair>();

            foreach (KeyValuePair <bool, string> p in moduleOrder)
            {
                pairs.Add(new ModuleOrder.ModulePair()
                {
                    Enabled = p.Key, Name = p.Value
                });
            }
            ModuleOrder mo = new ModuleOrder()
            {
                Order = pairs.ToArray()
            };

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ModuleOrder));
                TextWriter    writer     = new StreamWriter(file);
                serializer.Serialize(writer, mo);
                writer.Close();
            }
            catch (Exception e)
            {
                LogCenter.Instance.LogException(e);
            }
        }
예제 #3
0
 private void buttonOpenConfiguration_Click(object sender, EventArgs e)
 {
     try
     {
         DynamicUserControl uc = na.Modules.GetModule(checkedListBoxModules.SelectedIndex).GetUserInterface();
         if (uc != null)
         {
             DynamicForm f = new DynamicForm();
             f.Size = new System.Drawing.Size(640, 480);
             f.Text = na.GetAdapterInformation().Name + ": " + na.Modules.GetModule(checkedListBoxModules.SelectedIndex).MetaData.GetMeta().Name + " - " + na.Modules.GetModule(checkedListBoxModules.SelectedIndex).MetaData.GetMeta().Version;
             f.Controls.Add(uc);
             f.Show();
             f.ThemeChanged();
         }
     }
     catch (Exception ne)
     {
         LogCenter.Instance.LogException(ne);
     }
 }
예제 #4
0
 public static IPAddr GetLocalIPAddress(INDISFilter adapter)
 {
     IPAddr address = new IPAddr();
     NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
     
     foreach (var adapt in nics)
     {
         // if this adapter matches the one we're looking for
         if (adapt.Id.Equals(adapter.GetAdapterInformation().Id))
         {
             foreach(var i in adapt.GetIPProperties().UnicastAddresses)
             {
                 if (i.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                 {
                     address = new IPAddr(i.Address.GetAddressBytes());
                     return address;
                 }
             }
         }
     }
     return null;
 }
예제 #5
0
        public static IPAddr GetLocalIPAddress(INDISFilter adapter)
        {
            IPAddr address = new IPAddr();

            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();

            foreach (var adapt in nics)
            {
                // if this adapter matches the one we're looking for
                if (adapt.Id.Equals(adapter.GetAdapterInformation().Id))
                {
                    foreach (var i in adapt.GetIPProperties().UnicastAddresses)
                    {
                        if (i.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            address = new IPAddr(i.Address.GetAddressBytes());
                            return(address);
                        }
                    }
                }
            }
            return(null);
        }
예제 #6
0
 public static TCPPacket MakeSynPacket(INDISFilter fromAdapter, byte[] toMac, byte[] toIP, ushort fromPort, ushort toPort)
 {
     return MakeSynPacket(fromAdapter.GetAdapterInformation().InterfaceInformation.GetPhysicalAddress().GetAddressBytes(), toMac, toIP, fromAdapter.GetAdapterInformation().IPv4.GetAddressBytes(), fromPort, toPort);
 }
예제 #7
0
 public static TCPPacket MakeSynPacket(INDISFilter fromAdapter, byte[] toMac, byte[] toIP, ushort fromPort, ushort toPort)
 {
     return(MakeSynPacket(fromAdapter.GetAdapterInformation().InterfaceInformation.GetPhysicalAddress().GetAddressBytes(), toMac, fromAdapter.GetAdapterInformation().IPv4.GetAddressBytes(), toIP, fromPort, toPort));
 }