Skip to content

Commit 085e2a2

Browse files
committed
Wiki improved, lookup mac by vendor
1 parent 0de338d commit 085e2a2

9 files changed

Lines changed: 215 additions & 187 deletions

File tree

Source/NETworkManager/Models/Network/OUILookup.cs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using System.IO;
55
using NETworkManager.Models.Settings;
66
using System.Text.RegularExpressions;
7+
using System;
8+
using System.Windows;
79

810
namespace NETworkManager.Models.Network
911
{
@@ -12,13 +14,14 @@ public static class OUILookup
1214
#region Variables
1315
private static string OUIFilePath = Path.Combine(ConfigurationManager.Current.ExecutionPath, "Resources", "oui.txt");
1416

15-
public static Lookup<string, OUIInfo> OUIs;
17+
private static List<OUIInfo> OUIList;
18+
private static Lookup<string, OUIInfo> OUIs;
1619
#endregion
1720

18-
#region Methods
21+
#region Constructor
1922
static OUILookup()
2023
{
21-
List<OUIInfo> ouiList = new List<OUIInfo>();
24+
OUIList = new List<OUIInfo>();
2225

2326
// Load list from resource folder (.txt-file)
2427
foreach (string line in File.ReadAllLines(OUIFilePath))
@@ -28,22 +31,24 @@ static OUILookup()
2831

2932
string[] ouiData = line.Split('|');
3033

31-
ouiList.Add(new OUIInfo(ouiData[0], ouiData[1]));
34+
OUIList.Add(new OUIInfo(ouiData[0], ouiData[1]));
3235
}
3336

34-
OUIs = (Lookup<string, OUIInfo>)ouiList.ToLookup(x => x.MACAddress);
37+
OUIs = (Lookup<string, OUIInfo>)OUIList.ToLookup(x => x.MACAddress);
3538
}
39+
#endregion
3640

37-
public static Task<List<OUIInfo>> LookupAsync(string macAddressOrFirst3Bytes)
41+
#region Methods
42+
public static Task<List<OUIInfo>> LookupAsync(string macAddress)
3843
{
39-
return Task.Run(() => Lookup(macAddressOrFirst3Bytes));
44+
return Task.Run(() => Lookup(macAddress));
4045
}
4146

42-
public static List<OUIInfo> Lookup(string macAddressOrFirst3Bytes)
47+
public static List<OUIInfo> Lookup(string macAddress)
4348
{
4449
List<OUIInfo> list = new List<OUIInfo>();
4550

46-
string ouiKey = Regex.Replace(macAddressOrFirst3Bytes, "-|:", "").Substring(0, 6);
51+
string ouiKey = Regex.Replace(macAddress, "-|:", "").Substring(0, 6);
4752

4853
foreach (OUIInfo info in OUIs[ouiKey])
4954
{
@@ -52,6 +57,27 @@ public static List<OUIInfo> Lookup(string macAddressOrFirst3Bytes)
5257

5358
return list;
5459
}
60+
61+
public static Task<List<OUIInfo>> LookupByVendorAsync(List<string> vendors)
62+
{
63+
return Task.Run(() => LookupByVendor(vendors));
64+
}
65+
66+
public static List<OUIInfo> LookupByVendor(List<string> vendors)
67+
{
68+
List<OUIInfo> list = new List<OUIInfo>();
69+
70+
foreach (OUIInfo info in OUIList)
71+
{
72+
foreach (string vendor in vendors)
73+
{
74+
if (info.Vendor.IndexOf(vendor, StringComparison.OrdinalIgnoreCase) >= 0)
75+
list.Add(info);
76+
}
77+
}
78+
79+
return list;
80+
}
5581
#endregion
5682
}
5783
}

Source/NETworkManager/Models/Network/PortLookup.cs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class PortLookup
1717
private static Lookup<int, PortLookupInfo> Ports;
1818
#endregion
1919

