Пример #1
0
        public void Execute(Dictionary <string, string> arguments)
        {
            uint luid = 0;

            if (arguments.ContainsKey("/luid"))
            {
                try
                {
                    luid = UInt32.Parse(arguments["/luid"]);
                }
                catch
                {
                    try
                    {
                        luid = Convert.ToUInt32(arguments["/luid"], 16);
                    }
                    catch
                    {
                        Console.WriteLine("[X] Invalid LUID format ({0})\r\n", arguments["/LUID"]);
                        return;
                    }
                }
            }

            LSA.Purge(luid);
        }
Пример #2
0
        public void Test_LSA_Calculate()
        {
            double[,] matrix = new double[, ]
            {
                { 1, 0, 0, 1, 0, 1, 0, 1, 0 },
                { 0, 0, 0, 1, 0, 0, 0, 1, 0 },
                { 0, 0, 0, 1, 0, 0, 0, 1, 0 },
                { 0, 0, 1, 0, 1, 0, 0, 0, 1 },
                { 0, 0, 1, 0, 1, 0, 0, 0, 1 },
                { 1, 0, 0, 1, 0, 1, 0, 1, 0 },
                { 1, 0, 0, 0, 0, 0, 0, 1, 0 },
                { 0, 0, 1, 0, 1, 0, 0, 0, 1 },
                { 0, 1, 0, 0, 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 0, 0, 1, 0, 0 },
                { 0, 1, 0, 0, 0, 1, 0, 0, 0 },
                { 0, 1, 0, 0, 0, 0, 1, 0, 0 },
                { 0, 0, 1, 0, 1, 0, 0, 0, 0 }
            };
            //TODO: написать ответ


            LSA lsa = new LSA(matrix);

            //TODO: написать проверку результатов подсчетов с ответом.
            //Разобраться почему получаются отрицательные значения.(возможно так и должно быть)
            //Assert.IsTrue();
        }
Пример #3
0
        public void Execute(Dictionary <string, string> arguments)
        {
            if (arguments.ContainsKey("/luid"))
            {
                Interop.LUID luid = new Interop.LUID();

                if (arguments.ContainsKey("/luid"))
                {
                    try
                    {
                        luid = new Interop.LUID(arguments["/luid"]);
                    }
                    catch
                    {
                        Console.WriteLine("[X] Invalid LUID format ({0})\r\n", arguments["/luid"]);
                        return;
                    }
                }

                LSA.ListKerberosTickets(luid);
            }
            else
            {
                LSA.ListKerberosTickets(new Interop.LUID());
            }
        }
Пример #4
0
        public void Execute(Dictionary <string, string> arguments)
        {
            if (arguments.ContainsKey("/ticket"))
            {
                string kirbi64 = arguments["/ticket"];

                if (Helpers.IsBase64String(kirbi64))
                {
                    byte[]   kirbiBytes = Convert.FromBase64String(kirbi64);
                    KRB_CRED kirbi      = new KRB_CRED(kirbiBytes);
                    LSA.DisplayTicket(kirbi);
                }
                else if (File.Exists(kirbi64))
                {
                    byte[]   kirbiBytes = File.ReadAllBytes(kirbi64);
                    KRB_CRED kirbi      = new KRB_CRED(kirbiBytes);
                    LSA.DisplayTicket(kirbi);
                }
                else
                {
                    Console.WriteLine("\r\n[X] /ticket:X must either be a .kirbi file or a base64 encoded .kirbi\r\n");
                }
                return;
            }
            else
            {
                Console.WriteLine("\r\n[X] A /ticket:X needs to be supplied!\r\n");
                return;
            }
        }
