Beispiel #1
0
        private static string Request(string sArtifact, bool bHash, Int16 iDays)
        {
            var    parseConfigs = Object_ThreatGRID_Configs.GetThreatGridConfigs("search-level");
            var    searchdate   = DateTime.Now.AddDays(iDays);
            string request;

            if (bHash)
            {
                request = parseConfigs.ApiBaseUrl + parseConfigs.ApiFuncCall + "?checksum=" + sArtifact + parseConfigs.ApiQueryString + searchdate + "&api_key=" + parseConfigs.ApiKey;
            }
            else
            {
                request = parseConfigs.ApiBaseUrl + parseConfigs.ApiFuncCall + "?ip=" + sArtifact + parseConfigs.ApiQueryString + searchdate.ToShortDateString() + "&api_key=" + parseConfigs.ApiKey;
            }
            return(request);
        }
Beispiel #2
0
        public static Object_ThreatGRID_Threat_ConfigClass.ThreatGRID_Threat_Info ThreatInfo(string sHash)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            var ThreatGRIDReturn = new Object_ThreatGRID_Threat_ConfigClass.ThreatGRID_Threat_Info();
            var parseConfigs     = Object_ThreatGRID_Configs.GetThreatGridConfigs("hash-threat-level");
            var request          = parseConfigs.ApiBaseUrl + parseConfigs.ApiFuncCall + sHash + "/threat?" + parseConfigs.ApiQueryString + "&api_key=" + parseConfigs.ApiKey;
            var alertRequest     = (HttpWebRequest)WebRequest.Create(request);

            alertRequest.Method = "GET";
            //alertRequest.Timeout = 120000;
            try
            {
                using (var ThreatGRIDResponse = alertRequest.GetResponse() as HttpWebResponse)
                {
                    if (ThreatGRIDResponse != null && ThreatGRIDResponse.StatusCode == HttpStatusCode.OK)
                    {
                        using (var respStream = ThreatGRIDResponse.GetResponseStream())
                        {
                            if (respStream == null)
                            {
                                return(null);
                            }
                            var ThreatGRIDReader = new StreamReader(respStream, Encoding.UTF8);
                            var stringreturn     = ThreatGRIDReader.ReadToEnd();
                            ThreatGRIDReturn = JsonConvert.DeserializeObject <Object_ThreatGRID_Threat_ConfigClass.ThreatGRID_Threat_Info>(stringreturn);
                            ThreatGRIDResponse.Close();
                            return(ThreatGRIDReturn);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Fido_EventHandler.SendEmail("Fido Error", "Fido Failed: {0} Exception caught in retrieving ThreatGRID threat information:" + e + "Query : " + request);
            }
            return(ThreatGRIDReturn);
        }