public static SortedList<string, List<AccessPoint>> GetPossibleExtenders(CapFile[] CapFiles) { SortedList<string, List<AccessPoint>> AccessPoints = new SortedList<string, List<AccessPoint>>(); foreach (CapFile capFile in CapFiles) { SortedList<string, AccessPoint[]> PossibleExtenders = capFile.PossibleExtenders; for (int i = 0; i < PossibleExtenders.Count; i++) { if (AccessPoints.ContainsKey(PossibleExtenders.Keys[i])) { for (int j = 0; j < PossibleExtenders.Values[i].Length; j++) { AccessPoint extender = PossibleExtenders.Values[i][j]; if (AccessPoints[PossibleExtenders.Keys[i]].FirstOrDefault(o => o.MacAddress == extender.MacAddress) == null) { AccessPoints[PossibleExtenders.Keys[i]].Add(extender); } } } else { AccessPoints.Add(PossibleExtenders.Keys[i], new List<AccessPoint>(PossibleExtenders.Values[i])); } } } return AccessPoints; }
public static Station[] GetStations(CapFile[] CapFiles) { SortedList<string, Station> StationMacs = new SortedList<string, Station>(); foreach (CapFile capFile in CapFiles) { foreach (Station station in capFile.Stations) { if (!String.IsNullOrEmpty(station.SourceMacAddressStr)) { if (!StationMacs.ContainsKey(station.SourceMacAddressStr)) { StationMacs.Add(station.SourceMacAddressStr, station); } else { Station _station = StationMacs[station.SourceMacAddressStr]; //merge the data from this point... //copy the probes from other cap files HashSet<ProbePacket> probes = new HashSet<ProbePacket>(_station.Probes, new ProbePacket()); probes.UnionWith(station.Probes); _station.SetProbes(probes.ToArray()); //copy the data frames from other cap files HashSet<DataFrame> frames = new HashSet<DataFrame>(_station.DataFrames, new DataFrame()); frames.UnionWith(station.DataFrames); _station.SetDataFrames(frames.ToArray()); } } } } return StationMacs.Values.ToArray(); }
public void SetCapFile(CapFile capFile) { capFile.onReadAccessPoint += capFile_onReadAccessPoint; capFile.onReadBeacon += capFile_onReadBeacon; capFile.onReadDataFrame += capFile_onReadDataFrame; capFile.onReadStation += capFile_onReadStation; }
public static AccessPoint[] GetAllAccessPoints(CapFile[] CapFiles) { SortedList<string, AccessPoint> AccessPoints = new SortedList<string, AccessPoint>(); foreach (CapFile capFile in CapFiles) { foreach (AccessPoint AP in capFile.AccessPoints) { if (!AccessPoints.ContainsKey(AP.MacAddress)) { AccessPoints.Add(AP.MacAddress, AP); } } } return AccessPoints.Values.ToArray(); }
public void AddCapturefile(CapFile capFile) { AddCapturefiles(new CapFile[] { capFile }); }
public void AddCapturefiles(CapFile[] capFiles) { foreach (CapFile capFile in capFiles) { //merge beacons HashSet<BeaconFrame> beacons = new HashSet<BeaconFrame>(capFile.Beacons.AsEnumerable(), new BeaconFrame()); beacons.UnionWith(this._beacons.AsEnumerable()); _beacons.Clear(); _beacons.AddRange(beacons.ToArray()); //merge Access Points HashSet<AccessPoint> APs = new HashSet<AccessPoint>(capFile.AccessPoints.AsEnumerable(), new AccessPoint()); APs.UnionWith(this.AccessPoints.AsEnumerable()); _accessPoints.Clear(); foreach(AccessPoint AP in APs.ToArray()) { long MacAddrNumber = Utils.MacToLong(AP.BeaconFrame.MacAddress); _accessPoints.Add(MacAddrNumber, AP); } //merge Stations HashSet<Station> stations = new HashSet<Station>(capFile.Stations.AsEnumerable(), new Station()); stations.UnionWith(Stations.AsEnumerable()); _stations.Clear(); foreach (Station station in stations.ToArray()) { long MacAddrNumber = Utils.MacToLong(station.SourceMacAddress); _stations.Add(MacAddrNumber, station); } //merge Data Frames HashSet<DataFrame> dataFrames = new HashSet<DataFrame>(_dataFrames, new DataFrame()); dataFrames.UnionWith(capFile.DataFrames); _dataFrames.Clear(); _dataFrames.AddRange(dataFrames.ToArray()); //merge Auth Request Frames HashSet<AuthRequestFrame> authFrames = new HashSet<AuthRequestFrame>(_authRequestFrames, new AuthRequestFrame()); authFrames.UnionWith(capFile.AuthRequestFrames.AsEnumerable()); _authRequestFrames.Clear(); _authRequestFrames.AddRange(authFrames.ToArray()); } foreach (Station station in _stations.Values) { station.CaptureInfo = this; } //link all the DataFrames to the Stations int DataFrameCount = _dataFrames.Count; int DataFrameProgressValue = 0; SortedList<long, Station> StationList = new SortedList<long, Station>(); foreach (Station station in _stations.Values) { long MacSourceAddrNumber = Utils.MacToLong(station.SourceMacAddress); station.ClearDataFrames(); if (!StationList.ContainsKey(MacSourceAddrNumber)) StationList.Add(MacSourceAddrNumber, station); } for (int i = 0; i < _dataFrames.Count; i++) { Station station = null; if (StationList.TryGetValue(_dataFrames[i].SourceMacAddressLong, out station) || StationList.TryGetValue(_dataFrames[i].TargetMacAddressLong, out station)) { station.AddDataFrame(_dataFrames[i]); _dataFrames.RemoveAt(i); i--; DataFrameProgressValue++; if (onDataFrameProgress != null) onDataFrameProgress(DataFrameProgressValue, DataFrameCount); } } }
public static Station[] GetStationsFromAP(AccessPoint TargetAP, CapFile[] CapFiles) { Station[] Stations = GetStations(CapFiles); List<Station> TargetStations = new List<Station>(); foreach (Station station in Stations) { foreach (DataFrame frame in station.DataFrames) { if (frame.TargetMacAddressStr == TargetAP.MacAddress) { TargetStations.Add(station); break; } } } return TargetStations.ToArray(); }
private void ReadCapFiles() { LoadingForm LoadForm = new LoadingForm(); LoadForm.Show(); //CapFiles.Clear(); List<CapFile> CapFiles = new List<CapFile>(); foreach (string capFilePath in Directory.GetFiles(Environment.CurrentDirectory + "\\Data\\Captures", "*.cap")) { CapFile capFile = new CapFile(); LoadForm.SetCapFile(capFile); LoadForm.SetFileName(new FileInfo(capFilePath).Name); capFile.ReadCap(capFilePath); CapFiles.Add(capFile); } this.captureInfo = new CaptureInfo(); LoadForm.SetCaptureInfo(this.captureInfo); captureInfo.AddCapturefiles(CapFiles.ToArray()); CapFiles.Clear(); LoadForm.Close(); }
private void liveModeToolStripMenuItem_Click(object sender, EventArgs e) { if (!liveModeToolStripMenuItem.Checked) { if (AirservClient != null) { AirservClient.Disconnect(); } AirServSettingsForm sessingsForm = new AirServSettingsForm(); if (sessingsForm.ShowDialog() == DialogResult.OK) { this.AirservClient = sessingsForm.client; this.LiveCaptureFile = new CapFile(); captureInfo.Clear(); this.AirservClient.onPacketArrival += AirservClient_onPacketArrival; liveModeToolStripMenuItem.Checked = true; } } }