Example #1
0
 public void ApplyFilter(FirewallPage.FilterPreset CurFilter)
 {
     foreach (var setItem in progSets.Values)
     {
         setItem.IsHidden = (CurFilter != null && FirewallPage.DoFilter(CurFilter, setItem.progSet));
     }
 }
Example #2
0
        private bool LogFilter(object obj)
        {
            var item = obj as LogItem;

            switch (evetnFilter)
            {
            case FirewallRule.Actions.Allow: if (item.entry.FwEvent.Action != FirewallRule.Actions.Allow)
                {
                    return(false);
                }
                break;

            case FirewallRule.Actions.Block: if (item.entry.FwEvent.Action != FirewallRule.Actions.Block)
                {
                    return(false);
                }
                break;
            }

            if (item.IsLocal)
            {
                if (chkNoLocal.IsChecked == true)
                {
                    return(false);
                }
            }
            else if (item.IsMulti)
            {
                if (chkNoMulti.IsChecked == true)
                {
                    return(false);
                }
            }
            else if (item.IsLan)
            {
                if (chkNoLAN.IsChecked == true)
                {
                    return(false);
                }
            }
            else if (chkNoINet.IsChecked == true)
            {
                return(false);
            }

            if (FirewallPage.DoFilter(textFilter, item.name, new List <ProgramID>()
            {
                item.entry.ProgID
            }))
            {
                return(false);
            }
            return(true);
        }
Example #3
0
        private void SortAndFitlerProgList()
        {
            List <ProgramControl> OrderList = Programs.Values.ToList();

            int DoSort(ProgramControl l, ProgramControl r)
            {
                switch (SortBy)
                {
                case Sorts.Name: return(l.progSet.config.Name.CompareTo(r.progSet.config.Name));

                case Sorts.NameRev: return(r.progSet.config.Name.CompareTo(l.progSet.config.Name));

                case Sorts.LastActivity: return(r.progSet.GetLastActivity().CompareTo(l.progSet.GetLastActivity()));

                case Sorts.DataRate: return(r.progSet.GetDataRate().CompareTo(l.progSet.GetDataRate()));

                case Sorts.SocketCount: return(r.progSet.GetSocketCount().CompareTo(l.progSet.GetSocketCount()));

                case Sorts.ModuleCount: return(r.progSet.Programs.Count.CompareTo(l.progSet.Programs.Count));
                }
                return(0);
            }

            if (SortBy != Sorts.Unsorted)
            {
                OrderList.Sort(DoSort);
            }

            for (int i = 0; i < OrderList.Count; i++)
            {
                if (i >= this.processGrid.RowDefinitions.Count)
                {
                    this.processGrid.RowDefinitions.Add(new RowDefinition());
                }
                RowDefinition row = this.processGrid.RowDefinitions[i];
                //ProcessControl item = tmp.Item2;
                ProgramControl item = OrderList[i];
                if (row.Height.Value != item.Height)
                {
                    row.Height = GridLength.Auto; //new GridLength(item.Height + 2);
                }
                Grid.SetRow(item, i);

                item.Visibility = (CurFilter != null && FirewallPage.DoFilter(CurFilter, item.progSet)) ? Visibility.Collapsed : Visibility.Visible;
            }

            while (OrderList.Count < this.processGrid.RowDefinitions.Count)
            {
                this.processGrid.RowDefinitions.RemoveAt(OrderList.Count);
            }
        }
Example #4
0
            public bool TestFilter(string textFilter)
            {
                string strings = this.Name;

                strings += " " + this.HostName;
                strings += " " + this.LastSeen;
                strings += " " + this.SeenCount;
                strings += " " + this.ConnectionCount;
                strings += " " + this.Uploaded;
                strings += " " + this.Downloaded;
                return(FirewallPage.DoFilter(textFilter, strings, new List <ProgramID>()
                {
                    this.entry.ProgID
                }));
            }
        private bool RuleFilter(object obj)
        {
            var item = obj as RuleItem;

            switch (actionFilter)
            {
            case FirewallRule.Actions.Allow: if (item.Rule.Action != FirewallRule.Actions.Allow)
                {
                    return(false);
                }
                break;

            case FirewallRule.Actions.Block: if (item.Rule.Action != FirewallRule.Actions.Block)
                {
                    return(false);
                }
                break;
            }

            switch (directionFilter)
            {
            case FirewallRule.Directions.Inbound: if (item.Rule.Direction != FirewallRule.Directions.Inbound)
                {
                    return(false);
                }
                break;

            case FirewallRule.Directions.Outboun: if (item.Rule.Direction != FirewallRule.Directions.Outboun)
                {
                    return(false);
                }
                break;
            }

            if (chkNoDisabled.IsChecked == true && item.Rule.Enabled == false)
            {
                return(false);
            }

            if (FirewallPage.DoFilter(textFilter, item.Name, new List <ProgramID>()
            {
                item.Rule.ProgID
            }))
            {
                return(false);
            }
            return(true);
        }
