Ejemplo n.º 1
0
        public override void GetVersion()
        {
            Program.LogThis(new Log(Log.ModuleType.FingingerPrinting, "SMTP Fingerprinting on " + base.Host + ":" + base.Port, Log.LogType.debug));

            try
            {
                base.tcp.SendTimeout    = 2000;
                base.tcp.ReceiveTimeout = 2000;

                if (!base.TcpConnect())
                {
                    throw new Exception();
                }

                ns = base.TcpStream();
                if (ns == null)
                {
                    return;
                }
            }
            catch (Exception)
            {
                if (FingerPrintingError != null)
                {
                    FingerPrintingError(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, "SMTP server found on " + base.Host + ":" + base.Port, Log.LogType.medium));
            }
            catch
            {
                Version = "(Error)";
            }
            finally
            {
                base.TcpDisconnect();
            }

            AnalyzePosibleOS();
            FingerPrintingFinished?.Invoke(this, null);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
        }