Ejemplo n.º 1
0
        public static ResponseBuilder Connect(RequestBuilder request)
        {
            ResponseBuilder response = new ResponseBuilder();
            try
            {
                Socket s = Connect(request.CurrentURL.Host, request.CurrentURL.Port);
                if (s == null) throw new Exception("Connection failed");

                Byte[] bytesSent = Encoding.UTF8.GetBytes(request.ToString());
                Byte[] bytesReceived = new Byte[request.ToString().Length];

                // Send request to the server.
                s.Send(bytesSent, bytesSent.Length, 0);
                int bytes = 0;
                do
                {
                    // Receive response to the server.
                    bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
                    response.Append(Encoding.UTF8.GetString(bytesReceived, 0, bytes));
                }
                while (bytes > 0);
            }
            catch (Exception ex)
            {
                response.Clear();
                response.AppendLine(ex.Message);
                response.AppendLine(ex.StackTrace);
            }
            return response;
        }
Ejemplo n.º 2
0
        public void Login(string username, string password)
        {
            RequestBuilder _req = new RequestBuilder(doLogin);
            _req.By = RequestBuilder.Method.POST;
            _req.Referer = "http://forum.tirkx.com/main/index.php";
            _req.Origin = "http://forum.tirkx.com";
            _req.ContentType = "application/x-www-form-urlencoded";
            _req.PostValue.Add("vb_login_username", username);
            _req.PostValue.Add("vb_login_password", "");
            _req.PostValue.Add("vb_login_password_hint", "Password");
            _req.PostValue.Add("cookieuser", "1");
            _req.PostValue.Add("securitytoken", "guest");
            _req.PostValue.Add("do", "login");
            _req.PostValue.Add("vb_login_md5password", Tirkx.MD5(password));
            _req.PostValue.Add("vb_login_md5password_utf", Tirkx.MD5(password));

            //string respone = ConnectTirkx(doLogin, _req.ToString());
        }