Esempio n. 1
0
        private StructuredEngineResult GoogleSoap()
        {
            //System.Diagnostics.Debug.WriteLine("Houston, We're running in the Google SOAP routine");
            StructuredEngineResult returnItem = new StructuredEngineResult();
            Collection <StructuredResultElement> returnResults = new Collection <StructuredResultElement>();

            com.google.api.GoogleSearchService the_service = new global::com.sensepost.SPUDHelperClasses.com.google.api.GoogleSearchService();
            com.google.api.GoogleSearchResult  the_result  = new global::com.sensepost.SPUDHelperClasses.com.google.api.GoogleSearchResult();
            com.google.api.ResultElement       the_element = new global::com.sensepost.SPUDHelperClasses.com.google.api.ResultElement();
            try
            {
                the_result = the_service.doGoogleSearch(this.g_key, this.g_query, this.g_start, this.g_length, false, "", false, "", "latin1", "latin1");
            }
            catch (Exception ex)
            {
                StructuredResultElement str_res = new StructuredResultElement("Google", "", "", "", "", "", "ERROR:" + ex.Message.ToString());
                returnResults.Add(str_res);
                returnItem.ResultSource = "Google";
                returnItem.ResultTotal  = 0;
                returnItem.ResultItems  = returnResults;
                return(returnItem);
            }
            returnItem.ResultSource = "Google";
            returnItem.ResultTotal  = the_result.estimatedTotalResultsCount;
            for (int i = 0; i < the_result.resultElements.Length; i++)
            {
                the_element = the_result.resultElements[i];
                StructuredResultElement str_res = new StructuredResultElement("Google", the_element.URL.ToString(), the_element.cachedSize.ToString(), the_element.snippet.ToString(), the_element.summary.ToString(), the_element.title.ToString(), "SUCCESS");
                returnResults.Add(str_res);
            }
            returnItem.ResultItems = returnResults;
            return(returnItem);
        }
Esempio n. 2
0
        private StructuredEngineResult GoogleSearch()
        {
            //System.Diagnostics.Debug.WriteLine("Houston, We're running in the Google Search Routine");
            StructuredEngineResult return_item = new StructuredEngineResult();
            String GoogleHtml = this.GetGooglePage();

            if (GoogleHtml.StartsWith("ERROR:"))
            {
                StructuredResultElement sre = new StructuredResultElement("Google", "", "", "", "", "", GoogleHtml);
                return_item.ResultItems.Add(sre);
            }
            else
            {
                str_reshdr outres = GetGoogleItems(GoogleHtml);
                return_item.ResultSource = "Google";
                return_item.ResultTotal  = outres.n_total;
                foreach (str_resitm the_itm in outres.res_itm)
                {
                    StructuredResultElement sre = new StructuredResultElement("Google", the_itm.sz_url, the_itm.sz_cache, the_itm.sz_snip, the_itm.sz_snip, the_itm.sz_title, "SUCCESS");
                    return_item.ResultItems.Add(sre);
                }
            }
            return(return_item);
        }
Esempio n. 3
0
 private StructuredEngineResult GoogleSoap()
 {
     //System.Diagnostics.Debug.WriteLine("Houston, We're running in the Google SOAP routine");
     StructuredEngineResult returnItem = new StructuredEngineResult();
     Collection<StructuredResultElement> returnResults = new Collection<StructuredResultElement>();
     com.google.api.GoogleSearchService the_service = new global::com.sensepost.SPUDHelperClasses.com.google.api.GoogleSearchService();
     com.google.api.GoogleSearchResult the_result = new global::com.sensepost.SPUDHelperClasses.com.google.api.GoogleSearchResult();
     com.google.api.ResultElement the_element = new global::com.sensepost.SPUDHelperClasses.com.google.api.ResultElement();
     try
     {
         the_result = the_service.doGoogleSearch(this.g_key, this.g_query, this.g_start, this.g_length, false, "", false, "", "latin1", "latin1");
     }
     catch (Exception ex)
     {
         StructuredResultElement str_res = new StructuredResultElement("Google", "", "", "", "", "", "ERROR:" + ex.Message.ToString());
         returnResults.Add(str_res);
         returnItem.ResultSource = "Google";
         returnItem.ResultTotal = 0;
         returnItem.ResultItems = returnResults;
         return returnItem;
     }
     returnItem.ResultSource = "Google";
     returnItem.ResultTotal = the_result.estimatedTotalResultsCount;
     for (int i = 0; i < the_result.resultElements.Length; i++)
     {
         the_element = the_result.resultElements[i];
         StructuredResultElement str_res = new StructuredResultElement("Google", the_element.URL.ToString(), the_element.cachedSize.ToString(), the_element.snippet.ToString(), the_element.summary.ToString(), the_element.title.ToString(), "SUCCESS");
         returnResults.Add(str_res);
     }
     returnItem.ResultItems = returnResults;
     return returnItem;
 }
