Example #1
0
        public static string CollectedInfoToMessage(CollectedInfo inf)
        {
            string info = "@1";

            info += "|" + inf.Date.ToString();
            info += "|" + inf.IP_Address.ToString() + "|";
            if (inf.AttackedPorts != null)
            {
                info += string.Join(",", inf.AttackedPorts);
            }
            info += "|" + inf.Country;
            if (inf.Attacks != null)
            {
                info += "|" + string.Join(",", inf.Attacks);
            }
            info += "|" + inf.NetworkDistance.ToString();
            info += "|" + inf.OS;
            info += "|" + string.Join(",", inf.OpenPorts);
            info += "| " + string.Join(",", inf.AttacksPeriods) + "||";
            return(info);
        }
Example #2
0
        public void AnalyzeSniffFile()
        {
            string filename;

            while (true)
            {
                if (AnalyzeQueue.Count > 0)
                {
                    lock (AnalyzeQueue)
                    {
                        filename = AnalyzeQueue.Dequeue();
                    }
                    var           check_res = CheckAttacks(filename);
                    var           att_ip    = GetAttackerIP(filename);
                    CollectedInfo colInfo;
                    if (!att_ip.Equals(GetCurrentIPAddress()))
                    {
                        colInfo = NmapAdapter.AnalyzeHost(att_ip);
                    }
                    else
                    {
                        colInfo = new CollectedInfo(DateTime.Now, IPAddress.Any, null, "NONE", null, 0, "NONE", new List <int>(), null);
                    }
                    colInfo.Attacks        = check_res.Item1;
                    colInfo.AttacksPeriods = check_res.Item2;
                    colInfo.AttackedPorts  = check_res.Item3;

                    var msg_col_info = Message.CollectedInfoToMessage(colInfo);
                    if (ServerCommunicator.OutMessages != null)
                    {
                        lock (ServerCommunicator.OutMessages)
                        {
                            ServerCommunicator.OutMessages.Enqueue(msg_col_info);
                        }
                    }
                }
            }
        }