Beispiel #1
0
        private void UnpackContent()
        {
            /*
             * // set checked state
             *          m_fChecked = m_oDefinition.m_fCheckable && oContentFldListForBlock.getNumFieldOfType(CFieldList.c_nINT, CNaviAgent.c_fieldidIsChecked) > 0;
             */

            // parse server display data
            serverDisplayData = DisplayData.Parse(Content);

            Core.UI.ReferencedContent.Add(serverDisplayData);
            ParentNode.Register(serverDisplayData);

            // check if this block should have initial focus
            bool initialFocus = Content[NaviAgentFieldID.IsFocused].AsBoolean() ?? false;

            // set default state
            if (CanFocus && initialFocus)
            {
                SwitchToState(BlockState.Focused);
            }
            else
            {
                SwitchToState(BlockState.Normal);
            }
        }
Beispiel #2
0
        public NativeMessageBoxBodyBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Title   = String.Empty;
            Message = String.Empty;

            if ((Data != null) && (Data.SlotHints != null))
            {
                // parse server display data
                serverDisplayData = DisplayData.Parse(content);

                // extract title and message
                if ((serverDisplayData.Count > 0) && (Data.SlotHints.Length > 0))
                {
                    ProcessHintDataPair(Data.SlotHints[0], serverDisplayData[0]);
                }

                if ((serverDisplayData.Count > 1) && (Data.SlotHints.Length > 1))
                {
                    ProcessHintDataPair(Data.SlotHints[1], serverDisplayData[1]);
                }
            }

            if (Title == String.Empty)
            {
                Title = Core.ApplicationName;
            }

            if (Message == String.Empty)
            {
                Message = DefaultMessage;
            }
        }
        public NativeMessageBoxButtonBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Caption = String.Empty;

            // parse server display data
            serverDisplayData = DisplayData.Parse(content);

            // extract button caption
            if ((serverDisplayData.Count > 0) && (serverDisplayData[0].DisplayType == DisplayType.String))
            {
                Caption = (string)serverDisplayData[0].Data;
            }
        }
Beispiel #4
0
        public ApplicationBarButtonBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Text = String.Empty;
            Icon = null;

            // parse server display data
            serverDisplayData = DisplayData.Parse(content);

            // extract text and icon
            if ((serverDisplayData.Count > 0) && (Data.SlotHints.Length > 0))
            {
                ProcessHintDataPair(Data.SlotHints[0], serverDisplayData[0]);
            }

            if ((serverDisplayData.Count > 1) && (Data.SlotHints.Length > 1))
            {
                ProcessHintDataPair(Data.SlotHints[1], serverDisplayData[1]);
            }
        }
        public ApplicationBarMenuItemBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Text = String.Empty;

            // parse server display data
            serverDisplayData = DisplayData.Parse(content);

            // extract text
            if ((serverDisplayData.Count > 0) && (Data.SlotHints.Length > 0) &&
                !String.IsNullOrEmpty(Data.SlotHints[0]) && (serverDisplayData[0] != null) &&
                (serverDisplayData[0].DisplayType == DisplayType.String))
            {
                HintsDictionary hints = new HintsDictionary();
                hints.Parse(Data.SlotHints[0]);

                if (hints.ValueEquals(HintsDictionary.OfType, RenderingHint.ApplicationBarMenuItemText))
                {
                    Text = (string)serverDisplayData[0].Data;
                }
            }
        }
