Click here to Skip to main content
15,880,427 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to red variable continuously Pin
Zefir110-Feb-16 21:20
Zefir110-Feb-16 21:20 
GeneralRe: How to red variable continuously Pin
OriginalGriff10-Feb-16 21:38
mveOriginalGriff10-Feb-16 21:38 
QuestionFTP vs SCP Pin
Kevin Marois10-Feb-16 7:42
professionalKevin Marois10-Feb-16 7:42 
AnswerRe: FTP vs SCP Pin
Richard Deeming10-Feb-16 10:11
mveRichard Deeming10-Feb-16 10:11 
GeneralRe: FTP vs SCP Pin
Kevin Marois10-Feb-16 10:29
professionalKevin Marois10-Feb-16 10:29 
GeneralRe: FTP vs SCP Pin
Eddy Vluggen10-Feb-16 10:41
professionalEddy Vluggen10-Feb-16 10:41 
QuestionBeginner on TCP Server/Client Implementation Pin
Member 1018338210-Feb-16 6:18
Member 1018338210-Feb-16 6:18 
QuestionProgrammatically login to website that uses 2 steps. Pin
Dralken10-Feb-16 2:18
Dralken10-Feb-16 2:18 
I'm working on making an app that scrapes my debit card account for my current balance and account activity. (I recently bought a Windows Phone, and they don't have an app for WP, and their website is not mobile friendly).

I'm running into an issue that has me a bit stumped. They use 2 steps for authentication. The first form submits the username and password, the 2nd asks for your date of birth as a secondary authentication.

I'm not sure where it's failing. I know the first request is good, as it brings up the DOB verify page, however after posting the DOB data, the 3rd response is back at the login screen.

The cookie headers are being filled, and all the response codes seem to be good. Does anyone see where the potential problem might be in this?

C#
HttpWebRequest http = WebRequest.Create(LoginURL) as HttpWebRequest;
http.KeepAlive = true;
http.Method = "POST";
http.ContentType = "application/x-www-form-urlencoded";
//http.CookieContainer = AuthCookies;
string postData = "languageCode=&reqType=&j_username=myuser&j_password=mypass&sign-in.x=29&sign-in.y=7";
byte[] dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
http.ContentLength = postData.Length;

using (Stream postStream = http.GetRequestStream())
{
    postStream.Write(dataBytes, 0, dataBytes.Length);
}

HttpWebResponse httpResponse = http.GetResponse() as HttpWebResponse;
//foreach (Cookie ck in httpResponse.Cookies)
//{
//  AuthCookies.Add(ck);
//}
using (Stream respStream = httpResponse.GetResponseStream())
{
    StreamReader reader = new StreamReader(respStream, Encoding.UTF8);
    File.WriteAllText("loginresp.html", reader.ReadToEnd());
    reader.Close();
}

//DOB Verify
httpResponse.Close();
HttpWebRequest http2 = WebRequest.Create(DOBVerifyURL) as HttpWebRequest;
http2.KeepAlive = true;
http2.Method = "POST";
http2.ContentType = "application/x-www-form-urlencoded";
//http2.CookieContainer = AuthCookies;
http2.Headers["Cookie"] = httpResponse.Headers["Set-Cookie"];
http2.Referer = LoginURL;
http2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36";
postData = "reqType=&cmd=checkSecu&languageCode=&additionalHolderAuthValue=urlencodeddob&continue.x=86&continue.y=13";
dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
http2.ContentLength = postData.Length;
using (Stream postStream = http2.GetRequestStream())
{
    postStream.Write(dataBytes, 0, dataBytes.Length);
}
HttpWebResponse httpResponse2 = http2.GetResponse() as HttpWebResponse;
//foreach (Cookie ck in httpResponse2.Cookies)
//{
//  AuthCookies.Add(ck);
//}
using (Stream respStream2 = httpResponse2.GetResponseStream())
{
    HttpWebRequest http3 = WebRequest.Create(AcctActivityURL) as HttpWebRequest;
    http3.KeepAlive = true;
    http3.ContentType = "text/html";
    //http3.CookieContainer = AuthCookies;
    http3.Headers["Cookie"] = httpResponse2.Headers["Set-Cookie"];
    http3.Referer = LoginURL;
    http3.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36";
    http3.AllowAutoRedirect = false;
    HttpWebResponse httpResponse3 = http3.GetResponse() as HttpWebResponse;
    using (Stream respStream3 = httpResponse3.GetResponseStream())
    {
        StreamReader reader = new StreamReader(respStream3, Encoding.UTF8);
        File.WriteAllText("dobresp.html", reader.ReadToEnd());
        reader.Close();
    }
}

I copied the headers using Chrome's dev tools.
I can provide the working (from Chrome) headers, html, etc (edited of any personal info, of course) if needed.
(Side note: I don't plan on releasing or selling this app, this is purely for my own use. And it doesn't violate any terms or conditions so far as I can tell)
AnswerRe: Programmatically login to website that uses 2 steps. Pin
OriginalGriff10-Feb-16 4:14
mveOriginalGriff10-Feb-16 4:14 
GeneralRe: Programmatically login to website that uses 2 steps. Pin
Dralken10-Feb-16 4:30
Dralken10-Feb-16 4:30 
GeneralRe: Programmatically login to website that uses 2 steps. Pin
Luc Pattyn11-Feb-16 0:29
sitebuilderLuc Pattyn11-Feb-16 0:29 
GeneralRe: Programmatically login to website that uses 2 steps. Pin
OriginalGriff11-Feb-16 0:35
mveOriginalGriff11-Feb-16 0:35 
SuggestionRe: Programmatically login to website that uses 2 steps. Pin
Richard Deeming10-Feb-16 4:16
mveRichard Deeming10-Feb-16 4:16 
AnswerRe: Programmatically login to website that uses 2 steps. Pin
V.10-Feb-16 20:21
professionalV.10-Feb-16 20:21 
QuestionIssue with Serial Port class Pin
Member 120616009-Feb-16 23:13
Member 120616009-Feb-16 23:13 
SuggestionRe: Issue with Serial Port class Pin
Richard MacCutchan10-Feb-16 0:14
mveRichard MacCutchan10-Feb-16 0:14 
GeneralRe: Issue with Serial Port class Pin
Member 1206160010-Feb-16 0:23
Member 1206160010-Feb-16 0:23 
GeneralRe: Issue with Serial Port class Pin
Richard MacCutchan10-Feb-16 0:30
mveRichard MacCutchan10-Feb-16 0:30 
GeneralRe: Issue with Serial Port class Pin
Member 1206160010-Feb-16 0:38
Member 1206160010-Feb-16 0:38 
GeneralRe: Issue with Serial Port class Pin
Richard MacCutchan10-Feb-16 1:02
mveRichard MacCutchan10-Feb-16 1:02 
GeneralRe: Issue with Serial Port class Pin
Member 1206160010-Feb-16 1:18
Member 1206160010-Feb-16 1:18 
GeneralRe: Issue with Serial Port class Pin
Richard MacCutchan10-Feb-16 1:30
mveRichard MacCutchan10-Feb-16 1:30 
GeneralRe: Issue with Serial Port class Pin
Member 1206160010-Feb-16 1:52
Member 1206160010-Feb-16 1:52 
GeneralRe: Issue with Serial Port class Pin
Eddy Vluggen10-Feb-16 3:00
professionalEddy Vluggen10-Feb-16 3:00 
AnswerRe: Issue with Serial Port class Pin
Gerry Schmitz10-Feb-16 5:39
mveGerry Schmitz10-Feb-16 5:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.