20-
#region Methods
20+
#region Constructor
2121
static PortLookup()
2222
{
2323
PortList = new List<PortLookupInfo>();
@@ -33,14 +33,14 @@ static PortLookup()
3333
int port = int.Parse(portData[0]);
3434
Protocol protocol = (Protocol)Enum.Parse(typeof(Protocol), portData[1]);
3535

36-
// string key = GetKey(port, protocol);
37-
3836
PortList.Add(new PortLookupInfo(port, protocol, portData[2], portData[3]));
3937
}
4038

4139
Ports = (Lookup<int, PortLookupInfo>)PortList.ToLookup(x => x.Number);
4240
}
41+
#endregion
4342

43+
#region Methods
4444
public static Task<List<PortLookupInfo>> LookupAsync(int port)
4545
{
4646
return Task.Run(() => Lookup(port));
@@ -58,26 +58,6 @@ public static List<PortLookupInfo> Lookup(int port)
5858
return list;
5959
}
6060

61-
public static Task<List<PortLookupInfo>> LookupAsync(List<int> ports)
62-
{
63-
return Task.Run(() => Lookup(ports));
64-
}
65-
66-
public static List<PortLookupInfo> Lookup(List<int> ports)
67-
{
68-
List<PortLookupInfo> list = new List<PortLookupInfo>();
69-
70-
foreach (int port in ports)
71-
{
72-
foreach (PortLookupInfo info in Ports[port])
73-
{
74-
list.Add(info);
75-
}
76-
}
77-
78-
return list;
79-
}
80-
8161
public static Task<List<PortLookupInfo>> LookupByServiceAsync(List<string> portsByService)
8262
{
8363
return Task.Run(() => LookupByService(portsByService));
@@ -91,7 +71,7 @@ public static List<PortLookupInfo> LookupByService(List<string> portsByService)
9171
{
9272
foreach (string portByService in portsByService)
9373
{
94-
if (info.Service.IndexOf(portByService, StringComparison.OrdinalIgnoreCase) > 0 || info.Description.IndexOf(portByService, StringComparison.OrdinalIgnoreCase) > 0)
74+
if (info.Service.IndexOf(portByService, StringComparison.OrdinalIgnoreCase) >= 0 || info.Description.IndexOf(portByService, StringComparison.OrdinalIgnoreCase) >= 0)
9575
list.Add(info);
9676
}
9777
}

Source/NETworkManager/Models/Settings/SettingsInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,18 +595,18 @@ public int Traceroute_Timeout
595595
#endregion
596596

597597
#region Lookup
598-
private List<string> _lookup_MACAddressHistory = new List<string>();
599-
public List<string> Lookup_MACAddressHistory
598+
private List<string> _lookup_MACAddressOrVendorHistory = new List<string>();
599+
public List<string> Lookup_MACAddressOrVendorHistory
600600
{
601-
get { return _lookup_MACAddressHistory; }
601+
get { return _lookup_MACAddressOrVendorHistory; }
602602
set
603603
{
604-
if (value == _lookup_MACAddressHistory)
604+
if (value == _lookup_MACAddressOrVendorHistory)
605605
return;
606606

607607
SettingsChanged = true;
608608

609-
_lookup_MACAddressHistory = value;
609+
_lookup_MACAddressOrVendorHistory = value;
610610
}
611611
}
612612

Source/NETworkManager/NETworkManager.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@
284284
<Compile Include="Models\Settings\SettingsFileInfo.cs" />
285285
<Compile Include="Validators\FileExistsValidator.cs" />
286286
<Compile Include="Validators\PortRangeValidator.cs" />
287-
<Compile Include="Validators\MACAddressAndMACAddressFirst3BytesRangeValidator.cs" />
288287
<Compile Include="ViewModels\Applications\PortScannerViewModel.cs" />
289288
<Compile Include="ViewModels\Applications\WikiViewModel.cs" />
290289
<Compile Include="ViewModels\Settings\SettingsApplicationPortScannerViewModel.cs" />

Source/NETworkManager/Resources/Localization/Resources.de-DE.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<system:String x:Key="String_Header_WakeUp">Aufwecken</system:String>
1010
<system:String x:Key="String_Header_Templates">Templates</system:String>
1111
<system:String x:Key="String_Header_MACAddress">MAC-Adresse</system:String>
12+
<system:String x:Key="String_Header_MACAddressOrVendor">MAC-Adresse oder Hersteller</system:String>
1213
<system:String x:Key="String_Header_Details">Details</system:String>
1314
<system:String x:Key="String_Header_IPv4Calculator">IPv4-Rechner</system:String>
1415
<system:String x:Key="String_Header_Input">Eingabe</system:String>
@@ -58,6 +59,7 @@
5859
<system:String x:Key="String_Header_PortScanner">Port-Scanner</system:String>
5960
<system:String x:Key="String_Header_PortLookup">Port-Lookup</system:String>
6061
<system:String x:Key="String_Header_Port">Port</system:String>
62+
<system:String x:Key="String_Header_PortPortRangeOrService">Port, Port-Range oder Service</system:String>
6163
<system:String x:Key="String_Header_Socket">Socket</system:String>
6264
<system:String x:Key="String_Header_History">History</system:String>
6365
<system:String x:Key="String_Header_Applications">Anwendungen</system:String>
@@ -202,6 +204,7 @@
202204
<system:String x:Key="String_Duration">Dauer</system:String>
203205
<system:String x:Key="String_EndTime">Endzeit</system:String>
204206
<system:String x:Key="String_NoPortsFoundCheckYourInput">Keine Ports gefunden. Überprüfen Sie Ihre Eingabe!</system:String>
207+
<system:String x:Key="String_NoVendorFoundCheckYourInput">Kein Hersteller gefunden. Überprüfen Sie Ihre Eingabe!</system:String>
205208

206209
<!-- Buttons -->
207210
<system:String x:Key="String_Button_Change">Wechseln</system:String>
@@ -254,12 +257,13 @@
254257
<system:String x:Key="String_Watermark_HostnameOrIPAddress">Hostname oder IP-Adresse...</system:String>
255258
<system:String x:Key="String_Watermark_EampleIPScanRange">192.168.1.0/24; 192.168.178.1 - 192.168.178.128; 192.168.178.150</system:String>
256259
<system:String x:Key="String_Watermark_LocationOfTheImport">Speicherort der Importdatei...</system:String>
257-
<system:String x:Key="String_Watermark_ExampleMACAddressesOrParts">01:23:45:67:89:AB; 01-23-45; AA11BB; 00F1A2C3D4E5</system:String>
260+
<system:String x:Key="String_Watermark_ExampleMACAddressesOrVendor">01:23:45:67:89:AB; 01-23-45; AA11BB; 00F1A2C3D4E5; Intel Corp; Asus</system:String>
258261
<system:String x:Key="String_Watermark_EamplePortScanRange">22; 80; 443; 500 - 999; 8080</system:String>
259262
<system:String x:Key="String_Watermark_ExampleHostOrIPv4Address">192.168.178.1 oder fritz.box</system:String>
260263
<system:String x:Key="String_Watermark_ExampleSubnetmaskOrCIDR">255.255.255.0 or /24</system:String>
261264
<system:String x:Key="String_Watermark_ExampleIPv4Gateway">192.168.178.1</system:String>
262265
<system:String x:Key="String_Watermark_ExampleIPv4DNS">8.8.8.8</system:String>
266+
<system:String x:Key="String_Watermark_EamplePortPortRangeOrService">22; 80; https; ldaps; 777 - 999; 8080</system:String>
263267

264268
<!-- ShowProgress -->
265269
<system:String x:Key="String_ProgessHeader_ConfigureNetworkInterface">Konfiguriere Netzwerkinterface</system:String>

Source/NETworkManager/Resources/Localization/Resources.en-US.xaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<system:String x:Key="String_Header_WakeUp">Wake Up</system:String>
1010
<system:String x:Key="String_Header_Templates">Templates</system:String>
1111
<system:String x:Key="String_Header_MACAddress">MAC-Address</system:String>
12+
<system:String x:Key="String_Header_MACAddressOrVendor">MAC-Address or Vendor</system:String>
1213
<system:String x:Key="String_Header_Details">Details</system:String>
1314
<system:String x:Key="String_Header_IPv4Calculator">IPv4-Calculator</system:String>
1415
<system:String x:Key="String_Header_Input">Input</system:String>
@@ -59,6 +60,7 @@
5960
<system:String x:Key="String_Header_PortScanner">Port-Scanner</system:String>
6061
<system:String x:Key="String_Header_PortLookup">Port-Lookup</system:String>
6162
<system:String x:Key="String_Header_Port">Port</system:String>
63+
<system:String x:Key="String_Header_PortPortRangeOrService">Port, port range or service</system:String>
6264
<system:String x:Key="String_Header_Socket">Socket</system:String>
6365
<system:String x:Key="String_Header_History">History</system:String>
6466
<system:String x:Key="String_Header_Applications">Applications</system:String>
@@ -204,6 +206,7 @@
204206
<system:String x:Key="String_Duration">Duration</system:String>
205207
<system:String x:Key="String_EndTime">End time</system:String>
206208
<system:String x:Key="String_NoPortsFoundCheckYourInput">No ports found. Check your input!</system:String>
209+
<system:String x:Key="String_NoVendorFoundCheckYourInput">No vendor found. Check your input!</system:String>
207210

208211
<!-- Buttons -->
209212
<system:String x:Key="String_Button_Change">Change</system:String>
@@ -255,13 +258,14 @@
255258
<system:String x:Key="String_Watermark_HostnameOrIPAddress">Hostname or IP-Address...</system:String>
256259
<system:String x:Key="String_Watermark_EampleIPScanRange">192.168.1.0/24; 192.168.178.1 - 192.168.178.128; 192.168.178.150</system:String>
257260
<system:String x:Key="String_Watermark_LocationOfTheImport">Location of the import file...</system:String>
258-
<system:String x:Key="String_Watermark_ExampleMACAddressesOrParts">01:23:45:67:89:AB; 01-23-45; AA11BB; 00F1A2C3D4E5</system:String>
261+
<system:String x:Key="String_Watermark_ExampleMACAddressesOrVendor">01:23:45:67:89:AB; 01-23-45; AA11BB; 00F1A2C3D4E5; Intel Corp; Asus</system:String>
259262
<system:String x:Key="String_Watermark_EamplePortScanRange">22; 80; 443; 500 - 999; 8080</system:String>
260263
<system:String x:Key="String_Watermark_ExampleHostOrIPv4Address">192.168.178.1 or fritz.box</system:String>
261264
<system:String x:Key="String_Watermark_ExampleSubnetmaskOrCIDR">255.255.255.0 or /24</system:String>
262265
<system:String x:Key="String_Watermark_ExampleIPv4Gateway">192.168.178.1</system:String>
263266
<system:String x:Key="String_Watermark_ExampleIPv4DNS">8.8.8.8</system:String>
264-
267+
<system:String x:Key="String_Watermark_EamplePortPortRangeOrService">22; 80; https; ldaps; 777 - 999; 8080</system:String>
268+
265269
<!-- ShowProgress -->
266270
<system:String x:Key="String_ProgessHeader_ConfigureNetworkInterface">Configure Network Interface</system:String>
267271
<system:String x:Key="String_Progress_SetStaticIPAddress">Set static IP-Address and gateway...</system:String>

Source/NETworkManager/Validators/MACAddressAndMACAddressFirst3BytesRangeValidator.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)