Beispiel #6
0
        public TabBarButtonBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Text = String.Empty;
            Icon = null;

            // parse server display data
            serverDisplayData = DisplayData.Parse(content);

            // extract text and icon
            AtomicBlockDefinition data = Definition as AtomicBlockDefinition;

            if (data != null)
            {
                for (int i = 0; i < serverDisplayData.Count; i++)
                {
                    if (data.SlotHints.Length > i)
                    {
                        ProcessHintDataPair(data.SlotHints[i], serverDisplayData[i]);
                    }
                }
            }
        }
        public BlockingCollection <string> ReadFilesWriteToFile(string folder, string fileNameWC, string toFile)
        {
            var matchesCollection = new BlockingCollection <string>();

            var files = Directory.GetFiles(folder, fileNameWC,
                                           SearchOption.TopDirectoryOnly);

            Console.WriteLine("Reading Folder: " + folder);
            var exceptions = new ValueTuple <string, Regex>[]
            {
                ("change password", new Regex("CMD: echo \"root")),
                ("change password", new Regex("CMD: echo -e \"")),
                ("change password", new Regex(@"\|passwd")),
                ("change password", new Regex(" > /tmp/up.txt"))
            };
            var readTask = Task.Run(() =>
            {
                using (var writer = new StreamWriter(toFile))
                {
                    //List<string> cmds = new List<string>();
                    List <DisplayData> cmds = new List <DisplayData>();
                    try
                    {
                        foreach (var file in files)
                        {
                            string line2 = "";
                            try
                            {
                                using (var reader = new StreamReader(file))
                                {
                                    string line;

                                    while ((line = reader.ReadLine()) != null)
                                    {
                                        line2           = line;
                                        EventDTO _event = null;

                                        try
                                        {
                                            _event = JsonConvert.DeserializeObject <EventDTO>(line);
                                        }
                                        catch (Exception)
                                        {
                                            continue;
                                        }
                                        if (_event.eventid != "cowrie.session.file_upload")
                                        {
                                            continue;
                                        }

                                        foreach (var item in dls)
                                        {
                                            if (item.Value.ips == null)
                                            {
                                                continue;
                                            }
                                            foreach (var ii in item.Value.ips)
                                            {
                                                if (ii.sha2 == _event.shasum)
                                                {
                                                    ii.ip   = _event.src_ip;
                                                    ii.date = DateTime.Parse(_event.timestamp);
                                                }
                                            }
                                        }

                                        foreach (var item in dls)
                                        {
                                            if (item.Value.ips == null)
                                            {
                                                continue;
                                            }
                                            foreach (var ii in item.Value.ips)
                                            {
                                                if (ii.sha2 == _event.shasum)
                                                {
                                                    var ad = new AllData()
                                                    {
                                                        df = item.Value, ed = _event
                                                    };
                                                    cmds.Add(DisplayData.Parse(ad));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (DirectoryNotFoundException e)
                            {
                                Console.WriteLine(e.StackTrace);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(line2);
                                Console.WriteLine(e.StackTrace);
                            }
                        }
                    }

                    finally
                    {
                        matchesCollection.CompleteAdding();
                    }

                    writer.WriteLine(JsonConvert.SerializeObject(cmds, Formatting.Indented));
                }
            });

            Task.WaitAll(readTask);

            return(matchesCollection);
        }
Beispiel #8
0
        private void UnpackContent()
        {
            if (Content != null)
            {
                /*
                 * m_acSpotID = (char[]) oContentFldListForBlock.getNextFldData(CFieldList.c_nSTR, CNaviAgent.c_fieldidProxyValue, null);
                 * m_fPersistentBlockProxy = oContentFldListForBlock.getNumFieldOfType(CFieldList.c_nINT, CNaviAgent.c_fieldidProxyPersistence) > 0?true:false;
                 * m_nMaxBlocksToStoreInCache = oContentFldListForBlock.getIntFldData(CNaviAgent.c_fieldidProxyHistory);
                 */

                // find palette reference
                int paletteID = Content[NaviAgentFieldID.PaletteID].AsInteger() ?? 0;

                if (paletteID > 0)
                {
                    Palette = Core.Definitions.Find(ParentNode.ApplicationID, paletteID) as PaletteDefinition;
                }

                // unpack actionsets
                ActionSets.Load(Content, NaviAgentFieldID.ActionSet);

                // should we subscribe for back key notifications?
                subscribeAsBackKeyListener = (ActionSets[Anchor.Back] != null);

                /*
                 * bool fIsTopEvent = (oContentFldListForBlock.getIntFldData(CNaviAgent.c_fieldidIsTopEvent) == 1);
                 * if (fIsTopEvent)
                 * {
                 *  CNaviAgent.c_this.m_oBlockMgr.TopEventListener = this;
                 * }
                 */

                // form details
                FormID              = Content[NaviAgentFieldID.FormID].AsShort() ?? -1;
                FormSubmissionKey   = Content[NaviAgentFieldID.SubmissionKey].AsString();
                FormSubmissionValue = Content[NaviAgentFieldID.SubmissionValue].AsString();

                if (FormSubmissionKey != null)
                {
                    /*
                     * // allow block manager (bonded) to modify the value.
                     * m_acSubmissionValue = CNaviAgent.c_this.m_oBlockMgr.checkModifySubmissionValue(m_acSubmissionKey, m_acSubmissionValue);
                     */
                }

                if ((FormSubmissionValue != null) && FormSubmissionValue.StartsWith(Hint))
                {
                    FormSubmissionHint  = FormSubmissionValue.Substring(Hint.Length, FormSubmissionValue.Length - Hint.Length);
                    FormSubmissionValue = null;
                }

                // unpacking block signpost
                Signpost = Content[NaviAgentFieldID.Signpost].AsShort() ?? FieldList.FieldNotFound;

                if ((ParentNode != null) && (Signpost != FieldList.FieldNotFound))
                {
                    ParentNode.RegisterBlockSignpost(this);
                }

                // unpacking background image
                FieldList bgData = Content[NaviAgentFieldID.BackgroundImage] as FieldList;

                if (bgData != null)
                {
                    DisplayDataCollection ddc = DisplayData.Parse(bgData);

                    if ((ddc != null) && (ddc.Count > 0))
                    {
                        BlockBackground = new ImageBackground(ddc[0]);
                        Core.UI.ReferencedContent.Add(ddc[0]);

                        Children.Add(BlockBackground);
                    }
                }
            }
        }
Beispiel #9
0
        public ScrollingTextBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Caption = String.Empty;

            // parse content
            if (Content != null)
            {
                DisplayDataCollection ddc = DisplayData.Parse(Content);

                if ((ddc != null) && (ddc.Count > 0) && (ddc[0].DisplayType == DisplayType.String))
                {
                    Caption = (string)ddc[0].Data;
                }
            }

            // creating controls
            panel             = new StackPanel();
            panel.Orientation = Orientation.Vertical;

            wrapper         = new ScrollViewer();
            wrapper.Content = panel;

            // apply definition
            Brush          fg = null;
            FontDefinition fd = null;

            if (Data != null)
            {
                // background
                if (Data.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(Data.Background.Value);

                    if (bgRes.Brush != null)
                    {
                        Background = bgRes.Brush;
                    }
                }

                // foreground
                if (Data.Foreground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(Data.Foreground.Value);

                    fg = fgRes.Brush;
                }

                // apply font
                if (Data.Font.HasValue && (Data.Font.Value != -1))
                {
                    FontReferencePaletteEntry fr = FindCascadedPaletteItem(Data.Font.Value) as FontReferencePaletteEntry;

                    if (fr != null)
                    {
                        fd = fr.Resolve(ParentNode.ApplicationID);
                    }
                }

                // padding for text
                panel.Margin = new Thickness(DefaultPadding);
            }

            // apply text
            string[] parts = Caption.Split('\n');

            foreach (string part in parts)
            {
                TextBlock paragraph = new TextBlock();

                if (fg != null)
                {
                    paragraph.Foreground = fg;
                }

                if (fd != null)
                {
                    fd.Apply(paragraph);
                }

                paragraph.TextWrapping = TextWrapping.Wrap;

                if (!String.IsNullOrEmpty(part))
                {
                    paragraph.Text = part;
                }
                else
                {
                    paragraph.Text = " ";
                }

                panel.Children.Add(paragraph);
            }

            // display text
            Children.Add(wrapper);
        }