Esempio n. 4
0
 private StructuredEngineResult GoogleSearch()
 {
     //System.Diagnostics.Debug.WriteLine("Houston, We're running in the Google Search Routine");
     StructuredEngineResult return_item = new StructuredEngineResult();
     String GoogleHtml = this.GetGooglePage();
     if (GoogleHtml.StartsWith("ERROR:"))
     {
         StructuredResultElement sre = new StructuredResultElement("Google", "", "", "", "", "", GoogleHtml);
         return_item.ResultItems.Add(sre);
     }
     else
     {
         str_reshdr outres = GetGoogleItems(GoogleHtml);
         return_item.ResultSource = "Google";
         return_item.ResultTotal = outres.n_total;
         foreach (str_resitm the_itm in outres.res_itm)
         {
             StructuredResultElement sre = new StructuredResultElement("Google", the_itm.sz_url, the_itm.sz_cache, the_itm.sz_snip, the_itm.sz_snip, the_itm.sz_title, "SUCCESS");
             return_item.ResultItems.Add(sre);
         }
     }
     return return_item;
 }
Esempio n. 5
0
        //public ArrayList GetResults()
        public StructuredEngineResult GetResults()
        {
            int Totals = 0;
            StructuredEngineResult returnItem = new StructuredEngineResult();
            Collection<StructuredResultElement> returnResults = new Collection<StructuredResultElement>();
            //ArrayList al_returner = new ArrayList();
            com.msn.search.soap.MSNSearchService the_service = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.MSNSearchService();
            com.msn.search.soap.SourceRequest[] the_sourcerequest = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.SourceRequest[1];
            com.msn.search.soap.SearchRequest the_searchrequest = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.SearchRequest();
            com.msn.search.soap.SearchResponse the_response;

            the_sourcerequest[0] = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.SourceRequest();
            the_sourcerequest[0].Source = com.msn.search.soap.SourceType.Web;
            the_sourcerequest[0].ResultFields = global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.ResultFieldMask.All;

            the_searchrequest.AppID = this.g_key;
            the_searchrequest.Query = this.g_query;
            the_searchrequest.CultureInfo = "en-US";
            the_searchrequest.Requests = the_sourcerequest;

            try
            {
                the_response = the_service.Search(the_searchrequest);
                foreach (com.msn.search.soap.SourceResponse src_resp in the_response.Responses)
                {
                    com.msn.search.soap.Result[] the_result = src_resp.Results;
                    foreach (com.msn.search.soap.Result fin_res in the_result)
                    {
                        String res_url = "";
                        String res_sum = "";
                        String res_tit = "";

                        try
                        {
                            res_url = fin_res.Url.ToString();
                        }
                        catch
                        {
                            res_url = "";
                        }
                        try
                        {
                            res_sum = fin_res.Summary.ToString();
                        }
                        catch
                        {
                            res_sum = "";
                        }
                        try
                        {
                            res_tit = fin_res.Title.ToString();
                        }
                        catch
                        {
                            res_tit = "";
                        }

                        StructuredResultElement str_res = new StructuredResultElement("Live", res_url, "Unknown Cache Size", res_sum, res_sum, res_tit, "SUCCESS");
                        returnResults.Add(str_res);
                        Totals = src_resp.Total;
                    }
                    returnItem.ResultSource = "Live";
                    returnItem.ResultTotal = Totals;
                    returnItem.ResultItems = returnResults;
                }
            }
            catch (Exception ex)
            {
                StructuredResultElement str_res = new StructuredResultElement("Live", "", "", "", "", "", "ERROR:" + ex.Message.ToString());
                returnResults.Add(str_res);
                returnItem.ResultSource = "Live";
                returnItem.ResultTotal = 0;
                returnItem.ResultItems = returnResults;
                return returnItem;
            }
            return returnItem;
        }
