Esempio n. 1
0
        public void ConnectToOriginal()
        {
            signalStrengthTimer.Stop();
            stillConnectedTimer.Stop();

            if (originalAccessPoint == null)
            {
                return;
            }

            try {
                AccessPoint connectedAccessPoint = GetConnectedAccessPoint();
                if (connectedAccessPoint != null && connectedAccessPoint.Name.Equals(originalAccessPoint.Name))
                {
                    listener.ConnectedToDifferentNetwork(connectedAccessPoint.Name);
                    return;
                }

                AuthRequest authRequest = new AuthRequest(originalAccessPoint);
                originalAccessPoint.ConnectAsync(authRequest);
            }
            catch (Exception)
            {
                listener.NoWifiAvailable();
            }
        }
Esempio n. 2
0
        static private void ReadAccessDevices()
        {
            OleDbCommand command = new OleDbCommand();

            command.Connection  = _accessDBconnection;
            command.CommandText = "select DeviceId,DeviceFName,IpAddress from Devices";

            OleDbDataAdapter da = new OleDbDataAdapter(command);
            DataTable        dt = new DataTable();

            da.Fill(dt);

            DataColumn DeviceFName = dt.Columns["DeviceFName"];
            DataColumn DeviceId    = dt.Columns["DeviceId"];
            DataColumn IpAddress   = dt.Columns["IpAddress"];

            List <AccessPoint> accessPoints = new List <AccessPoint>();

            foreach (DataRow row in dt.Rows)
            {
                AccessPoint d = new AccessPoint();
                d.ID   = int.Parse(row[DeviceId].ToString());
                d.Name = row[DeviceFName].ToString();
                if (d.Name.Contains("Manual") || d.Name.Contains("Test Device"))
                {
                    continue;
                }
                d.IpAddress = row[IpAddress].ToString();
                accessPoints.Add(d);
            }

            AttendanceManager.AccessPoints = accessPoints;
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = listView1.SelectedItems[0];

                string ssid = listView1.SelectedItems[0].Text;
                Trace.WriteLine("SSID 123: ", ssid);

                SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = D:\OHIO SU\Subjects\Bitcoin and Networking\WpfApp1\WpfApp1\Database_All.mdf; Integrated Security = True;");
                con.Open();

                string     qu1  = "SELECT WifiPassword FROM [dbo].[Credentials] WHERE WifiSsid = @un;";
                SqlCommand cmd1 = new SqlCommand(qu1, con);
                cmd1.Parameters.Add("@un", SqlDbType.NVarChar).Value = ssid;
                string password = (string)cmd1.ExecuteScalar();

                Trace.WriteLine("Pass 123: ", password);


                AccessPoint ap = (AccessPoint)selectedItem.Tag;
                if (connectToWifi(ap, password))
                {
                    lbl_status.Text = "You connected Successfully";
                }
                else
                {
                    lbl_status.Text = "Connection Failed";
                }
            }
        }
Esempio n. 4
0
 private void CheckNetwork()
 {
     if (wifi.ConnectionStatus == WifiStatus.Connected)
     {
         AccessPoint connectedAccessPoint = GetConnectedAccessPoint();
         if (connectedAccessPoint == null)
         {
             listener.Disconnected();
             ConnectToCloudRover();
         }
         else
         {
             if (connectedAccessPoint.Name.Equals(CLOUD_ROVER_SSID))
             {
                 listener.ConnectedToCloudRover();
                 signalStrengthTimer.Start();
                 stillConnectedTimer.Start();
             }
             else
             {
                 listener.ConnectedToDifferentNetwork(connectedAccessPoint.Name);
                 ConnectToCloudRover();
             }
         }
     }
     else
     {
         listener.Disconnected();
         ConnectToCloudRover();
     }
 }
Esempio n. 5
0
        private bool connectToWifi(AccessPoint ap, string password)
        {
            AuthRequest authRequest = new AuthRequest(ap);

            authRequest.Password = password;
            return(ap.Connect(authRequest));
        }
Esempio n. 6
0
        private void scannerView_SelectionChanged(object sender, EventArgs e)
        {
            //if(scannerView.SelectedRows.Count > 0) Console.WriteLine(scannerView.SelectedRows[0]);
            if (_ignoreSelection)
            {
                //scannerView.SelectedRows.Clear();
                foreach (DataGridViewRow row in scannerGrid.Rows)
                {
                    row.Selected = false;
                }
                _ignoreSelection = false;
            }

            foreach (DataGridViewRow row in scannerGrid.Rows)
            {
                //    if(row.Selected)
                //    {
                //        _sc.Cache.GetAccessPointByMacAddress(row.Cells["macColumn"].Value.ToString()).Highlight = true;
                //    }
                AccessPoint apTemp = _sc.Cache.GetAccessPointById((long)row.Cells["idColumn"].Value);
                if (apTemp == null)
                {
                    continue;
                }

                apTemp.Highlight = row.Selected;
            }
            OnRequireRefresh();
            //if (scannerView.SelectedRows.Count > 0) _selectedRow = scannerView.SelectedRows[0].Index;
        }