Пример #5
0
        private void CalculateEducationLineAndUsersCoord()
        {
            //Получаем чистое представление нашей матрицы(только числа, без доп. информации)
            var matrix = CalculateMatrix(allUserEducationLine);
            int row    = matrix.GetLength(0);
            int column = matrix.GetLength(1);

            LSA lsa = new LSA(matrix);

            //Проанализируем пользователей
            UsersToEducationLinesPosition = new List <ItemPosition>();
            for (int i = 0; i < row; i++)
            {
                int    id   = allUserEducationLine[i, 0].UserId;
                string name = allUserEducationLine[i, 0].UserName;

                UsersToEducationLinesPosition.Add(
                    new ItemPosition(id, name, lsa.UCoords[i, 0], lsa.UCoords[i, 1]));
            }

            //Проанализируем направления обучения
            EducationLinesToUsersPosition = new List <ItemPosition>();
            for (int i = 0; i < column; i++)
            {
                int    id   = allUserEducationLine[0, i].EducationLineId;
                string name = allUserEducationLine[0, i].EducationLineName;

                EducationLinesToUsersPosition.Add(
                    new ItemPosition(id, name, lsa.VCoords[i, 0], lsa.VCoords[i, 1]));
            }
        }
Пример #6
0
        private void CalculateEducationLineAndClusterCoord()
        {
            //Получаем чистое представление нашей матрицы(только числа, без доп. информации)
            var matrix = CalculateMatrix(AllEducationLinesCluster);
            int row    = matrix.GetLength(0);
            int column = matrix.GetLength(1);

            LSA lsa = new LSA(matrix);

            //Проанализируем пользователей
            EducationLinesToClusterPosition = new List <ItemPosition>();
            for (int i = 0; i < row; i++)
            {
                int    id   = AllEducationLinesCluster[i, 0].EducationLineId;
                string name = AllEducationLinesCluster[i, 0].EducationLineName;
                EducationLinesToClusterPosition.Add(
                    new ItemPosition(id, name, lsa.UCoords[i, 0], lsa.UCoords[i, 1]));
            }

            //Проанализируем кластеры обучения
            ClustersToEducationLinesPosition = new List <ItemPosition>();
            for (int i = 0; i < column; i++)
            {
                int    id   = AllEducationLinesCluster[0, i].ClusterId;
                string name = AllEducationLinesCluster[0, i].ClusterName;
                ClustersToEducationLinesPosition.Add(
                    new ItemPosition(id, name, lsa.VCoords[i, 0], lsa.VCoords[i, 1]));
            }
        }
Пример #7
0
   /// <summary>
   /// Updates the network with a newly received LSA (Link State Announcement).
   /// </summary>
   /// <param name="lsa">The LSA.</param>
   /// <returns>Null on successful update, and an LSA if the sequence number is older than the latest received from that sender.</returns>
   public LSA UpdateBackEndWithLSA(LSA lsa)
   {
       Node SenderNode = GetNodeByID(lsa.SenderNodeID);
       if (lsa.SequenceNumber > SenderNode.LastSequenceNumber)
       {
           int index = allNodes.IndexOf(SenderNode);
           allNodes[index].Neighbors = lsa.Links;
           allNodes[index].Users = lsa.Users;
           allNodes[index].LastSequenceNumber = lsa.SequenceNumber;
           allNodes[index].IsDown = false;
           allNodes[index].LastUpdateTime = DateTime.Now;
           this.UpdateRoutingTable();
           return null;
       }
       else
       {
           //send my lsa 
           /**** leh dol bass  *****/
           int index = allNodes.IndexOf(SenderNode);
           lsa.Links = allNodes[index].Neighbors;
           lsa.Users = allNodes[index].Users;
           lsa.SequenceNumber = allNodes[index].LastSequenceNumber;
           lsa.SenderNodeID = this.allNodes[index].NodeID;
           lsa.Type = LSAType.Advertisement;
           lsa.Version = 1;
           lsa.TTL = 32;
           return lsa;
       }
 
   }