Esempio n. 6
0
        public StructuredEngineResult GetResults()
        {
            int TotalResults = 0;
            StructuredEngineResult returnItem = new StructuredEngineResult();
            Collection<StructuredResultElement> returnResults = new Collection<StructuredResultElement>();
            int i = this.g_start + 1;

            Uri the_address = new Uri("http://search.yahooapis.com/WebSearchService/V1/webSearch");
            HttpWebRequest the_request = WebRequest.Create(the_address) as HttpWebRequest;
            the_request.Method = "POST";
            the_request.ContentType = "application/x-www-form-urlencoded";
            // We mangle the query somewhat here so that Google Hack queries return less false-positives...
            this.g_query = this.g_query.ToLower();
            this.g_query = this.g_query.Replace("filetype:", "inurl:.");
            this.g_query = this.g_query.Replace("intext:", "SENSEPOSTINTEXTPLACEHOLDER:");
            this.g_query = this.g_query.Replace("ext:", "inurl:.");
            this.g_query = this.g_query.Replace("SENSEPOSTINTEXTPLACEHOLDER:", "intext:");
            this.g_query = this.g_query.Replace("|", " OR ");
            this.g_query = this.g_query.Replace("intitle:index.of.", "intitle:\"index of \"");
            this.g_query = this.g_query.Replace("intitle:index.of", "intitle:\"index of\"");
            this.g_query = this.g_query.Replace("intitle:\"index.of.", "intitle:\"index of ");
            this.g_query = this.g_query.Replace("intitle:\"index.of", "intitle:\"index of");
            StringBuilder the_querydata = new StringBuilder();
            the_querydata.Append("appid=" + HttpUtility.UrlEncode(this.g_key));
            the_querydata.Append("&start=" + HttpUtility.UrlEncode(i.ToString()));
            the_querydata.Append("&query=" + HttpUtility.UrlEncode(this.g_query));
            the_querydata.Append("&results=" + HttpUtility.UrlEncode(this.g_length.ToString()));
            byte[] the_datatosend = UTF8Encoding.UTF8.GetBytes(the_querydata.ToString());
            the_request.ContentLength = the_datatosend.Length;
            using (Stream strm_post = the_request.GetRequestStream())
            {
                strm_post.Write(the_datatosend, 0, the_datatosend.Length);
            }
            String the_xmlstring = "";
            try
            {
                using (HttpWebResponse the_response = the_request.GetResponse() as HttpWebResponse)
                {
                    StreamReader strm_response = new StreamReader(the_response.GetResponseStream());
                    the_xmlstring = strm_response.ReadToEnd().ToString();
                }
                XmlDocument the_xmldoc = new XmlDocument();
                the_xmldoc.LoadXml(the_xmlstring);
                XmlNodeList the_masterlist = the_xmldoc.DocumentElement.ChildNodes;

                String sz_resultstr = "";
                String sz_resultend = "";
                String sz_resulttot = "";

                sz_resultstr = the_xmldoc.DocumentElement.GetAttribute("firstResultPosition").ToString();
                sz_resultend = the_xmldoc.DocumentElement.GetAttribute("totalResultsReturned").ToString();
                sz_resulttot = the_xmldoc.DocumentElement.GetAttribute("totalResultsAvailable").ToString();
                TotalResults = System.Convert.ToInt32(sz_resulttot);

                foreach (XmlNode master_node in the_masterlist)
                {
                    String res_title = "";
                    String res_summary = "";
                    String res_url = "";
                    String res_cache = "";
                    foreach (XmlNode child1_node in master_node.ChildNodes)
                    {
                        if (child1_node.Name.ToString().ToLower() == "title") res_title = child1_node.InnerText.ToString();
                        if (child1_node.Name.ToString().ToLower() == "summary") res_summary = child1_node.InnerText.ToString();
                        if (child1_node.Name.ToString().ToLower() == "url") res_url = child1_node.InnerText.ToString();
                        if (child1_node.Name.ToString().ToLower() == "cache")
                        {
                            foreach (XmlNode child2_node in child1_node.ChildNodes)
                            {
                                if (child2_node.Name.ToString().ToLower() == "size")
                                {
                                    res_cache = child2_node.InnerText.ToString();
                                    break;
                                }
                            }
                        }
                    }
                    if (res_title.Length > 0 || res_summary.Length > 0 || res_url.Length > 0)
                    {
                        StructuredResultElement the_resultelement = new StructuredResultElement("Yahoo", res_url, res_cache, res_summary, res_summary, res_title, "SUCCESS");
                        returnResults.Add(the_resultelement);
                    }
                }
                returnItem.ResultSource = "Yahoo";
                returnItem.ResultTotal = TotalResults;
                returnItem.ResultItems = returnResults;
            }
            catch (Exception ex)
            {
                StructuredResultElement the_resultelement = new StructuredResultElement("Yahoo", "", "", "", "", "", "ERROR:" + ex.Message.ToString());
                returnResults.Add(the_resultelement);
                returnItem.ResultSource = "Yahoo";
                returnItem.ResultTotal = 0;
                returnItem.ResultItems = returnResults;
            }
            return returnItem;
        }