Esempio n. 7
0
        private void ConnectToCloudRover()
        {
            AccessPoint connectedAccessPoint = GetConnectedAccessPoint();

            if (connectedAccessPoint != null && connectedAccessPoint.Name.Equals(CLOUD_ROVER_SSID))
            {
                listener.ConnectedToCloudRover();
                signalStrengthTimer.Start();
                stillConnectedTimer.Start();
                return;
            }

            AccessPoint cloudRoverAccessPoint = GetCloudRoverAccessPoint();

            if (cloudRoverAccessPoint != null)
            {
                originalAccessPoint = connectedAccessPoint;
                ConnectToCloudRover(cloudRoverAccessPoint);
            }
            else
            {
                listener.CloudRoverNotFound();
                cloudRoverInRangeTimer.Start();
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModifyAccessPointForm" /> class.
 /// </summary>
 /// <param name="accessPoint">The <paramref name="accessPoint"/> parameter.</param>
 public ModifyAccessPointForm(AccessPoint accessPoint)
 {
     InitializeComponent();
     SelectedAccessPoint   = accessPoint;
     tbxName.Text          = accessPoint.Name;
     cbxType.SelectedIndex = (int)accessPoint.Type;
 }
Esempio n. 9
0
        private void Reconnect(TimeSpan?WaitTime = null)
        {
            if (oAP != null)
            {
                var r = new AuthRequest(oAP);

                if (WaitTime.HasValue)
                {
                    Thread.Sleep(WaitTime.Value);
                }

                oAP.ConnectAsync(r, false, x =>
                {
                    if (!x)
                    {
                        WriteToConsole(ConsoleType.WiFiReconnectionProblem, oAP.Name);
                        oAP = GetNext(oAPs, oAP);
                        Reconnect(TimeSpan.FromMinutes(1));
                    }
                    else
                    {
                        WriteToConsole(ConsoleType.WiFiReconnected);
                    }
                });
            }
        }
        private static List <Point> GetAccessPointRangeIntersections(AccessPoint ap1, AccessPoint ap2)
        {
            var intersections = new List <Point>();

            var p0 = ap1.Location; var r0 = ap1.Distance;
            var p1 = ap2.Location; var r1 = ap2.Distance;
            var d  = DistanceBetweenPoints(p0, p1);
            var a  = (Math.Pow(r0, 2) - Math.Pow(r1, 2) + Math.Pow(d, 2)) / (2 * d);
            var h  = Math.Sqrt(Math.Pow(r0, 2) - Math.Pow(a, 2));
            var x2 = p0.X + (h * (p1.X - p0.X)) / d;
            var y2 = p0.Y + (h * (p1.Y - p0.Y)) / d;
            var x3 = x2 + (h * (p1.Y - p0.Y)) / d;
            var y3 = y2 - (h * (p1.X - p0.X)) / d;
            var x4 = x2 - (h * (p1.Y - p0.Y)) / d;
            var y4 = y2 + (h * (p1.X - p0.X)) / d;

            intersections.Add(new Point()
            {
                X = (int)x3, Y = (int)y3
            });
            intersections.Add(new Point()
            {
                X = (int)x4, Y = (int)y4
            });
            return(intersections);
        }
        public void TestUpdateApp()
        {
            var capabilityList = new CapabilityList
            {
                OS      = Architecture.CurrentSystem.OS,
                Entries = { new FileType {
                                ID = "my_ext1"
                            }, new FileType{
                                ID = "my_ext2"
                            } }
            };
            var feed = new Feed {
                Name = "Test 1", CapabilityLists = { capabilityList }
            };
            var accessPoints = new AccessPoint[] { new MockAccessPoint {
                                                       ID = "id1", Capability = "my_ext1"
                                                   } };

            var appEntry = _integrationManager.AddApp(new FeedTarget(FeedTest.Test1Uri, feed));

            _integrationManager.AddAccessPoints(appEntry, feed, accessPoints);
            _integrationManager.AppList.Entries[0].AccessPoints !.Entries
            .Should().Equal(accessPoints, because: "All access points should be applied.");

            // Modify feed
            feed.Name = "Test 2";
            capabilityList.Entries.RemoveLast();

            _integrationManager.UpdateApp(appEntry, feed);
            appEntry.Name.Should().Be("Test 2");
            _integrationManager.AppList.Entries[0].AccessPoints !.Entries
            .Should().Equal(new[] { accessPoints[0] }, because: "Only the first access point should be left.");
        }
        public async Task <bool> Add(AccessPoint item)
        {
            try
            {
                var filter = Builders <AccessPoint> .Filter.Eq(x => x.ID, item.ID) &
                             Builders <AccessPoint> .Filter.Eq(x => x.IpAddress, item.IpAddress);

                var o = _context.AccessPoints
                        .Find(filter)
                        .FirstOrDefaultAsync()
                        .Result;
                if (o == null)
                {
                    await _context.AccessPoints.InsertOneAsync(item);

                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                _logger.Warning("Something went wrong while adding AccessPoint with ID {@ID}.", item.ID);
                throw ex;
            }
        }
Esempio n. 13
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (f1.lvAccessPoints.SelectedItems.Count > 0)
            {
                ListViewItem selectedAP = f1.lvAccessPoints.SelectedItems[0];
                AccessPoint  ap         = (AccessPoint)selectedAP.Tag;

                if (connectToWifi(ap, txtPassword.Text))
                {
                    lblStatus.Visible          = true;
                    lblStatus.Text             = "Successfully connected to \n" + ap.Name;
                    f1.lblConnStatus.Text      = "ONLINE";
                    f1.lblConnStatus.ForeColor = Color.Green;
                    f1.btnDisconnect.Visible   = true;
                    f1.btnConnect.Visible      = false;
                    this.Close();
                }
                else
                {
                    lblStatus.Visible = true;
                    lblStatus.Text    = "Having difficulty connecting to " + ap.Name + " \nPlease check password and try again.";
                }
            }

            else
            {
                lblStatus.Visible = true;
                lblStatus.Text    = "This is a secured network, \na valid password is required.";
                lblStatus.Visible = true;
            }
        }
Esempio n. 14
0
        private void button_connect_Click(object sender, EventArgs e)
        {
            string selectedNetwork = null;

            // проверка, выбрана ли сеть для подключения
            if (dataGridView_networks.SelectedRows.Count > 0)
            {
                selectedNetwork = (string)dataGridView_networks.SelectedRows[0].Cells["SSID"].Value;
            }

            if (string.IsNullOrEmpty(selectedNetwork.Trim()))
            {
                MessageBox.Show($"Не выбрана сеть для подключения");
                return;
            }


            List <AccessPoint> aps = _wifiConnectClient.GetAccessPoints();
            AccessPoint        ap  = aps.Where(x => x.Name == selectedNetwork).FirstOrDefault();

            AuthRequest ar = new AuthRequest(ap);

            ar.Password = textBox_password.Text;

            bool res = ap.Connect(ar, true);

            _ui_update_connect_state(res);

            if (!res)
            {
                MessageBox.Show($"Подключение к сети {selectedNetwork} - не установлено!");
            }
        }
Esempio n. 15
0
 protected void RaiseAPInfoChange(AccessPoint ap)
 {
     if (APInfoChange != null)
     {
         APInfoChange(ap);
     }
 }
Esempio n. 16
0
        /// <summary>
        /// Creates the access point.
        /// </summary>
        /// <param name="tAccessPoint">The access point.</param>
        /// <returns></returns>
        public static AccessPoint CreateAccessPoint(string tAccessPoint)
        {
            AccessPoint accPoint = new AccessPoint();

            accPoint.Text = tAccessPoint;
            return(accPoint);
        }
Esempio n. 17
0
        public async Task <IActionResult> Edit(int id, [Bind("AccessPointID,From,To,Description")] AccessPoint accessPoint)
        {
            if (id != accessPoint.AccessPointID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accessPoint);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccessPointExists(accessPoint.AccessPointID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accessPoint));
        }
Esempio n. 18
0
        /// <summary>
        /// Creates the binding template.
        /// </summary>
        /// <param name="bAccessPoint">The access point.</param>
        /// <returns></returns>
        public static BindingTemplate CreateBindingTemplate(AccessPoint bAccessPoint)
        {
            BindingTemplate bTemplate = new BindingTemplate();

            bTemplate.AccessPoint = bAccessPoint;
            return(bTemplate);
        }
Esempio n. 19
0
        public static OperationResult <accessPoint> AddAccessPoint(user user, AccessPoint accessPoint)
        {
            if ((Roles)user.Role_Id != Roles.Admin && (Roles)user.Role_Id != Roles.Manager)
            {
                return new OperationResult <accessPoint> {
                           ErrorCode = 9, Message = "Unauthorized"
                }
            }
            ;

            var newDbAccessPoint = Entities.accessPoint.Add(new accessPoint
            {
                IPv4     = accessPoint.IPv4,
                IPv6     = accessPoint.IPv6,
                IsOn     = accessPoint.IsOn ? (byte)1 : (byte)0,
                Location = accessPoint.Location,
                Name     = accessPoint.Name,
            });

            Entities.SaveChanges();

            Entities.department_accessPoint.Add(new department_accessPoint
            {
                Department_Id  = user.Department_Id,
                AccessPoint_Id = accessPoint.Id
            });
            Entities.SaveChanges();

            return(new OperationResult <DB.accessPoint> {
                Success = true, ReturnValue = newDbAccessPoint
            });
        }
Esempio n. 20
0
        private async Task bruteForce(int xx, AccessPoint ap)
        {
            if (x == xx)
            {
                foreach (char chrx in area)
                {
                    texttotal = text + chrx;
                    Console.WriteLine(texttotal);
                    await Task.Run(() => connect(ap, texttotal));

                    //connect(ap, texttotal);
                }
            }
            else
            {
                xx--;
                foreach (char chrx in area)
                {
                    text += chrx;
                    await bruteForce(xx, ap);

                    text = text.Substring(0, text.Length - 1);
                }
            }
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            AccessPoint accessPoint = null;

            do
            {
                int employeeId = Request.Int("Hvad er dit medarbejder ID?");
                try
                {
                    accessPoint = new AccessPoint(employeeId);
                }
                catch (EntryPointNotFoundException)
                {
                    Console.WriteLine("Kunne ikke finde data for medarbejder ID " + employeeId);
                    Console.ReadKey();
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Noget gik galt mellem serveren & programmet: " + e);
                    Console.ReadKey();
                }
            } while (accessPoint is null);

            Department department = accessPoint.Department;

            SmartMenu smartMenu = new SmartMenu("Afdeling " + department.Id, "Luk programmet");

            smartMenu.Attach(new ShowAllCompensations(accessPoint));

            smartMenu.Attach(new CreateDriving(accessPoint));

            smartMenu.Attach(new CreateTravel(accessPoint));

            smartMenu.Activate();
        }
Esempio n. 22
0
        /// <summary>
        /// Validates the profile creation process for different encryption and authentication types.
        /// </summary>
        /// <param name="authentication">Authentication type of access point.</param>
        /// <param name="encryption">Encryption type of access point.</param>
        /// <param name="ssid">Ssid of access point.</param>
        /// <param name="keyType">KeyType of access point.</param>
        /// <param name="keyIsEncrypted">Key/password specified in profile is encrypted or not.</param>
        /// <param name="password">Password needed to connect to access point, null if open access point.</param>
        public void CreateAndValidateProfile(WiFiAuthentication authentication,
                                             WiFiEncryptionType encryption, string ssid, WiFiKeyType keyType,
                                             bool keyIsEncrypted, string password)
        {
            /* Create access point, needed in order to create connection profile. */
            AccessPoint accessPoint = new AccessPoint()
            {
                Ssid           = ssid,
                Authentication = authentication,
                Encryption     = encryption,
                BssType        = WiFiBssType.Infrastructure
            };

            string profileXml = _profileService.CreateProfileXml(accessPoint, password);

            Assert.IsNotNull(profileXml, "Generated connection profile is null.");
            Assert.IsNotEmpty(profileXml, "Generated connection profile is string.Empty.");

            /* Attributes of generated profile are returned in profile object. */
            Profile profile = new Profile();
            bool    result  = _profileService.Parse(profileXml, ref profile);

            Assert.IsTrue(result, "Failed to parse generated profile.");
            /* Validate attributes of generated profile. */
            Assert.AreEqual(authentication, profile.Authentication, "Failed to validate authentication.");
            Assert.AreEqual(encryption, profile.Encryption, "Failed to validate encryption.");
            Assert.AreEqual(ssid, profile.Ssid, "Failed to validate ssid.");
            Assert.AreEqual(ssid, profile.ProfileName, "Failed to validate profile name.");
            Assert.AreEqual(WiFiBssType.Infrastructure, profile.BssType, "Failed to validate profile BSS type.");
            Assert.IsFalse(profile.IsAutoConnectEnabled, "Wireless profile automatic connection is enabled.");
            Assert.IsFalse(profile.IsAutoSwitchEnabled, "Wireless profile automatic switch is enabled.");
            Assert.AreEqual(keyType, profile.KeyType, "Failed to validate wireless profile KeyType.");
            Assert.AreEqual(keyIsEncrypted, profile.KeyIsEncrypted, "Failed to validate profile property KeyIsEncrypted.");
            Assert.AreEqual(password, profile.KeyValue, "Wireless profile password is not equal to expected password.");
        }
Esempio n. 23
0
 protected void RaiseAPOutOfRange(AccessPoint ap)
 {
     if (APOutOfRange != null)
     {
         APOutOfRange(ap);
     }
 }
Esempio n. 24
0
        private void DoConnect()
        {
            InternalToken it = new InternalToken(DSAServices.PassportToken.PassportContent);

            InternalConnection = new Connection();
            InternalConnection.Connect(AccessPoint.Parse(TargetDSNS), "sm", it);
        }
Esempio n. 25
0
        public static async Task SeedDataAsync(this AccessControlContext accessControlContext)
        {
            //await accessControlContext.Database.EnsureDeletedAsync();

            if (await accessControlContext.Database.EnsureCreatedAsync())
            {
                var identity = new Identity()
                {
                    Id   = Guid.NewGuid(),
                    Name = "Bob",
                };

                accessControlContext.Identitiets.Add(identity);

                var accessPoint = new AccessPoint()
                {
                    Id         = Guid.NewGuid(),
                    Name       = "AccessPoint1",
                    AccessTime = TimeSpan.FromSeconds(8),
                    IPAddress  = "192.168.1.182"
                };

                accessPoint.AccessList = new AccessList()
                {
                    Id   = Guid.NewGuid(),
                    Name = "AccessPoint1_AccessList",
                };

                accessPoint.AccessList.Members.Add(identity);

                accessControlContext.AccessPoints.Add(accessPoint);

                await accessControlContext.SaveChangesAsync();
            }
        }
        private void PopulateAccessPoinsPnls()
        {
            List <AccessPoint> allAccessPointsFromWorld = AccessPoint.GetAllAccessPointFromWorldExceptFromOneLocation(world, currentLocation);

            foreach (AccessPointPnl apPanel in accessPointsPnls)
            {
                foreach (AccessPoint ap in accessPoints)
                {
                    if (ap.Direction == apPanel.direction)
                    {
                        apPanel.cbZone.SelectedItem = ap.DestZone.ToString();
                        apPanel.cbDest.SelectedItem = ap.DestLoc.ToString();
                    }
                }
                //foreach (AccessPoint ap in allAccessPointsFromWorld)
                //{
                //    if (AccessPoint.ReturnOppositeDirection(apPanel.lblDir.Text) == ap.Direction &&
                //                    ap.DestZone == currentZone.Name &&
                //                    ap.DestLoc ==currentLocation.Title)
                //    {
                //        apPanel.cbZone.SelectedItem = ap.DestZone.ToString();
                //        apPanel.cbDest.SelectedItem = ap.DestLoc.ToString();
                //    }
                //}
            }
        }
Esempio n. 27
0
        public bool Connect(AccessPoint ap, string password)
        {
            try
            {
                var  authRequest = new AuthRequest(ap);
                bool overwrite   = true;
                if (authRequest.IsPasswordRequired)
                {
                    if (!ap.IsValidPassword(password))
                    {
                        return(false);
                    }
                    authRequest.Password = password;
                }
                else
                {
                    authRequest.Password = "";
                }

                try
                {
                    return(ap.Connect(authRequest, true));
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            catch (Exception) { }

            return(true);
        }
        private void ApplyAccessPointsChanges()
        {
            accessPoints.Clear();
            locationsToCreate.Clear();


            foreach (AccessPointPnl apPnl in accessPointsPnls)
            {
                if (!String.IsNullOrWhiteSpace(apPnl.cbDest.Text))
                {
                    AccessPoint apToAdd = new AccessPoint(apPnl.direction, apPnl.cbZone.Text, apPnl.cbDest.Text.Trim());
                    accessPoints.Add(apToAdd);

                    Zone             zone = world.GetZoneFromString(apPnl.cbZone.Text);
                    zoneLocationPair locToCreate;
                    if (!zone.IsLocationExistingInZone(apPnl.cbDest.Text.Trim()))
                    {
                        locToCreate = new zoneLocationPair(zone.Name, apPnl.cbDest.Text.Trim());
                        locationsToCreate.Add(locToCreate);
                    }
                }
            }
            //if accessPointsOnFormLoad has an accessPoint not existing in accessPoints, It means it has been remove so we should remove the access point
            //from the opposite Location too.
            SyncOldAccessPointsAndNewOnes();
            this.Close();
        }
Esempio n. 29
0
        private bool check(AccessPoint selectedAP)
        {
            Collection <String> connectedSsids = new Collection <string>();

            if (WifiStatus.Connected.ToString() == "Connected")
            {
                foreach (WlanClient.WlanInterface wlanInterface in wlan.Interfaces)
                {
                    try
                    {
                        Wlan.Dot11Ssid ssid = wlanInterface.CurrentConnection.wlanAssociationAttributes.dot11Ssid;
                        connectedSsids.Add(new String(Encoding.ASCII.GetChars(ssid.SSID, 0, (int)ssid.SSIDLength)));
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                foreach (string ssid in connectedSsids)
                {
                    if (selectedAP.Name == ssid)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
Esempio n. 30
0
        private void UpdateOppositeAccessPoints()
        {
            foreach (AccessPoint ap in tempLocation.AccessPoints)
            {
                string dir          = ap.Direction;
                string oppositeDir  = AccessPoint.ReturnOppositeDirection(dir);
                string locToChange  = ap.DestLoc;
                string zoneToChange = ap.DestZone;

                Zone     targetZone     = world.GetZoneFromString(zoneToChange);
                Location targetLocation = targetZone.GetLocationByName(locToChange);
                if (targetLocation.AccessPoints == null)
                {
                    targetLocation.AccessPoints = new List <AccessPoint>();
                }
                if (targetLocation.AccessPoints.Count > 0)
                {
                    foreach (AccessPoint apTarget in targetLocation.AccessPoints)
                    {
                        if (apTarget.Direction == oppositeDir)
                        {
                            apTarget.DestZone = currentZone.Name;
                            apTarget.DestLoc  = tempLocation.Title;
                            return;
                        }
                    }
                }
                else
                {
                    AccessPoint tempAp = new AccessPoint(oppositeDir, currentZone.Name, tempLocation.Title);
                    targetLocation.AccessPoints.Add(tempAp);
                }
            }
        }
Esempio n. 31
0
 public AdHocAccessPoint(AccessPoint ap)
 {
     channel = ap.Channel;
     macAddress = ap.PhysicalAddress.GetAddressBytes();
     name = ap.Name;
     privacy = ap.Privacy;
     signalStrengthInDecibels = ap.SignalStrength.Decibels;
     signalStrengthQuality = ap.SignalStrength.Strength;
     supportedRates = ap.SupportedRates;
 }
        public static void SetAccessPoint(SharedBeacon sharedBeaconItem)
        {
            //if (sharedBeaconItem == null)
            //{
            //    return;
            //}

            WirelessCalculationClient _client = new WirelessCalculationClient(binding, endPoint);

            AccessPoint accessPoint = new AccessPoint
            {
                Bssid = sharedBeaconItem.Bssid,
                X = (int)sharedBeaconItem.PosX,
                Y = (int)sharedBeaconItem.PosY,
                XReal = (int)sharedBeaconItem.PosX,
                YReal = (int)sharedBeaconItem.PosY,
                Ssid = sharedBeaconItem.RssiLevel,
            };

            _client.SetAccessPointCompleted += _client_SetAccessPointCompleted;

            _client.SetAccessPointAsync(accessPoint);
            //var res = Task<int>.Factory.FromAsync (_client.SetAccessPointAsync, _client.SetAccessPointCompleted, value1, null, null);
        }
Esempio n. 33
0
        /// <summary>
        /// Add Access Point to the list
        /// </summary>
        /// <param name="ap">Access Point</param>
        /// <returns></returns>
        protected bool addAccessPoint(AccessPoint ap)
        {
            if (ap == null)
            {
                return false;
            }

            // Create DataTable if needed
            if (!this._dataset.Tables.Contains(ACCESSPOINTS_DATATABLE))
            {
                // Create Access Points DataTable
                DataTable dtAPs = new DataTable(ACCESSPOINTS_DATATABLE);
                dtAPs.CaseSensitive = true;
                
                // Create columns
                dtAPs.Columns.AddRange(this.getColumnsFromHashtable(ap.FieldsDictionary, ap.FieldsOrder));

                this._dataset.Tables.Add(dtAPs);
            }

            // Add row
            DataRow dr = this._dataset.Tables[ACCESSPOINTS_DATATABLE].NewRow();

            foreach (string key in ap.FieldsDictionary.Keys)
            {
                dr[key] = ap.FieldsDictionary[key];
            }

            // Add row
            this._dataset.Tables[ACCESSPOINTS_DATATABLE].Rows.Add(dr);

            // Add the Access Point to the list
            this._accessPoints.Add(ap);

            return true;
        }
Esempio n. 34
0
        /// <summary>
        /// Read/Update the content of the file
        /// </summary>
        /// <returns>true if successful</returns>
        /// <exception cref="FormatException">Airodump-ng CSV format unknown</exception>
        public override bool Read()
        {
            // Reset parsing status
            this.ParseSuccess = false;

            // Get the content of the file
            string[] content = this.getStrippedFileContent();

            // Get file format
            this._fileFormat = this.getFormat(content);

            if (this._fileFormat == CSVFileFormat.Unknown)
            {
                throw new FormatException("Airodump-ng CSV format unknown");
            }

            // Parse AP ...
            int i = 2; // Start at line 3 (skipping header)
            for (; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) 
            {
                string [] splitted = content[i].Split(',');

                switch (this._fileFormat)
                {
                    case CSVFileFormat.v0X:
                        if (splitted.Length < 11)
                        {
                            continue;
                        }
                        break;

                    case CSVFileFormat.v1X:
                        if (splitted.Length < 15)
                        {
                            continue;
                        }
                        break;
                }
                AccessPoint ap = new AccessPoint();
                ap.BSSID = splitted[0].Trim();
                ap.FirstTimeSeen = this.parseDateTime(splitted[1]);
                ap.LastTimeSeen = this.parseDateTime(splitted[2]);
                ap.Channel = int.Parse(splitted[3].Trim());
                ap.MaxRate = double.Parse(splitted[4].Trim());
                ap.Privacy = splitted[5].Trim();

                switch (this._fileFormat)
                {
                    case CSVFileFormat.v0X:
                        ap.Power = int.Parse(splitted[6].Trim());
                        ap.Beacons = long.Parse(splitted[7].Trim());
                        ap.DataFrames = ulong.Parse(splitted[8].Trim());
                        ap.IP = splitted[9].Replace(" ", "");
                        ap.ESSID = splitted[10].Substring(1); // TODO: Improve it because it may contain a ','
                        ap.ESSIDLength = (byte)ap.ESSID.Length;
                        break;

                    case CSVFileFormat.v1X:
                        ap.Cipher = splitted[6].Trim();
                        ap.Authentication = splitted[7].Trim();
                        ap.Power = int.Parse(splitted[8].Trim());
                        ap.Beacons = long.Parse(splitted[9].Trim());
                        ap.DataFrames = ulong.Parse(splitted[10].Trim());
                        ap.IP = splitted[11].Replace(" ", "");
                        ap.ESSIDLength = byte.Parse(splitted[12].Trim());
                        ap.ESSID = splitted[13].Substring(1); // TODO: Improve it because it may contain a ','
                        ap.Key = splitted[14];
                        break;
                }

                // Add AP to the list
                this.addAccessPoint(ap);
            }

            // ... Parse stations

            i += 2; // Skip station header
            for (; i < content.Length && !string.IsNullOrEmpty(content[i]); i++)
            {
                string[] splitted = content[i].Split(',');

                // Skip to the next if not long enough
                if (splitted.Length < 6)
                {
                    continue;
                }

                // Parse station information
                Station sta = new Station();
                sta.StationMAC = splitted[0].Trim();
                sta.FirstTimeSeen = this.parseDateTime(splitted[1]);
                sta.LastTimeSeen = this.parseDateTime(splitted[2]);
                sta.Power = int.Parse(splitted[3].Trim());
                sta.NbPackets = ulong.Parse(splitted[4].Trim());
                sta.BSSID = splitted[5].Trim();

                // Get probed ESSID list
                if (splitted.Length > 6 && splitted[6] != "")
                {
                    List<string> list = new List<string>();
                    for (int j = 6; j < splitted.Length; j++)
                    {
                        // There's always a whitespace character before
                        list.Add(splitted[j].Substring(1));
                    }
                    sta.ProbedESSIDsList = list.ToArray();
                }
                else
                {
                    sta.ProbedESSIDs = string.Empty;
                }

                // Add station to the list
                this.addStation(sta);
            }

            // Link them together
            this.LinkAPClients();

            // Parsing was successful
            this.ParseSuccess = true;

            return this.ParseSuccess;
        }
Esempio n. 35
0
 /// <summary>
 /// methods takes a lot of parameters belonging to an access point and adds the object to it's list
 /// </summary>
 /// <param name="bssid">string</param>
 /// <param name="rssi">double</param>
 /// <param name="mapMinRssi">double</param>
 /// <param name="mapMaxRssi">double</param>
 public void addAccessPointToSector(string bssid, double rssi, double mapMinRssi, double mapMaxRssi)
 {
     AccessPoint ap = new AccessPoint(bssid, rssi, mapMinRssi, mapMaxRssi);
     this.apList.Add(bssid, ap);
 }
Esempio n. 36
0
 /// <summary>
 /// method takes an <c>AccessPoint</c> and adds it to this sector.
 /// </summary>
 /// <param name="ap">AccessPoint</param>
 public void addAccessPointToSector(AccessPoint ap)
 {
     string bssid = ap.getBssid();
     this.apList.Add(bssid, ap);
 }
        private void StartModify(string orgPW, string newPW)
        {
            AccessPoint Database = new AccessPoint();
            Database.Filename = "BoundaryID.sdf";
            Database.Filepath = Helper.GetExeParentFolder() + "Database\\";

            Database.ChangePassword(orgPW, newPW);
            modifyFinished.Set();
        }
Esempio n. 38
0
        /// <summary>
        /// Read/Update the content of the file
        /// </summary>
        /// <returns>true if successful</returns>
        /// <exception cref="FormatException">Airodump-ng CSV format unknown</exception>
        public override bool Read()
        {
            // Reset parsing status
            this.ParseSuccess = false;

            // Get the content of the file
            string[] content = this.getStrippedFileContent();

            // Check if this is really a kismet CSV file
            if (content.Length == 0)
            {
                throw new FormatException("Empty file");
            }

            this.ParseSuccess = (content[0] == "Network;NetType;ESSID;BSSID;Info;Channel;Cloaked;Encryption;Decrypted;MaxRate;MaxSeenRate;Beacon;LLC;Data;Crypt;Weak;Total;Carrier;Encoding;FirstTime;LastTime;BestQuality;BestSignal;BestNoise;GPSMinLat;GPSMinLon;GPSMinAlt;GPSMinSpd;GPSMaxLat;GPSMaxLon;GPSMaxAlt;GPSMaxSpd;GPSBestLat;GPSBestLon;GPSBestAlt;DataSize;IPType;IP;");
            if (!this.ParseSuccess)
            {
                throw new FormatException("Not a Kismet CSV file");
            }

            // Parse content
            for (int i = 1; i < content.Length && !string.IsNullOrEmpty(content[i]); i++)
            {
                string [] splitted = content[i].Split(';');

                // Check if there are enough elements
                if (splitted.Length < 39)
                {
                    continue;
                }

                AccessPoint ap = new AccessPoint();
                
                // Skip first element which is the network number (if someone cares about it, email me)
                ap.NetworkType = splitted[1].Trim();
                ap.ESSID = splitted[2].Trim();
                ap.ESSIDLength = (byte)splitted[2].Length;
                ap.BSSID = splitted[3].Trim();
                ap.Info = splitted[4].Trim();
                ap.Channel = int.Parse(splitted[5]);
                ap.Cloaked = (splitted[6].Trim().ToLower() == "yes");
                ap.Encryption = splitted[7].Trim();
                ap.Decrypted = (splitted[8].Trim().ToLower() == "yes");
                ap.MaxRate = double.Parse(splitted[9]);
                ap.MaxSeenRate = double.Parse(splitted[10]);
                ap.Beacon = ulong.Parse(splitted[11]);
                ap.LLC = ulong.Parse(splitted[12]);
                ap.DataFrames = ulong.Parse(splitted[13]);
                ap.Crypt = ulong.Parse(splitted[14]);
                ap.Weak = ulong.Parse(splitted[15]);
                ap.Total = ulong.Parse(splitted[16]);
                ap.Carrier = splitted[17].Trim();
                ap.Encoding = splitted[18].Trim();
                ap.FirstTimeSeen = this.parseDateTime(splitted[19]);
                ap.LastTimeSeen = this.parseDateTime(splitted[20]);
                ap.BestQuality = int.Parse(splitted[21]);
                ap.BestSignal = int.Parse(splitted[22]);
                ap.BestNoise = int.Parse(splitted[23]);
                ap.MinLocation = new Coordinates(splitted[24], splitted[25], splitted[26], splitted[27]);
                ap.MaxLocation = new Coordinates(splitted[28], splitted[29], splitted[30], splitted[31]);
                ap.BestLocation = new Coordinates(splitted[32], splitted[33], splitted[34], "");
                ap.DataSize = ulong.Parse(splitted[35]);
                ap.IPType = int.Parse(splitted[36]);
                ap.IP = splitted[37].Replace(" ", "");

                this.addAccessPoint(ap);
            }

            // No need to link stations and access points together since there are only access points.

            return true;
        }
Esempio n. 39
0
        /// <summary>
        /// Is the Access Point dangerous ? Running Karma/Mana modules ?
        /// </summary>
        /// <param name="AP"></param>
        /// <returns></returns>
        public bool IsAccessPointDanger(AccessPoint AP)
        {
            List<string> names = new List<string>();

            foreach (AuthRequestFrame frame in _authRequestFrames.Where(o => (o.SourceMacAddressLong == AP.MacAddressLong ||
                                                                             o.TargetMacAddressLong == AP.MacAddressLong) &&
                                                                             !String.IsNullOrWhiteSpace(o.SSID)))
            {
                if (!names.Contains(frame.SSID))
                    names.Add(frame.SSID);

                if (names.Count > 5)
                {
                    return true;
                }
            }

            return false;
        }
Esempio n. 40
0
        /// <summary>
        /// De-Cloak an hidden Access Point
        /// </summary>
        /// <param name="AP">The AP to De-Cloak</param>
        /// <returns>De-Cloak successful ?</returns>
        public bool DeCloakAP(AccessPoint AP, ref string SSID)
        {
            if (!AP.BeaconFrame.IsHidden)
                return false;

            foreach (AuthRequestFrame frame in _authRequestFrames.Where(o => o.SourceMacAddressLong == AP.MacAddressLong ||
                                                                             o.TargetMacAddressLong == AP.MacAddressLong))
            {
                if(String.IsNullOrWhiteSpace(frame.SSID))
                    continue;
                SSID = frame.SSID;
                return true;
            }

            return false;
        }
Esempio n. 41
0
 public Station[] GetStationsFromAP(AccessPoint AP)
 {
     return Stations.Where(o => o.DataFrames.FirstOrDefault(frame => frame.TargetMacAddressLong == AP.MacAddressLong) != null).ToArray();
 }
Esempio n. 42
0
        /// <summary>
        /// loads a virtual access point map. you have to supply the type of the file and the name. possibles types are:
        ///
        /// - json (TODO: read file and interpret)
        /// 
        /// </summary>
        /// <param name="type">string</param>
        /// <param name="mapName">string</param>
        /// <returns>SortedDictionary</returns>
        public virtual SortedDictionary<int, Sector> loadMap(string type, string mapName)
        {
            SortedDictionary<int, Sector> apMap = new SortedDictionary<int, Sector>();

            Dictionary<string, AccessPoint> apList = new Dictionary<string, AccessPoint>();
            Sector tempSector = new Sector();

            if (type.Equals("xml"))
            {
                // xpath
                XPathNavigator nav;
                XPathDocument docNav;
                XPathNodeIterator NodeIter;
                String strExpression;

                docNav = new XPathDocument(mapName);
                Console.WriteLine("reading " + mapName);

                nav = docNav.CreateNavigator();

                // read map
                strExpression = "//map/sector/*";
                NodeIter = nav.Select(strExpression);

                int counter = 0;
                while (NodeIter.MoveNext())
                {
                    if (counter == 0)
                    {
                        Console.WriteLine("number: " + NodeIter.Current.Value);
                        tempSector.setSectorId(int.Parse(NodeIter.Current.Value));
                        this.xmlCountSector++;
                    }
                    else if (counter == 1)
                    {
                        Console.WriteLine("x: " + NodeIter.Current.Value);
                        tempSector.setX(int.Parse(NodeIter.Current.Value));
                    }
                    else if (counter == 2)
                    {
                        Console.WriteLine("y: " + NodeIter.Current.Value);
                        tempSector.setY(int.Parse(NodeIter.Current.Value));
                    }
                    else
                    {
                        if (NodeIter.Current.Value.Equals("stop"))
                        {
                            tempSector.setAccessPointList(apList);

                            Console.WriteLine("counter = " + counter);

                            apMap.Add(tempSector.getSectorId(), tempSector);
                            counter = 0;

                            // reset temp dicitionary
                            apList = null;
                            apList = new Dictionary<string, AccessPoint>();

                            Console.WriteLine("sector saved");
                        }
                        else
                        {
                           Console.WriteLine("accesspoint: " + NodeIter.Current.Value);
                           string[] splitted = NodeIter.Current.Value.Split('|');

                           Console.WriteLine("split0: " + splitted[0]);
                           Console.WriteLine("split1: " + splitted[1]);

                           AccessPoint tempAp = new AccessPoint(splitted[0], double.Parse(splitted[1]));

                           apList.Add(splitted[0], tempAp);

                           this.xmlCountAps++;
                        }
                    }

                    if(!NodeIter.Current.Value.Equals("stop"))
                        counter++;
                }

                Console.WriteLine("finished reading");

                if (apMap.Count == 0)
                    Console.WriteLine("ap map while xml loading is empty!");

                return apMap;
            }
            else if (type.Equals("json"))
            {
                Console.WriteLine("json file loading ... ");
                // MAKE ME WORK
                return null;
            }
            else
            {
                Console.WriteLine("only 'xml' or 'json' files could be read!");
                return null;
            }
        }
Esempio n. 43
0
        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();
        }
Esempio n. 44
0
 void capFile_onReadAccessPoint(AccessPoint AP)
 {
     AccessPointCount++;
     RefreshValues();
 }
Esempio n. 45
0
        public void ProcessPacket(Packet packet, DateTime ArrivalDate)
        {
            PacketDotNet.Ieee80211.BeaconFrame beacon = packet as PacketDotNet.Ieee80211.BeaconFrame;
            PacketDotNet.Ieee80211.ProbeRequestFrame probeRequest = packet as PacketDotNet.Ieee80211.ProbeRequestFrame;
            PacketDotNet.Ieee80211.QosDataFrame DataFrame = packet as PacketDotNet.Ieee80211.QosDataFrame;

            PacketDotNet.Ieee80211.DeauthenticationFrame DeAuthFrame = packet as PacketDotNet.Ieee80211.DeauthenticationFrame;
            PacketDotNet.Ieee80211.AssociationRequestFrame AuthRequestFrame = packet as PacketDotNet.Ieee80211.AssociationRequestFrame;

            PacketDotNet.Ieee80211.DataDataFrame DataDataFrame = packet as PacketDotNet.Ieee80211.DataDataFrame;

            if (beacon != null)
            {
                BeaconFrame beaconFrame = new BeaconFrame(beacon, ArrivalDate);
                _beacons.Add(beaconFrame);

                long MacAddrNumber = Utils.MacToLong(beaconFrame.MacAddress);

                //check for APs with this Mac Address
                AccessPoint AP = null;

                if (!_accessPoints.TryGetValue(MacAddrNumber, out AP))
                {
                    AP = new AccessPoint(beaconFrame);
                    _accessPoints.Add(MacAddrNumber, AP);
                }
                AP.AddBeaconFrame(beaconFrame);

                if (onReadAccessPoint != null)
                    onReadAccessPoint(AP);
            }
            else if (probeRequest != null)
            {
                ProbePacket probe = new ProbePacket(probeRequest, ArrivalDate);
                Station station = null;

                long MacAddrNumber = Utils.MacToLong(probe.SourceMacAddress);

                if (!_stations.TryGetValue(MacAddrNumber, out station))
                {
                    station = new Station(probe);
                    _stations.Add(MacAddrNumber, station);
                }

                station.AddProbe(probe);

                if (onReadStation != null)
                    onReadStation(station);
            }
            else if (DataFrame != null)
            {
                DataFrame _dataFrame = new Packets.DataFrame(DataFrame, ArrivalDate);

                _dataFrames.Add(_dataFrame);

                if (onReadDataFrame != null)
                    onReadDataFrame(_dataFrame);
            }
            else if (DataDataFrame != null)
            {
                DataFrame _dataFrame = new Packets.DataFrame(DataDataFrame, ArrivalDate);

                _dataFrames.Add(_dataFrame);

                if (onReadDataFrame != null)
                    onReadDataFrame(_dataFrame);
            }
            else if (AuthRequestFrame != null)
            {
                _authRequestFrames.Add(new AuthRequestFrame(AuthRequestFrame, ArrivalDate));
            }
        }