Пример #8
0
        /// <summary>
        /// Broadcasts the local LSA to all neighbors.
        /// </summary>
        private void BroadcastLSA()
        {
            while (true)
            {
                Thread.Sleep(AdvertisementCycleTime);
                Backend.DaemonBackEnd.Instance.LocalNode.LastSequenceNumber += 1;
                LSA localLsa = Backend.DaemonBackEnd.Instance.GetLocalNodeLSA();
                foreach (Node n in Backend.DaemonBackEnd.Instance.LocalNode.Neighbors)
                {
                    if (!n.IsDown)
                    {
                        EndPoint EPN = n.Configuration.GetNodeEndPoint();
                        /**************************************************************/
                        try
                        {
                            daemonUDPSocket.SendTo(Utilities.LSAUtility.GetByteArrayFromLSA(localLsa), EPN);
                            Logger.Instance.Debug("i send new lsa to broad cast to port" + n.Configuration.RoutingPort.ToString());
                        }
                        catch
                        {
                            continue;
                        }

                        n.IsAcknowledged = false;
                    }
                    //wait for ack
                }

                Thread WaitForAckThread = new Thread(new ThreadStart(this.WaitForAck));
                WaitForAckThread.Start();
            }
            //throw new NotImplementedException();
        }
Пример #9
0
        public void Execute(Dictionary <string, string> arguments)
        {
            Interop.LUID luid    = new Interop.LUID();
            string       user    = "";
            string       service = "";

            if (arguments.ContainsKey("/luid"))
            {
                try
                {
                    luid = new Interop.LUID(arguments["/luid"]);
                }
                catch
                {
                    Console.WriteLine("[X] Invalid LUID format ({0})\r\n", arguments["/luid"]);
                    return;
                }
            }
            if (arguments.ContainsKey("/user"))
            {
                user = arguments["/user"];
            }
            if (arguments.ContainsKey("/service"))
            {
                service = arguments["/service"];
            }

            LSA.TriageKerberosTickets(luid, user, service);
        }
Пример #10
0
 // This function will get triggered/executed when a new message is written
 // on an Azure Queue called queue.
 public static void StartProcessingJob([QueueTrigger("buildqueue")] Tuple <int, IEnumerable <int> > jobTuple, TextWriter log)
 {
     log.WriteLine(jobTuple.Item1);
     Task.Factory.StartNew(() =>
     {
         LSA.ProcessAndStore(jobTuple.Item1, jobTuple.Item2);
     });
 }