Esempio n. 7
0
        public StructuredEngineResult GetResults()
        //public ArrayList GetResults()
        {
            int Totals = 0;
            StructuredEngineResult returnItem = new StructuredEngineResult();
            Collection <StructuredResultElement> returnResults = new Collection <StructuredResultElement>();

            //ArrayList al_returner = new ArrayList();
            com.msn.search.soap.MSNSearchService the_service       = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.MSNSearchService();
            com.msn.search.soap.SourceRequest[]  the_sourcerequest = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.SourceRequest[1];
            com.msn.search.soap.SearchRequest    the_searchrequest = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.SearchRequest();
            com.msn.search.soap.SearchResponse   the_response;

            the_sourcerequest[0]              = new global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.SourceRequest();
            the_sourcerequest[0].Source       = com.msn.search.soap.SourceType.Web;
            the_sourcerequest[0].ResultFields = global::com.sensepost.SPUDHelperClasses.com.msn.search.soap.ResultFieldMask.All;

            the_searchrequest.AppID       = this.g_key;
            the_searchrequest.Query       = this.g_query;
            the_searchrequest.CultureInfo = "en-US";
            the_searchrequest.Requests    = the_sourcerequest;

            try
            {
                the_response = the_service.Search(the_searchrequest);
                foreach (com.msn.search.soap.SourceResponse src_resp in the_response.Responses)
                {
                    com.msn.search.soap.Result[] the_result = src_resp.Results;
                    foreach (com.msn.search.soap.Result fin_res in the_result)
                    {
                        String res_url = "";
                        String res_sum = "";
                        String res_tit = "";

                        try
                        {
                            res_url = fin_res.Url.ToString();
                        }
                        catch
                        {
                            res_url = "";
                        }
                        try
                        {
                            res_sum = fin_res.Summary.ToString();
                        }
                        catch
                        {
                            res_sum = "";
                        }
                        try
                        {
                            res_tit = fin_res.Title.ToString();
                        }
                        catch
                        {
                            res_tit = "";
                        }


                        StructuredResultElement str_res = new StructuredResultElement("Live", res_url, "Unknown Cache Size", res_sum, res_sum, res_tit, "SUCCESS");
                        returnResults.Add(str_res);
                        Totals = src_resp.Total;
                    }
                    returnItem.ResultSource = "Live";
                    returnItem.ResultTotal  = Totals;
                    returnItem.ResultItems  = returnResults;
                }
            }
            catch (Exception ex)
            {
                StructuredResultElement str_res = new StructuredResultElement("Live", "", "", "", "", "", "ERROR:" + ex.Message.ToString());
                returnResults.Add(str_res);
                returnItem.ResultSource = "Live";
                returnItem.ResultTotal  = 0;
                returnItem.ResultItems  = returnResults;
                return(returnItem);
            }
            return(returnItem);
        }