Example #6
0
            public bool TestFilter(string textFilter)
            {
                string strings = this.Name;

                strings += " " + this.TimeStamp;
                strings += " " + this.Action;
                strings += " " + this.Direction;
                strings += " " + this.Protocol;
                strings += " " + this.DestAddress;
                strings += " " + this.DestPorts;
                strings += " " + this.SrcAddress;
                strings += " " + this.SrcPorts;
                return(FirewallPage.DoFilter(textFilter, strings, new List <ProgramID>()
                {
                    this.entry.ProgID
                }));
            }
Example #7
0
            public bool TestFilter(string textFilter)
            {
                string strings = this.Name;

                strings += " " + this.TimeStamp;
                strings += " " + this.State;
                strings += " " + this.Protocol;
                strings += " " + this.DestAddress;
                strings += " " + this.DestPorts;
                strings += " " + this.SrcAddress;
                strings += " " + this.SrcPorts;
                strings += " " + this.Access;
                strings += " " + this.Upload;
                strings += " " + this.Download;
                strings += " " + this.Uploaded;
                strings += " " + this.Downloaded;
                return(FirewallPage.DoFilter(textFilter, strings, new List <ProgramID>()
                {
                    this.sock.ProgID
                }));
            }
Example #8
0
        public bool OnActivity(ProgramSet prog, Program program, Priv10Engine.FwEventArgs args)
        {
            ProgramControl item = null;

            if (!ProgramList.Items.TryGetValue(args.guid.ToString(), out item))
            {
                if (FirewallPage.DoFilter(CurFilter, prog))
                {
                    return(false);
                }

                item = ProgramList.AddItem(prog);

                args.update = false;
            }

            //Note: windows firewall doesn't block localhost acces so we ignore it
            //if (args.entry.State == Program.LogEntry.States.RuleError
            //  && args.entry.FwEvent.Action == FirewallRule.Actions.Allow
            //  && !NetFunc.IsLocalHost(args.entry.FwEvent.RemoteAddress))
            //    item.SetError(true);

            if ((chkNoLocal.IsChecked != true || (args.entry.Realm != Program.LogEntry.Realms.LocalHost && args.entry.Realm != Program.LogEntry.Realms.MultiCast)) &&
                (chkNoLan.IsChecked != true || args.entry.Realm != Program.LogEntry.Realms.LocalArea) &&
                args.entry.FwEvent.ProcessId != ProcFunc.CurID) // Note: When DNS proxy is nabled we are always very active, so ignore it
            {
                switch (args.entry.FwEvent.Action)
                {
                case FirewallRule.Actions.Allow: item.Flash(Colors.LightGreen); break;

                case FirewallRule.Actions.Block: item.Flash(Colors.LightPink); break;
                }
            }

            item.DoUpdate(prog);

            return(SortBy == Sorts.LastActivity);
        }
Example #9
0
            public bool TestFilter(string textFilter)
            {
                string strings = this.Name;

                strings += " " + this.Grouping;
                strings += " " + this.Index;
                strings += " " + this.Status;
                strings += " " + this.Profiles;
                strings += " " + this.Action;
                strings += " " + this.Direction;
                strings += " " + this.Protocol;
                strings += " " + this.DestAddress;
                strings += " " + this.DestPorts;
                strings += " " + this.SrcAddress;
                strings += " " + this.SrcPorts;
                strings += " " + this.ICMPOptions;
                strings += " " + this.Interfaces;
                strings += " " + this.EdgeTraversal;
                return(FirewallPage.DoFilter(textFilter, strings, new List <ProgramID>()
                {
                    this.Rule.ProgID
                }));
            }
