public void BuildMarkedList(string text, char mark, byte shift) { MarkedList ml = new MarkedList(text, mark, shift); Result.AddSection(ml); }
/// <summary> /// Determines the result of a Simian sensation. /// Problems with sensors are not generally logged /// since they are frequently called and most are not /// fatal. /// </summary> /// <param name="sensorRef">A sensor expression in a rule.</param> /// <returns>true if the sensor detected its target.</returns> public bool sensation(EmptyElement sensorRef) { if (sensorRef.getName().Equals("window")) { // is the window showing? string id = sensorRef.getValue("id"); // a VarNode string title = sensorRef.getValue("title"); MarkedNode mn = null; if (Utilities.isGoodStr(id) && Utilities.isGoodStr(title)) { // fetch the title from the model node via id + title mn = m_varNodes.get(id); // bail out if id not defined yet. if (mn == null) { return(false); } if (mn.node != null) { title = m_GuiModel.selectToString(mn.node, title, "title"); } if (!Utilities.isGoodStr(title)) { return(false); } } else if (id == null && title == null) { // get the main window title from the model title = m_Config.getDataBase() + m_GuiModel.getTitle(); } if (title == null) { return(false); // model lacks title } if (Utilities.isGoodStr(title)) { IntPtr winHand = FindWindow(null, title); if ((int)winHand != 0) { AccessibilityHelper ah = new AccessibilityHelper(winHand); // look for a titlebar GuiPath gPath = new GuiPath("1:NAMELESS"); AccessibilityHelper tah = ah.SearchPath(gPath, this); if (tah == null || !tah.Value.Equals(title)) { return(false); } m_ah = ah; return(true); } } } if (sensorRef.getName().Equals("tested")) { string id = sensorRef.getValue("id"); // which controls string control = sensorRef.getValue("control"); // which controls string count = sensorRef.getValue("count"); // indicates how many if (control != null && count == null) { return(false); } if (control == null && count != null) { return(false); } if (control == null && count == null && id == null) { return(false); } if (id != null) { MarkedNode mn = m_varNodes.get(id); if (mn != null) { if (mn.mark == null) { return(false); } return(mn.mark.Equals("tested")); } } // if id fails to return a marked node, try a control count if (control != null) { int n = 0; int k = 0; if (control.Equals("view")) { if (m_views == null) { m_views = new MarkedList(m_GuiModel, "//*[@role='view']"); } n = m_views.Count(); k = m_views.Count("tested"); } if (count.Equals("all") && n == k) { return(true); } if (count.Equals("not-all") && k < n) { return(true); } return(false); } return(false); } if (sensorRef.getName().Equals("glimpse")) { string id = sensorRef.getValue("id"); // a VarNode string appPath = sensorRef.getValue("on"); // an appPath string guiPath = sensorRef.getValue("at"); // a giuPath string property = sensorRef.getValue("prop"); // an ah property string expect = sensorRef.getValue("expect"); // value expected // Id provides a context ah that must be used to find the rest of the path! // can't just use the appPath from it. What if it's a dialog? XmlNode context = null; MarkedNode mn = null; if (Utilities.isGoodStr(id)) { mn = m_varNodes.get(id); // bail out if id not defined yet. if (mn == null) { return(false); } if (mn.node != null) { context = mn.node; } } return(glimpse(context, appPath, guiPath, property, expect)); } return(false); }
/// <summary> /// Determines the result of a Simian sensation. /// Problems with sensors are not generally logged /// since they are frequently called and most are not /// fatal. /// </summary> /// <param name="sensorRef">A sensor expression in a rule.</param> /// <returns>true if the sensor detected its target.</returns> public bool sensation(EmptyElement sensorRef) { if (sensorRef.getName().Equals("window")) { // is the window showing? string id = sensorRef.getValue("id"); // a VarNode string title = sensorRef.getValue("title"); MarkedNode mn = null; if (Utilities.isGoodStr(id) && Utilities.isGoodStr(title)) { // fetch the title from the model node via id + title mn = m_varNodes.get(id); // bail out if id not defined yet. if (mn == null) return false; if (mn.node != null) title = m_GuiModel.selectToString(mn.node, title, "title"); if (!Utilities.isGoodStr(title)) return false; } else if (id == null && title == null) { // get the main window title from the model title = m_Config.getDataBase()+m_GuiModel.getTitle(); } if (title == null) return false; // model lacks title if (Utilities.isGoodStr(title)) { IntPtr winHand = FindWindow(null, title); if ((int)winHand != 0) { AccessibilityHelper ah = new AccessibilityHelper(winHand); // look for a titlebar GuiPath gPath = new GuiPath("1:NAMELESS"); AccessibilityHelper tah = ah.SearchPath(gPath, this); if (tah == null || !tah.Value.Equals(title)) return false; m_ah = ah; return true; } } } if (sensorRef.getName().Equals("tested")) { string id = sensorRef.getValue("id"); // which controls string control = sensorRef.getValue("control"); // which controls string count = sensorRef.getValue("count"); // indicates how many if (control != null && count == null) return false; if (control == null && count != null) return false; if (control == null && count == null && id == null) return false; if (id != null) { MarkedNode mn = m_varNodes.get(id); if (mn != null) { if (mn.mark == null) return false; return mn.mark.Equals("tested"); } } // if id fails to return a marked node, try a control count if (control != null) { int n = 0; int k = 0; if (control.Equals("view")) { if (m_views == null) m_views = new MarkedList(m_GuiModel, "//*[@role='view']"); n = m_views.Count(); k = m_views.Count("tested"); } if (count.Equals("all") && n == k) return true; if (count.Equals("not-all") && k < n) return true; return false; } return false; } if (sensorRef.getName().Equals("glimpse")) { string id = sensorRef.getValue("id"); // a VarNode string appPath = sensorRef.getValue("on"); // an appPath string guiPath = sensorRef.getValue("at"); // a giuPath string property = sensorRef.getValue("prop"); // an ah property string expect = sensorRef.getValue("expect"); // value expected // Id provides a context ah that must be used to find the rest of the path! // can't just use the appPath from it. What if it's a dialog? XmlNode context = null; MarkedNode mn = null; if (Utilities.isGoodStr(id)) { mn = m_varNodes.get(id); // bail out if id not defined yet. if (mn == null) return false; if (mn.node != null) context = mn.node; } return glimpse(context, appPath, guiPath, property, expect); } return false; }
private async Task LoadMarkedTask(string uri) { MarkedList.Clear(); int o = 0; while (true) { string reqUri = uri + o; string responseString = await SendRequest.GET(reqUri); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(responseString); HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(@"//form[@name='frm_mis']/tr"); int count = 0; Regex regex = new Regex(@"# \d+"); for (int i = 0; i < nodes.Count; i++) { if (i == 0 || i == nodes.Count - 1) { continue; } string complete = nodes[i].SelectSingleNode(@"./td[1]/table/tr[@class='m2']//a").GetAttributeValue("href", ""); string mark = ""; // nodes[i].SelectSingleNode(@"./td[1]/table/tr[2]//a").GetAttributeValue("href", ""); string targetIP = nodes[i].SelectSingleNode(@"./td[2]/table/tr[1]//a/span[@class='green']").InnerText; string type = nodes[i].SelectSingleNode(@"./td[3]/a/span").InnerText; string detail = StringHelper.RemoveSpecial(nodes[i].SelectSingleNode(@"./td[4]//td[@align='justify']").InnerText); string reward = nodes[i].SelectSingleNode(@"./td[5]").InnerText; string fileID = ""; var match = regex.Match(detail); if (match.Success) { fileID = match.Value.Replace("#", "").Trim(); } MissionModel newData = new MissionModel() { Complete = complete, Mark = mark, TargetIP = targetIP, Type = type, Details = detail, Reward = reward, FileID = fileID }; MarkedList.Add(newData); count++; } if (count == 0) { break; } o += 50; } }