Esempio n. 8
0
        public StructuredEngineResult GetResults()
        {
            int TotalResults = 0;
            StructuredEngineResult returnItem = new StructuredEngineResult();
            Collection <StructuredResultElement> returnResults = new Collection <StructuredResultElement>();
            int i = this.g_start + 1;

            Uri            the_address = new Uri("http://search.yahooapis.com/WebSearchService/V1/webSearch");
            HttpWebRequest the_request = WebRequest.Create(the_address) as HttpWebRequest;

            the_request.Method      = "POST";
            the_request.ContentType = "application/x-www-form-urlencoded";
            // We mangle the query somewhat here so that Google Hack queries return less false-positives...
            this.g_query = this.g_query.ToLower();
            this.g_query = this.g_query.Replace("filetype:", "inurl:.");
            this.g_query = this.g_query.Replace("intext:", "SENSEPOSTINTEXTPLACEHOLDER:");
            this.g_query = this.g_query.Replace("ext:", "inurl:.");
            this.g_query = this.g_query.Replace("SENSEPOSTINTEXTPLACEHOLDER:", "intext:");
            this.g_query = this.g_query.Replace("|", " OR ");
            this.g_query = this.g_query.Replace("intitle:index.of.", "intitle:\"index of \"");
            this.g_query = this.g_query.Replace("intitle:index.of", "intitle:\"index of\"");
            this.g_query = this.g_query.Replace("intitle:\"index.of.", "intitle:\"index of ");
            this.g_query = this.g_query.Replace("intitle:\"index.of", "intitle:\"index of");
            StringBuilder the_querydata = new StringBuilder();

            the_querydata.Append("appid=" + HttpUtility.UrlEncode(this.g_key));
            the_querydata.Append("&start=" + HttpUtility.UrlEncode(i.ToString()));
            the_querydata.Append("&query=" + HttpUtility.UrlEncode(this.g_query));
            the_querydata.Append("&results=" + HttpUtility.UrlEncode(this.g_length.ToString()));
            byte[] the_datatosend = UTF8Encoding.UTF8.GetBytes(the_querydata.ToString());
            the_request.ContentLength = the_datatosend.Length;
            using (Stream strm_post = the_request.GetRequestStream())
            {
                strm_post.Write(the_datatosend, 0, the_datatosend.Length);
            }
            String the_xmlstring = "";

            try
            {
                using (HttpWebResponse the_response = the_request.GetResponse() as HttpWebResponse)
                {
                    StreamReader strm_response = new StreamReader(the_response.GetResponseStream());
                    the_xmlstring = strm_response.ReadToEnd().ToString();
                }
                XmlDocument the_xmldoc = new XmlDocument();
                the_xmldoc.LoadXml(the_xmlstring);
                XmlNodeList the_masterlist = the_xmldoc.DocumentElement.ChildNodes;

                String sz_resultstr = "";
                String sz_resultend = "";
                String sz_resulttot = "";

                sz_resultstr = the_xmldoc.DocumentElement.GetAttribute("firstResultPosition").ToString();
                sz_resultend = the_xmldoc.DocumentElement.GetAttribute("totalResultsReturned").ToString();
                sz_resulttot = the_xmldoc.DocumentElement.GetAttribute("totalResultsAvailable").ToString();
                TotalResults = System.Convert.ToInt32(sz_resulttot);

                foreach (XmlNode master_node in the_masterlist)
                {
                    String res_title   = "";
                    String res_summary = "";
                    String res_url     = "";
                    String res_cache   = "";
                    foreach (XmlNode child1_node in master_node.ChildNodes)
                    {
                        if (child1_node.Name.ToString().ToLower() == "title")
                        {
                            res_title = child1_node.InnerText.ToString();
                        }
                        if (child1_node.Name.ToString().ToLower() == "summary")
                        {
                            res_summary = child1_node.InnerText.ToString();
                        }
                        if (child1_node.Name.ToString().ToLower() == "url")
                        {
                            res_url = child1_node.InnerText.ToString();
                        }
                        if (child1_node.Name.ToString().ToLower() == "cache")
                        {
                            foreach (XmlNode child2_node in child1_node.ChildNodes)
                            {
                                if (child2_node.Name.ToString().ToLower() == "size")
                                {
                                    res_cache = child2_node.InnerText.ToString();
                                    break;
                                }
                            }
                        }
                    }
                    if (res_title.Length > 0 || res_summary.Length > 0 || res_url.Length > 0)
                    {
                        StructuredResultElement the_resultelement = new StructuredResultElement("Yahoo", res_url, res_cache, res_summary, res_summary, res_title, "SUCCESS");
                        returnResults.Add(the_resultelement);
                    }
                }
                returnItem.ResultSource = "Yahoo";
                returnItem.ResultTotal  = TotalResults;
                returnItem.ResultItems  = returnResults;
            }
            catch (Exception ex)
            {
                StructuredResultElement the_resultelement = new StructuredResultElement("Yahoo", "", "", "", "", "", "ERROR:" + ex.Message.ToString());
                returnResults.Add(the_resultelement);
                returnItem.ResultSource = "Yahoo";
                returnItem.ResultTotal  = 0;
                returnItem.ResultItems  = returnResults;
            }
            return(returnItem);
        }