Пример #11
0
        public void GetScoreTestForLSA3()
        {
            double[,] Gamma = BinarySerializationHelper.DeserializeObject <double[, ]>(Resources.Sample3);
            int    np       = 8;
            double expected = Double.Parse(Resources.LSAAnswer3);
            double actual   = LSA.GetScore(Gamma, np);

            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        // GET api/<controller>
        public IEnumerable <Document> Get(int page = 1, int docsPerPage = 20)
        {
            using (var context = new Engine.SvdEntities())
            {
                var documents = LSA.GetDocuments(context, page, docsPerPage);

                return(Mapper.Map <IEnumerable <Engine.Document>, IEnumerable <Document> >(documents, opt => opt.Items["context"] = context));;
            }
        }
Пример #13
0
        /// <summary>
        /// Creates the LSA from byte array.
        /// </summary>
        /// <param name="data">The byte array received.</param>
        /// <returns>The LSA.</returns>
        public static LSA CreateLSAFromByteArray(byte[] data)
        {
            LSA lsa = new LSA();

            int     version        = (int)data[0];
            int     ttl            = (int)data[1];
            LSAType type           = (LSAType)data[3];
            int     senderId       = BitConverter.ToInt32(data, 4);
            int     sequenceNumber = BitConverter.ToInt32(data, 8);

            if (type == LSAType.Acknowledgement)
            {
                return(new LSA()
                {
                    Version = version,
                    TTL = ttl,
                    Type = type,
                    SequenceNumber = sequenceNumber,
                    SenderNodeID = senderId
                });
            }


            int numOfLinks = BitConverter.ToInt32(data, 12);
            int numOfUsers = BitConverter.ToInt32(data, 16);

            Node[] nodes = new Node[numOfLinks];

            for (int i = 0; i < numOfLinks; i++)
            {
                int nodeId = BitConverter.ToInt32(data, 20 + i * 4);
                nodes[i] = DaemonBackEnd.Instance.GetNodeByID(nodeId);
            }

            User[] users = new User[numOfUsers];

            for (int i = 0; i < numOfUsers; i++)
            {
                string nickname = System.Text.Encoding.ASCII.GetString(data, 20 + numOfLinks * 4 + i * 16, 16);
                users[i] = new User()
                {
                    Nickname = nickname.Trim().Replace("\0", "")
                };
            }

            return(new LSA()
            {
                Version = version,
                Type = type,
                TTL = ttl,
                SenderNodeID = senderId,
                Links = nodes.ToList(),
                Users = users.ToList(),
                SequenceNumber = sequenceNumber
            });
        }
Пример #14
0
        private void RefreshTicketCache(bool display = false)
        {
            // goes through each ticket in the cache, removes any tickets that have expired
            //  and renews any tickets that are going to expire before the next check interval
            //  then displays the current "active" ticket cache if "display" is passed as true

            if (display)
            {
                Console.WriteLine("\r\n[*] Refreshing TGT ticket cache ({0})\r\n", DateTime.Now);
            }

            for (var i = harvesterTicketCache.Count - 1; i >= 0; i--)
            {
                var endTime    = TimeZone.CurrentTimeZone.ToLocalTime(harvesterTicketCache[i].enc_part.ticket_info[0].endtime);
                var renewTill  = TimeZone.CurrentTimeZone.ToLocalTime(harvesterTicketCache[i].enc_part.ticket_info[0].renew_till);
                var userName   = harvesterTicketCache[i].enc_part.ticket_info[0].pname.name_string[0];
                var domainName = harvesterTicketCache[i].enc_part.ticket_info[0].prealm;

                // check if the ticket has now expired
                if (endTime < DateTime.Now)
                {
                    Console.WriteLine("[!] Removing TGT for {0}@{1}\r\n", userName, domainName);
                    // remove the ticket from the cache
                    Console.WriteLine("harvesterTicketCache count: {0}", harvesterTicketCache.Count);
                    harvesterTicketCache.RemoveAt(i);
                    Console.WriteLine("harvesterTicketCache count: {0}", harvesterTicketCache.Count);
                }

                else
                {
                    // check if the ticket is going to expire before the next interval checkin
                    //  but we'll still be in the renew window
                    if ((endTime < DateTime.Now.AddSeconds(monitorIntervalSeconds)) && (renewTill > DateTime.Now.AddSeconds(monitorIntervalSeconds)))
                    {
                        // renewal limit after checkin interval, so renew the TGT
                        userName   = harvesterTicketCache[i].enc_part.ticket_info[0].pname.name_string[0];
                        domainName = harvesterTicketCache[i].enc_part.ticket_info[0].prealm;

                        Console.WriteLine("[*] Renewing TGT for {0}@{1}\r\n", userName, domainName);
                        var bytes       = Renew.TGT(harvesterTicketCache[i], "", false, "", false);
                        var renewedCred = new KRB_CRED(bytes);
                        harvesterTicketCache[i] = renewedCred;
                    }

                    if (display)
                    {
                        LSA.DisplayTicket(harvesterTicketCache[i], 2, true, true, false, this.nowrap);
                    }
                }
            }

            if (display)
            {
                Console.WriteLine("[*] Ticket cache size: {0}", harvesterTicketCache.Count);
            }
        }
Пример #15
0
        private void AddTicketsToTicketCache(List <KRB_CRED> tickets, bool displayNewTickets)
        {
            // adds a list of KRB_CREDs to the internal cache
            //  displayNewTickets - display new TGTs as they're added, e.g. "monitor" mode

            bool newTicketsAdded = false;

            if (tickets == null)
            {
                throw new ArgumentNullException(nameof(tickets));
            }

            foreach (var ticket in tickets)
            {
                var newTgtBytes = Convert.ToBase64String(ticket.RawBytes);

                var ticketInCache = false;

                foreach (var cachedTicket in harvesterTicketCache)
                {
                    // check the base64 of the raw ticket bytes to see if we've seen it before
                    if (Convert.ToBase64String(cachedTicket.RawBytes) == newTgtBytes)
                    {
                        ticketInCache = true;
                        break;
                    }
                }

                if (ticketInCache)
                {
                    continue;
                }

                var endTime = TimeZone.CurrentTimeZone.ToLocalTime(ticket.enc_part.ticket_info[0].endtime);

                if (endTime < DateTime.Now)
                {
                    // skip if the ticket is expired
                    continue;
                }

                harvesterTicketCache.Add(ticket);
                newTicketsAdded = true;

                if (displayNewTickets)
                {
                    Console.WriteLine($"\r\n[*] {DateTime.Now.ToUniversalTime()} UTC - Found new TGT:\r\n");
                    LSA.DisplayTicket(ticket, 2, true, true, false, this.nowrap);
                }
            }

            if (displayNewTickets && newTicketsAdded)
            {
                Console.WriteLine("[*] Ticket cache size: {0}\r\n", harvesterTicketCache.Count);
            }
        }
Пример #16
0
        public void HarvestTicketGrantingTickets()
        {
            if (!Helpers.IsHighIntegrity())
            {
                Console.WriteLine("\r\n[X] You need to have an elevated context to dump other users' Kerberos tickets :( \r\n");
                return;
            }

            // get the current set of TGTs
            while (true)
            {
                // extract out the TGTs (service = krbtgt_ w/ full data, silent enumeration
                List <LSA.SESSION_CRED> sessionCreds   = LSA.EnumerateTickets(true, new LUID(), "krbtgt", this.targetUser, null, true, true);
                List <KRB_CRED>         currentTickets = new List <KRB_CRED>();
                foreach (var sessionCred in sessionCreds)
                {
                    foreach (var ticket in sessionCred.Tickets)
                    {
                        currentTickets.Add(ticket.KrbCred);
                    }
                }

                if (renewTickets)
                {
                    // "harvest" mode - so don't display new tickets as they come in
                    AddTicketsToTicketCache(currentTickets, false);

                    // check if we're at a new display interval
                    if (lastDisplay.AddSeconds(this.displayIntervalSeconds) < DateTime.Now.AddSeconds(1))
                    {
                        this.lastDisplay = DateTime.Now;
                        // refresh/renew everything in the cache and display the working set
                        RefreshTicketCache(true);
                        Console.WriteLine("[*] Sleeping until {0} ({1} seconds) for next display\r\n", DateTime.Now.AddSeconds(displayIntervalSeconds), displayIntervalSeconds);
                    }
                    else
                    {
                        // refresh/renew everything in the cache, but don't display the working set
                        RefreshTicketCache();
                    }
                }
                else
                {
                    // "monitor" mode - display new ticketson harvest
                    AddTicketsToTicketCache(currentTickets, true);
                }

                if (registryBasePath != null)
                {
                    LSA.SaveTicketsToRegistry(harvesterTicketCache, registryBasePath);
                }

                Thread.Sleep(monitorIntervalSeconds * 1000);
            }
        }
Пример #17
0
 private static void ImportTicket(byte[] kirbiBytes, string createnetonly, bool show)
 {
     if (!string.IsNullOrEmpty(createnetonly))
     {
         Helpers.CreateProcessNetOnly(createnetonly, show, kirbiBytes: kirbiBytes);
     }
     else
     {
         LSA.ImportTicket(kirbiBytes, new LUID());
     }
 }
Пример #18
0
 public void Execute(Dictionary <string, string> arguments)
 {
     if (arguments.ContainsKey("/program"))
     {
         LSA.CreateProcessNetOnly(arguments["/program"], arguments.ContainsKey("/show"));
     }
     else
     {
         Console.WriteLine("\r\n[X] A /program needs to be supplied!\r\n");
     }
 }
Пример #19
0
 public void Execute(Dictionary <string, string> arguments)
 {
     if (arguments.ContainsKey("/target"))
     {
         byte[] blah = LSA.RequestFakeDelegTicket(arguments["/target"]);
     }
     else
     {
         byte[] blah = LSA.RequestFakeDelegTicket();
     }
 }
Пример #20
0
        /// <summary>
        /// Creates the acknoledgment LSA from the received LSA.
        /// </summary>
        /// <param name="receivedLSA">The received LSA.</param>
        /// <returns></returns>
        public static byte[] CreateAckLSAFromLSA(LSA receivedLSA)
        {
            LSA ackLsa = new LSA()
            {
                Type           = LSAType.Acknowledgement,
                SenderNodeID   = Backend.DaemonBackEnd.Instance.LocalNode.NodeID,
                SequenceNumber = receivedLSA.SequenceNumber
            };

            byte[] buffer = GetByteArrayFromLSA(ackLsa);
            return(buffer);
        }
        public static LokaiSkills XMLGetSkills(Mobile from)
        {
            LSA lsa;

            lsa = (LSA)XmlAttach.FindAttachment(from, typeof(LSA));
            if (lsa == null)
            {
                lsa = new LSA(from);
                XmlAttach.AttachTo(from, lsa);
            }
            return(lsa.Skills);
        }
Пример #22
0
        public void Execute(Dictionary <string, string> arguments)
        {
            Console.WriteLine("\r\n[*] Action: Request Fake Delegation TGT (current user)\r\n");

            if (arguments.ContainsKey("/target"))
            {
                byte[] blah = LSA.RequestFakeDelegTicket(arguments["/target"]);
            }
            else
            {
                byte[] blah = LSA.RequestFakeDelegTicket();
            }
        }
Пример #23
0
        public void Execute(Dictionary <string, string> arguments)
        {
            if (Helpers.IsHighIntegrity())
            {
                Console.WriteLine("\r\nAction: Dump Kerberos Ticket Data (All Users)\r\n");
            }
            else
            {
                Console.WriteLine("\r\nAction: Dump Kerberos Ticket Data (Current User)\r\n");
            }

            LUID   targetLuid    = new LUID();
            string targetUser    = "";
            string targetService = "";
            string targetServer  = "";

            if (arguments.ContainsKey("/luid"))
            {
                try
                {
                    targetLuid = new LUID(arguments["/luid"]);
                }
                catch
                {
                    Console.WriteLine("[X] Invalid LUID format ({0})\r\n", arguments["/luid"]);
                    return;
                }
            }

            if (arguments.ContainsKey("/user"))
            {
                targetUser = arguments["/user"];
            }

            if (arguments.ContainsKey("/service"))
            {
                targetService = arguments["/service"];
            }

            if (arguments.ContainsKey("/server"))
            {
                targetServer = arguments["/server"];
            }

            // extract out the tickets (w/ full data) with the specified targeting options
            List <LSA.SESSION_CRED> sessionCreds = LSA.EnumerateTickets(true, targetLuid, targetService, targetUser, targetServer, true);

            // display tickets with the "Full" format
            LSA.DisplaySessionCreds(sessionCreds, LSA.TicketDisplayFormat.Full);
        }
Пример #24
0
        public void Execute(Dictionary <string, string> arguments)
        {
            uint luid = 0;

            if (arguments.ContainsKey("/luid"))
            {
                try
                {
                    luid = UInt32.Parse(arguments["/luid"]);
                }
                catch
                {
                    try
                    {
                        luid = Convert.ToUInt32(arguments["/luid"], 16);
                    }
                    catch
                    {
                        Console.WriteLine("[X] Invalid LUID format ({0})\r\n", arguments["/LUID"]);
                        return;
                    }
                }
            }

            if (arguments.ContainsKey("/ticket"))
            {
                string kirbi64 = arguments["/ticket"];

                if (Helpers.IsBase64String(kirbi64))
                {
                    byte[] kirbiBytes = Convert.FromBase64String(kirbi64);
                    LSA.ImportTicket(kirbiBytes, luid);
                }
                else if (File.Exists(kirbi64))
                {
                    byte[] kirbiBytes = File.ReadAllBytes(kirbi64);
                    LSA.ImportTicket(kirbiBytes, luid);
                }
                else
                {
                    Console.WriteLine("\r\n[X]/ticket:X must either be a .kirbi file or a base64 encoded .kirbi\r\n");
                }
                return;
            }
            else
            {
                Console.WriteLine("\r\n[X] A /ticket:X needs to be supplied!\r\n");
                return;
            }
        }
Пример #25
0
        public async Task <IActionResult> AuthorSearch(AuthorSearchRequestViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var authorSearchRequest = viewModel.AuthorSearchRequest;

            var organizationAlternativeNames = OrganizationProvider.GetAlternativeNames(authorSearchRequest.Organization);

            var possibleOrganizations = new List <string>();

            if (!string.IsNullOrEmpty(authorSearchRequest.Organization))
            {
                possibleOrganizations.Add(authorSearchRequest.Organization);
                possibleOrganizations.AddRange(organizationAlternativeNames);
            }

            var profiles = new List <AuthorSearchResult>(await PageParser.GetProfilesFromAuthorSearch(authorSearchRequest.NameSurname, authorSearchRequest.NumberOfRecords, possibleOrganizations));

            IEnumerable <AuthorSearchResult> orderedProfiles = new List <AuthorSearchResult>();

            if (!string.IsNullOrEmpty(authorSearchRequest.Keywords))
            {
                var correlationProfiles = new Dictionary <AuthorSearchResult, double>();

                var lsa          = new LSA(authorSearchRequest.Keywords, profiles.Select(a => string.Join("; ", a.Publications.Select(p => p.Name))));
                var correlations = new List <CorrelationItem>(lsa.GetCorrelations());
                for (var i = 0; i < profiles.Count(); i++)
                {
                    correlationProfiles.Add(profiles[i], correlations[i].Value);
                }

                var orderedCorrelationProfiles = correlationProfiles.OrderByDescending(k => k.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
                orderedProfiles = orderedCorrelationProfiles.Keys;
            }
            else
            {
                orderedProfiles = profiles.OrderByDescending(p => p.HIndex);
            }

            return(View("AuthorSearchResults", new AuthorSearchResultsViewModel
            {
                Authors = orderedProfiles,
                PublicationActivity = viewModel.PublicationActivity,
                IsNum1 = viewModel.IsNum1,
                IsNum2 = viewModel.IsNum2
            }));
        }
Пример #26
0
        public static void UploadDocument([QueueTrigger("uploadqueue")] string blobName, [Blob("uploadbatch/{queueTrigger}", FileAccess.Read)] Stream blobStream, TextWriter log)
        {
            try
            {
                var binaryFormatter = new BinaryFormatter();

                var uploadDocs = binaryFormatter.Deserialize(blobStream) as UploadDocumentParameter[];

                uploadDocs.AsParallel().ForAll(doc => LSA.CreateDocument(doc.StreamData, doc.FileName));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #27
0
        /// <summary>
        /// Gets the local node LSA.
        /// </summary>
        /// <returns>The LSA of the local node.</returns>
        public LSA GetLocalNodeLSA()
        {
            LSA lsa = new LSA();
            lsa.SenderNodeID = this.LocalNode.NodeID;
            lsa.SequenceNumber = this.LocalNode.LastSequenceNumber ;
            lsa.Type = LSAType.Advertisement;
            lsa.Users = this.LocalNode.Users;
            lsa.Links = this.LocalNode.Neighbors;
            lsa.Version = 1;
            lsa.TTL = 32;
            
            return lsa;

           // throw new NotImplementedException();
        }
Пример #28
0
        /// <summary>
        /// Gets the byte array from the LSA.
        /// </summary>
        /// <param name="lsa">The LSA.</param>
        /// <returns>The byte array to send.</returns>
        public static byte[] GetByteArrayFromLSA(LSA lsa)
        {
            byte[] data = new byte[20 + lsa.Users.Count * 16 + lsa.Links.Count * 4];

            data[0] = Convert.ToByte(lsa.Version);
            data[1] = Convert.ToByte(lsa.TTL);
            data[2] = Convert.ToByte(0);
            data[3] = Convert.ToByte(lsa.Type);

            byte[] senderId       = BitConverter.GetBytes(lsa.SenderNodeID);
            byte[] sequenceNumber = BitConverter.GetBytes(lsa.SequenceNumber);
            byte[] numOfLinks     = BitConverter.GetBytes(lsa.Links.Count);
            byte[] numOfUsers     = BitConverter.GetBytes(lsa.Users.Count);

            byte[] users = new byte[lsa.Users.Count * 16];

            for (int i = 0; i < lsa.Users.Count * 16; i++)
            {
                users[i] = 0;
            }

            int offset = 0;

            foreach (User user in lsa.Users)
            {
                System.Text.Encoding.ASCII.GetBytes(user.Nickname).CopyTo(users, offset);
                offset += 16;
            }

            byte[] links = new byte[lsa.Links.Count * 4];

            offset = 0;
            foreach (Node link in lsa.Links)
            {
                BitConverter.GetBytes(link.NodeID).CopyTo(links, offset);
                offset += 4;
            }

            senderId.CopyTo(data, 4);
            sequenceNumber.CopyTo(data, 8);
            numOfLinks.CopyTo(data, 12);
            numOfUsers.CopyTo(data, 16);
            links.CopyTo(data, 20);
            users.CopyTo(data, 20 + links.Length);

            return(data);
        }
Пример #29
0
        /// <summary>
        /// Waits for acknowledgment LSA from all neighbors.
        /// </summary>
        private void WaitForAck()
        {
            int OldLsa = Backend.DaemonBackEnd.Instance.LocalNode.LastSequenceNumber;

            while (true)
            {
                //To DO:  new boardcase Lsa i want to break?????
                Thread.Sleep(RetransmissionTimeout);
                //byte[] buffer = new byte[1024];
                //EndPoint EP = new IPEndPoint(IPAddress.Any, 0);
                //daemonUDPSocket.ReceiveFrom(buffer, ref EP);
                //LSA Alsa = new LSA();
                //Alsa = Utilities.LSAUtility.CreateLSAFromByteArray(buffer);
                LSA  localLsa = Backend.DaemonBackEnd.Instance.GetLocalNodeLSA();
                bool allAkc   = true;
                foreach (Node n in Backend.DaemonBackEnd.Instance.LocalNode.Neighbors)
                {
                    if (!n.IsDown && !n.IsAcknowledged && n.LastSequenceNumber == OldLsa)
                    {
                        allAkc = false;
                        //******************** until   acknowledged, or a newer LSA has been issued by the BroadcastLSA thread and This thread does not wait for acknowledgments for flooded LSAs.
                        // EndPoint EPN = new IPEndPoint(IPAddress.Any, n.Configuration.RoutingPort);
                        try
                        {
                            Logger.Instance.Debug("not reseive ack i send lsa again");
                            daemonUDPSocket.SendTo(Utilities.LSAUtility.GetByteArrayFromLSA(localLsa), n.Configuration.GetNodeEndPoint());
                        }
                        catch
                        {
                            continue;
                        }

                        n.IsAcknowledged = false;
                    }
                }
                if (allAkc)
                {
                    return;
                }
            }
            // Handle retransmission
        }
Пример #30
0
        public void Execute(Dictionary <string, string> arguments)
        {
            Interop.LUID luid = new Interop.LUID();

            if (arguments.ContainsKey("/luid"))
            {
                try
                {
                    luid = new Interop.LUID(arguments["/luid"]);
                }
                catch
                {
                    Console.WriteLine("[X] Invalid LUID format ({0})\r\n", arguments["/luid"]);
                    return;
                }
            }

            Console.WriteLine("Luid: {0}", luid);

            LSA.Purge(luid);
        }