private void AnalyzeCertificate() { try { var request = (HttpWebRequest)WebRequest.Create("https://" + Host + ":" + "443" + "/"); request.KeepAlive = false; request.AllowAutoRedirect = false; request.Timeout = 5 * 1000; // 5 seconds Program.LogThis(new Log(Log.ModuleType.FingingerPrinting, "HTTP Fingerprinting on " + "https://" + Host + ":" + "443", Log.LogType.debug)); request.GetResponse(); if (string.IsNullOrEmpty(aux_certName)) { return; } if (Program.data.GetDomain(aux_certName) == null) { Program.data.AddDomain(aux_certName, "Certificate FingerPrinting", 1, Program.cfgCurrent); } } catch (WebException) { } catch (Exception) { FingerPrintingError?.Invoke(this, null); } }
public override void GetVersion() { try { base.tcp.SendTimeout = 2000; base.tcp.ReceiveTimeout = 2000; if (!base.TcpConnect()) { throw new Exception(); } System.Threading.Thread.Sleep(5000); // Algunos servidores ftp tardan unos segundos en mostrar el banner ns = base.TcpStream(); if (ns == null) { return; } } catch (Exception) { FingerPrintingError?.Invoke(this, null); return; } StringBuilder sb = new StringBuilder(); int size = 1024; buffer = new byte[size]; int bytesLeidos = 0; bool endOfStream = false; try { while (bytesLeidos >= 0 && (endOfStream == false)) { bytesLeidos = ns.Read(buffer, 0, size); sb.Append(ASCIIEncoding.ASCII.GetString(buffer, 0, bytesLeidos)); endOfStream = !ns.DataAvailable; } Version = sb.ToString(); Program.LogThis(new Log(Log.ModuleType.FingingerPrinting, "FTP server found on " + base.Host + ":" + base.Port, Log.LogType.medium)); } catch { Version = "(Error)"; } finally { base.TcpDisconnect(); FingerPrintingFinished?.Invoke(this, null); } }
private void AnalyzeCertificate() { try { HttpWebRequest request = HttpWebRequest.CreateHttp("https://" + Host + ":" + "443" + "/"); request.KeepAlive = false; request.AllowAutoRedirect = false; request.Timeout = 5 * 1000; // 5 seconds request.ServerCertificateValidationCallback += ExtractServerCertificateInformation; Program.LogThis(new Log(Log.ModuleType.FingingerPrinting, "HTTP Fingerprinting on " + "https://" + Host + ":" + "443", Log.LogType.debug)); var response = request.GetResponse(); response.Dispose(); } catch (WebException) { } catch (Exception) { FingerPrintingError?.Invoke(this, null); } }
public override void GetVersion() { var httpProtocol = ssl ? "https://" : "http://"; WebResponse response; try { var request = (HttpWebRequest)WebRequest.Create(httpProtocol + Host + ":" + Port + "/"); request.KeepAlive = false; request.AllowAutoRedirect = false; request.Timeout = 3 * 1000; // 3 seconds response = request.GetResponse(); Program.LogThis(new Log(Log.ModuleType.FingingerPrinting, "HTTP Fingerprinting on " + httpProtocol + Host + ":" + Port, Log.LogType.debug)); var rs = response.GetResponseStream(); if (rs == null) { return; } var sr = new StreamReader(rs); var respuesta = sr.ReadToEnd(); var m = Regex.Match(respuesta, @"<Title>\s*(.+?)\s*</Title>", RegexOptions.IgnoreCase); if (m.Success) { if (m.Value.Length < 200) { Title = m.Value; } } } catch (WebException ex) { // it may occur if you use SSL to connect to a port that doesn't support it if (ex.Response == null) { return; } response = ex.Response; } catch (Exception) { FingerPrintingError?.Invoke(this, null); return; } Version = response.Headers["Server"] ?? "(Unavaliable)"; response.Close(); // try to guess the OS (sometimes the banner leaks that information) AnalyzeBanner(Version); // tests using HTTP Errors if (os == OperatingSystem.OS.Unknown) { AnalyzeErrors404(); AnalyzeErrors403(); AnalyzeAspx(); } AnalyzeRobots(); AnalyzeCertificate(); FingerPrintingFinished?.Invoke(this, null); }