예제 #1
0
 private void InterceptConnection()
 {
     string[] ports = Program.GameData.InfoPort.Split(',');
     if (ports.Length == 0 || !ushort.TryParse(ports[0], out ushort port) ||
         !HotelEndPoint.TryParse(Program.GameData.InfoHost, port, out HotelEndPoint endpoint))
     {
         throw new Exception("Failed to parse: " + Program.GameData.InfoPort);
     }
     Program.Connection.Intercept(endpoint);
 }
예제 #2
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string address = value.ToString();

            string[] points = address.Split(':');

            HotelEndPoint endpoint = null;

            if (points.Length == 2)
            {
                string[] ports = points[1].Split(',');
                if (ports.Length > 0 && ushort.TryParse(ports[0], out ushort port))
                {
                    HotelEndPoint.TryParse(points[0], port, out endpoint);
                }
            }
            return(endpoint);
        }
예제 #3
0
        private void InterceptClientPage(object sender, ResponseInterceptedEventArgs e)
        {
            if (!e.Response.ContentType.Contains("text/html"))
            {
                return;
            }
            string body = Encoding.UTF8.GetString(e.Payload);

            if (!body.Contains("info.host") && !body.Contains("info.port"))
            {
                return;
            }

            Eavesdropper.ResponseIntercepted -= InterceptClientPage;
            App.Master.GameData.Source        = body;

            if (IsAutomaticServerExtraction)
            {
                string[] ports = App.Master.GameData.InfoPort.Split(',');
                if (ports.Length == 0 ||
                    !ushort.TryParse(ports[0], out ushort port) ||
                    !HotelEndPoint.TryParse(App.Master.GameData.InfoHost, port, out HotelEndPoint endpoint))
                {
                    Cancel(null);
                    return;
                }
                HotelServer = endpoint;
            }

            if (App.Master.GameData.Hotel != HHotel.Unknown)
            {
                body = body.Replace(App.Master.GameData.InfoHost, "127.0.0.1");
            }
            body = body.Replace(".swf", $".swf?Tanji-{DateTime.Now.Ticks}");

            Status = SYNCHRONIZING_GAME_DATA;
            App.Master.Synchronize(App.Master.GameData);

            e.Payload = Encoding.UTF8.GetBytes(body);

            Status = INJECTING_CLIENT;
            Eavesdropper.RequestIntercepted += InjectGameClient;
        }
예제 #4
0
        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string address = value.ToString();

            string[] points = address.Split(':');

            if (points.Length < 2)
            {
                return(null);
            }

            ushort        port     = 0;
            HotelEndPoint endpoint = null;

            if (!ushort.TryParse(points[1], out port) ||
                !HotelEndPoint.TryParse(points[0], port, out endpoint))
            {
                return(null);
            }
            return(endpoint);
        }