// MaverickHttpMap.exe — mapeia rotas locais do servico de stream. // Testa 127.255.255.254:80 (GfnSdkService) e 127.0.0.1:50101/50103/48010. // Só GET/HEAD em rotas conhecidas; sem POST destrutivo. // csc /nologo /optimize+ /out:MaverickHttpMap.exe MaverickHttpMap.cs using System; using System.Net; using System.Net.Sockets; using System.Text; internal static class MaverickHttpMap { static readonly string[] Endpoints = { "127.255.255.254:80", "127.0.0.1:50101", "127.0.0.1:50103", "127.0.0.1:48010", }; static string Host(string endpoint) { return endpoint.Substring(0, endpoint.LastIndexOf(':')); } static int Port(string endpoint) { return int.Parse(endpoint.Substring(endpoint.LastIndexOf(':') + 1)); } static readonly string[] Routes = { "/", "/v1/", "/v1/status", "/v1/session", "/SDK/v.1.0/BusMessage", "/AppInfo/v.1.0/ping", "/AppInfo/v.1.0/Notification", "/EventAPI/v.1.0/BusMessage", }; static string Tcp(string host, int port) { try { using (var c = new TcpClient()) { var t = c.ConnectAsync(host, port); if (!t.Wait(900) || !c.Connected) return "fechado/timeout"; return "aberto"; } } catch (Exception ex) { return ex.GetType().Name; } } static string[] Request(string url) { try { var req = (HttpWebRequest)WebRequest.Create(url); req.Method = "GET"; req.Timeout = 1200; req.ReadWriteTimeout = 1200; req.AllowAutoRedirect = false; req.UserAgent = "MaverickHttpMap"; using (var resp = (HttpWebResponse)req.GetResponse()) using (var s = resp.GetResponseStream()) { var buf = new byte[2048]; int n = s.Read(buf, 0, buf.Length); string body = Encoding.UTF8.GetString(buf, 0, Math.Max(0, n)); var clean = new StringBuilder(); foreach (char ch in body) { clean.Append(ch >= 32 && ch < 127 ? ch : '.'); } return new[] { ((int)resp.StatusCode).ToString(), n.ToString(), clean.ToString() }; } } catch (WebException ex) { var err = ex.Response as HttpWebResponse; if (err != null) return new[] { ((int)err.StatusCode).ToString(), "0", "(corpo de erro)" }; return new[] { "-1", "0", ex.Message }; } catch (Exception ex) { return new[] { "-2", "0", ex.Message }; } } static int Main() { Console.WriteLine("=== MaverickHttpMap ==="); Console.WriteLine("user=" + Environment.UserName + " session=" + System.Diagnostics.Process.GetCurrentProcess().SessionId + "\n"); foreach (string endpoint in Endpoints) { string host = Host(endpoint); int port = Port(endpoint); string state = Tcp(host, port); Console.WriteLine("== " + endpoint + " -> " + state); if (state != "aberto") { Console.WriteLine(); continue; } foreach (string route in Routes) { string url = "http://" + endpoint + route; string[] r = Request(url); int code; int.TryParse(r[0], out code); if (code == -1 || code == -2) continue; Console.WriteLine(string.Format(" {0,-32} {1,5} {2,6}B {3}", route, r[0], r[1], r[2].Length > 90 ? r[2].Substring(0, 90) : r[2])); } Console.WriteLine(); } Console.WriteLine("leitura: 200/404 = servidor HTTP vivo. -1 em tudo = porta fala outro protocolo (rtsp/raw)."); return 0; } }