public static Blob Fetch(Session session, IWebClient webClient) { webClient.Headers.Add("Cookie", string.Format("PHPSESSID={0}", Uri.EscapeDataString(session.Id))); byte[] response; try { response = webClient.DownloadData("https://lastpass.com/getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android"); } catch (WebException e) { throw new FetchException(FetchException.FailureReason.WebException, "WebException occured", e); } try { return new Blob(response.ToUtf8().Decode64(), session.KeyIterationCount); } catch (FormatException e) { throw new FetchException(FetchException.FailureReason.InvalidResponse, "Invalid base64 in response", e); } }
public static Blob Fetch(Session session) { using (var webClient = new WebClient()) return Fetch(session, webClient); }