Example #10
0
        private bool SocksFilter(object obj)
        {
            var item = obj as SocketItem;

            if (socketFilter != FirewallPage.FilterPreset.Socket.Any)
            {
                switch (socketFilter)
                {
                case FirewallPage.FilterPreset.Socket.TCP:
                    if ((item.sock.ProtocolType & (UInt32)IPHelper.AF_PROT.TCP) == 0)
                    {
                        return(false);
                    }
                    break;

                case FirewallPage.FilterPreset.Socket.Client:
                    if ((item.sock.ProtocolType & (UInt32)IPHelper.AF_PROT.TCP) == 0 || item.sock.State == (int)IPHelper.MIB_TCP_STATE.LISTENING)
                    {
                        return(false);
                    }
                    break;

                case FirewallPage.FilterPreset.Socket.Server:
                    if ((item.sock.ProtocolType & (UInt32)IPHelper.AF_PROT.TCP) == 0 || item.sock.State != (int)IPHelper.MIB_TCP_STATE.LISTENING)
                    {
                        return(false);
                    }
                    break;

                case FirewallPage.FilterPreset.Socket.UDP:
                    if ((item.sock.ProtocolType & (UInt32)IPHelper.AF_PROT.UDP) == 0)
                    {
                        return(false);
                    }
                    break;

                case FirewallPage.FilterPreset.Socket.Web:
                    if ((item.sock.ProtocolType & (UInt32)IPHelper.AF_PROT.TCP) == 0 || !(item.sock.RemotePort == 80 || item.sock.RemotePort == 443))
                    {
                        return(false);
                    }
                    break;
                }
            }

            if (item.sock.RemoteAddress != null)
            {
                if (NetFunc.IsLocalHost(item.sock.RemoteAddress))
                {
                    if (chkNoLocal.IsChecked == true)
                    {
                        return(false);
                    }
                }

                /*else if (NetFunc.IsMultiCast(item.sock.RemoteAddress))
                 * {
                 *  if (chkNoMulti.IsChecked == true)
                 *      return false;
                 * }*/
                else if (FirewallRule.MatchAddress(item.sock.RemoteAddress, FirewallRule.AddrKeywordLocalSubnet))
                {
                    if (chkNoLAN.IsChecked == true)
                    {
                        return(false);
                    }
                }
                else if (chkNoINet.IsChecked == true)
                {
                    return(false);
                }
            }

            if (FirewallPage.DoFilter(textFilter, item.name, new List <ProgramID>()
            {
                item.sock.ProgID
            }))
            {
                return(false);
            }
            return(true);
        }
Example #11
0
        public ProgramListControl()
        {
            InitializeComponent();

            ProgramList = new ControlList <ProgramControl, ProgramSet>(this.processScroll, (prog) => { return(new ProgramControl(prog, CatModel)); }, (prog) => prog.guid.ToString(),
                                                                       (list) => { list.Sort(DoSort); }, (item) => { return(CurFilter != null && FirewallPage.DoFilter(CurFilter, item.progSet)); });

            ProgramList.SelectionChanged += (s, e) => { SelectionChanged?.Invoke(this, e); };

            SuspendChange++;

            //this.rbbSort.Header = Translate.fmt("lbl_sort_and");
            this.lblSort.Content = Translate.fmt("lbl_sort");
            //this.chkNoLocal.Content = Translate.fmt("chk_ignore_local");
            //this.chkNoLan.Content = Translate.fmt("chk_ignore_lan");

            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_no"), Sorts.Unsorted);
            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_name"), Sorts.Name);
            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_rname"), Sorts.NameRev);
            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_act"), Sorts.LastActivity);
            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_rate"), Sorts.DataRate);
            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_socks"), Sorts.SocketCount);
            WpfFunc.CmbAdd(cmbSort, Translate.fmt("sort_count"), Sorts.ModuleCount);
            WpfFunc.CmbSelect(cmbSort, ((Sorts)App.GetConfigInt("GUI", "SortList", 0)).ToString());

            this.chkNoLocal.IsChecked = App.GetConfigInt("GUI", "ActNoLocal", 0) == 1;
            this.chkNoLan.IsChecked   = App.GetConfigInt("GUI", "ActNoLan", 0) == 1;

            SuspendChange--;
        }