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)); }
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); } }
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); } }
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; }
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); }
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); }
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)); }