コード例 #1
0
        static void Main(string[] args)
        {
            string path = System.Reflection.Assembly.GetExecutingAssembly().Location;

            path = path.Substring(0, path.LastIndexOf('\\') + 1);

            // Console.WriteLine("Directory: {0}", path);
            if (args.Length == 0 || args[0].ToLower() == "help")
            {
                ShowUsage();
                return;
            }
            try {
                Database.Instance.Configure(path);
                IddsConfig.Instance.ApplicationPath = path;
                switch (args[0].ToLower())
                {
                case "islicensed":
                    Console.WriteLine(@"Cyberarms IDDS does not require licensing anymore. Please visit https://cyberarms.net for support options!");
                    break;

                case "manualreport":
                    if (args.Length < 2)
                    {
                        Console.WriteLine("Please enter output filename as parameter.");
                        return;
                    }
                    string report = ReportGenerator.Instance.GetReport(String.Format("Manual report, {0:MM/dd/yyyy}", DateTime.Now),
                                                                       String.Format("Manually created report for system {0}.{1}", System.Net.Dns.GetHostName(), System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName), ""
                                                                       , DateTime.Now.AddMonths(-1), DateTime.Now);
                    try {
                        StreamWriter sw = System.IO.File.CreateText(args[1]);
                        sw.Write(report);
                        sw.Close();
                    } catch (Exception ex) {
                        Console.WriteLine(ex.Message);
                    }
                    break;

                case "exportcsv":
                    if (args.Length < 2)
                    {
                        Console.WriteLine("Please enter output filename as parameter.");
                        return;
                    }
                    int lastSquenceNumber = 0;
                    if (args.Length > 2)
                    {
                        if (!int.TryParse(args[2], out lastSquenceNumber))
                        {
                            Console.WriteLine("Please enter last sequence number as parameter.");
                        }
                    }
                    try {
                        StreamWriter            swexport = System.IO.File.CreateText(args[1]);
                        System.Data.IDataReader rdr      = IntrusionLog.ReadDifferential(lastSquenceNumber);
                        swexport.WriteLine("Sequence Number;Date and Time;Security Agent;IP Address;Status");
                        while (rdr.Read())
                        {
                            swexport.WriteLine("{0};{1};{2};{3};{4}", rdr[0].ToString(), rdr[1].ToString(), SecurityAgents.Instance.GetDisplayName(rdr[2].ToString()),
                                               rdr[3].ToString(), IntrusionLog.GetStatusName(int.Parse(rdr[4].ToString())));
                        }
                        swexport.Flush();
                        swexport.Close();
                        rdr.Close();
                    } catch (Exception ex) {
                        Console.WriteLine(ex.Message);
                    }
                    break;

                default:
                    ShowUsage();
                    break;
                }
            } catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
コード例 #2
0
ファイル: IddsAdmin.cs プロジェクト: vishalishere/Cyberarms
        void logReader_Tick(object sender, EventArgs e)
        {
            DateTime metering = DateTime.Now;

            if (!IsUpdating && Database.Instance.IsConfigured)
            {
                IsUpdating = true;
                if (CurrentMenu == labelMenuSecurityLog && IntrusionLog.HasUpdates(LastLogId))
                {
                    IDataReader rdr      = IntrusionLog.ReadDifferential(LastLogId);
                    int         maxLogId = LastLogId;
                    while (rdr.Read())
                    {
                        int    action  = int.Parse(rdr["Action"].ToString());
                        string agentId = Shared.Db.DbValueConverter.ToString(rdr["AgentId"]);
                        PanelSecurityLog.AddLogEntry(int.Parse(rdr["id"].ToString()), action,
                                                     agentId,
                                                     IntrusionLog.GetStatusIcon(action),
                                                     IntrusionLog.GetStatusClass(action), DateTime.Parse(rdr["IncidentTime"].ToString()), rdr["ClientIP"].ToString(),
                                                     GetLogMessage(agentId, action));
                        if (Convert.ToInt32(rdr["Id"]) > maxLogId)
                        {
                            maxLogId = Convert.ToInt32(rdr["Id"]);
                        }
                    }
                    rdr.Close();
                    rdr.Dispose();
                    if (maxLogId > LastLogId)
                    {
                        LastLogId = maxLogId;
                    }
                }

                if (CurrentMenu == labelMenuCurrentLocks && Locks.HasUpdates(LastLockUpdate))
                {
                    LastLockUpdate = DateTime.Now;
                    PanelCurrentLocks.Clear();
                    IDataReader locksReader = Locks.ReadLocks();
                    while (locksReader.Read())
                    {
                        DateTime lockDate;
                        DateTime unlockDate;
                        DateTime.TryParse(locksReader["LockDate"].ToString(), out lockDate);
                        DateTime.TryParse(locksReader["UnlockDate"].ToString(), out unlockDate);
                        PanelCurrentLocks.Add(int.Parse(locksReader["LockId"].ToString()), global::Cyberarms.IntrusionDetection.Admin.Properties.Resources.logIcon_softLock,
                                              LockStatusAdapter.GetLockStatusName(int.Parse(locksReader["Status"].ToString())), locksReader["ClientIp"].ToString(),
                                              locksReader["DisplayName"].ToString(),
                                              lockDate, unlockDate, IntrusionDetection.Shared.Db.DbValueConverter.ToInt(locksReader["Status"]));
                    }
                    locksReader.Close();
                    locksReader.Dispose();
                }
                if (CurrentMenu == labelMenuHome)
                {
                    Dashboard.SetUnsuccessfulLogins(Locks.ReadUnsuccessfulLoginAttempts(DateTime.Now.AddDays(-30)));
                    foreach (SecurityAgent agent in SecurityAgents.Instance)
                    {
                        agent.UpdateStatistics();
                    }
                }
                if (CurrentMenu == labelMenuHome || CurrentMenu == labelMenuCurrentLocks)
                {
                    int softLocks = Locks.ReadCurrentSoftLocks();
                    int hardLocks = Locks.ReadCurrentHardLocks();
                    PanelCurrentLocks.SetSoftLocks(softLocks);
                    PanelCurrentLocks.SetHardLocks(hardLocks);
                    Dashboard.SetHardLocks(hardLocks);
                    Dashboard.SetSoftLocks(softLocks);
                }
                if (!IsInitialized || (CurrentMenu == labelMenuHome || CurrentMenu == labelMenuSecurityLog))
                {
                    // ??
                }
            }
            IsInitialized = true;
            IsUpdating    = false;
            System.Diagnostics.Debug.Print(DateTime.Now.Subtract(metering).TotalMilliseconds.ToString());
        }