示例#1
0
        // GET procedure
        private async void getProcedure(string userText, string accountText, string passwordText)
        {
            // Hash user, send HTTP request and store response in httpresult
            string userhash = BackendClass.hashuserhex(userText);
            FormUrlEncodedContent toSend = BackendClass.generateFirstPost(userhash, accountText);
            HttpClient            client = new HttpClient();

            client.BaseAddress = new Uri(Config.serverURL);
            client.DefaultRequestHeaders.Add("Referer", Config.serverURI + "/getpass.html");
            string httpresult = "";

            try {
                HttpResponseMessage httpresultraw = await client.PostAsync(Config.serverURI + "/getpass.php", toSend);

                httpresult = await httpresultraw.Content.ReadAsStringAsync();
            } catch (HttpRequestException ex) {
                ResultLabel.Text = "HTTP error. Are you connected\nto the Internet?"; return;
            }
            // Run parseGetResult
            string getResult = BackendClass.parseGetResult(userhash, httpresult, passwordText);

            // Check success and act accordingly
            if (getResult.StartsWith("Password: "******"password" header before copying
                ResultLabel.Text = "Result: Password Copied";
            }
            else
            {
                ResultLabel.Text = getResult.Trim();
            }
        }
示例#2
0
        // ADD procedure
        private async void addProcedure(string userText, string accountText, string passwordText, int passLength)
        {
            // Hash user, send HTTP request and store response in httpresult. Cookies stored in handler.
            string userhash = BackendClass.hashuserhex(userText);
            FormUrlEncodedContent toSend  = BackendClass.generateFirstPost(userhash, accountText);
            HttpClientHandler     handler = new HttpClientHandler(); handler.UseCookies = true;
            HttpClient            client  = new HttpClient(handler);

            client.BaseAddress = new Uri(Config.serverURL);
            client.DefaultRequestHeaders.Add("Referer", Config.serverURI + "/addpass.html");
            string httpresult = "";

            try {
                HttpResponseMessage httpresultraw = await client.PostAsync(Config.serverURI + "/addpass_challenge.php", toSend);

                httpresult = await httpresultraw.Content.ReadAsStringAsync();
            } catch (HttpRequestException ex) {
                ResultLabel.Text = "HTTP error. Are you connected\nto the Internet?"; return;
            }
            // Run respondToAdd
            string[] responseFields;
            try {
                responseFields = BackendClass.respondToAdd(userhash, httpresult, passwordText, accountText, passLength).Split('$');
            } catch (Exception ex) {
                ResultLabel.Text = ex.Message.Trim();
                return;
            }
            // Send verification
            toSend = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("userhash", userhash),
                new KeyValuePair <string, string>("passwordcrypt", responseFields[0]),
                new KeyValuePair <string, string>("signature", responseFields[1])
            });
            HttpResponseMessage httpresultfinalraw = await client.PostAsync(Config.serverURI + "/addpass_verify.php", toSend);

            string httpresultfinal = await httpresultfinalraw.Content.ReadAsStringAsync();

            // Show result and return
            ResultLabel.Text = httpresultfinal;
        }