I want to try get current DateTime like this :
try {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.timestampconvert.com/");
req.Method = "GET";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36";
req.ContentType = "text/html; charset=utf-8";
req.Referer = string.Empty;
req.KeepAlive = true;
req.Timeout = 25000;
//req.Proxy = proxy;
HttpWebResponse res = (HttpWebResponse) req.GetResponse();
Stream Stream = res.GetResponseStream();
StreamReader reader = new StreamReader(Stream);
string reader_str = reader.ReadToEnd();
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.LoadHtml(reader_str);
var divs = from div in htmlDoc.DocumentNode.Descendants("div")
select div;
DateTime dt = DateTime.Now;
foreach(var div in divs) {
if (div.Attributes["class"] != null) {
if (div.Attributes["class"].Value == "remarkrow") {
if (div.InnerText.Contains("Computation based on input date")) {
CultureInfo cultureinfo = new CultureInfo("en-US");
dt = Convert.ToDateTime(div.InnerText.Replace("\n\t*)Computation based on input date ", string.Empty), cultureinfo);
dt = dt.AddHours(2).AddMinutes(30);
break;
}
}
}
}
DateTime dt_ = dt;
}
catch(Exception ex) {
MessageBox.Show(ex.ToString());
}
But it has an exception like below :
The request was aborted: Could not create SSL/TLS secure channel
How can i fix this error?
The code I have works and successfully logs me in the first time, but when I try it for a second time the form freezes and I have to restart the program. Here is my code:
private void button1_Click(object sender, EventArgs e)
{
Auth(textBox1.Text, textBox2.Text);
}
private void Auth(string user, string pass)
{
try
{
//GET CSRF TOKEN
var request = (HttpWebRequest)WebRequest.Create("https://accounts.spotify.com/en-US/login?continue=https:%2F%2Fwww.spotify.com%2Fus%2Faccount%2Foverview%2F");
request.Method = "GET";
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
var response1 = (HttpWebResponse)request.GetResponse();
var headers = response1.Headers;
var csrf = headers["Set-Cookie"].Split('=', ';')[1];
//POST LOGIN
var request2 = (HttpWebRequest)WebRequest.Create("https://accounts.spotify.com/api/login");
var postdata = Encoding.ASCII.GetBytes(string.Format("remember=true&username={0}&password={1}&captcha_token=&csrf_token={2}", user, pass, csrf));
request2.Method = "POST";
request2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36";
request2.ContentType = "application/x-www-form-urlencoded";
request2.ContentLength = postdata.Length;
request2.Headers.Add(string.Format("Cookie: sp_t=4c114efa38d7c3d8510fa41bb7fd76af; spot=%7B%22t%22%3A1523485160%2C%22m%22%3A%22us%22%2C%22p%22%3Anull%7D; _ga=GA1.2.981430147.1523485160; sp_usid=919af976-2997-44dc-872b-1704356316bb; sp_last_utm=%7B%22utm_source%22%3A%22us-en_brand_contextual-desktop_text%22%2C%22utm_medium%22%3A%22paidsearch%22%2C%22utm_campaign%22%3A%22alwayson_ucanz_us_performancemarketing_core_brand+contextual-desktop+text+bmm+us-en+google%22%7D; _gid=GA1.2.411374915.1523901844; _gcl_aw=GCL.1523901845.CjwKCAjwk9HWBRApEiwA6mKWabkt4w1SE6lOm5TjrId-HkZNuakJeNIhOAkuVou7Vmueqb0bbw7sUBoCcvYQAvD_BwE; _gcl_dc=GCL.1523901845.CjwKCAjwk9HWBRApEiwA6mKWabkt4w1SE6lOm5TjrId-HkZNuakJeNIhOAkuVou7Vmueqb0bbw7sUBoCcvYQAvD_BwE; _gac_UA-5784146-31=1.1523902416.CjwKCAjwk9HWBRApEiwA6mKWabkt4w1SE6lOm5TjrId-HkZNuakJeNIhOAkuVou7Vmueqb0bbw7sUBoCcvYQAvD_BwE; _gat_UA-5784146-31=1; _gali=header-login-link; __bon=MHwwfC0zMTA4ODYyMDR8LTEzMDU3MjIwNTY4fDF8MXwxfDE=; fb_continue=https%3A%2F%2Fwww.spotify.com%2Fus%2Faccount%2Foverview%2F; _gat=1; csrf_token={0}; remember=ghyuit78%40gmail.com", csrf));
using (Stream w = request2.GetRequestStream()) //Freezes around here the second time around
{
w.Write(postdata, 0, postdata.Length);
}
var response2 = new StreamReader(((HttpWebResponse)request2.GetResponse()).GetResponseStream()).ReadToEnd();
richTextBox1.Text = "Request1:\n----------------------\n" + response2;
if (response2.Contains("displayName"))
{
label3.ForeColor = Color.Green;
label3.Text = "Successfully logged in!";
}
else
{
label3.ForeColor = Color.Red;
label3.Text = "Invalid username/password. Try again!";
}
}
catch
{
label3.ForeColor = Color.Red;
label3.Text = "ERROR! Try again!";
}
}
I manage to get a successful login the first time, but when I press the button again, it freezes and does not give me an error or anything. I have to open my task manager and end the process.
Everything Working Properly but we click on submitData() button i will show me login page instead of myhomepage,
so very first I navigate login page it will set the cookie, then cookie stored in cookie container code is
CookieContainer cookieJar = new CookieContainer();
public Form1()
{
String captcha;
InitializeComponent();
}
private void BUTTON_LOGIN_Click(object sender, EventArgs e)
{
//Get captcha
var request = (HttpWebRequest)HttpWebRequest.Create("https://www.irctc.co.in/eticketing/loginHome.jsf");
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
request.KeepAlive = true;
request.CookieContainer = cookieJar;
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
var response = request.GetResponse();
using (var stream = response.GetResponseStream())
{
}
// need array, different storage for every cookies
//
foreach (Cookie c in cookieJar.GetCookies(response.ResponseUri))
{
request.CookieContainer.Add(c);
MessageBox.Show("Cookie['" + c.Name + "']: " + c.Value);
}
}
Then I request for captcha using cookie
private void pictureBox1_Click(object sender, EventArgs e) // This Event Refresh thr captcha
{
//Get captch
var request =(HttpWebRequest)HttpWebRequest.Create("https://www.irctc.co.in/eticketing/captchaImage");
request.Accept = "image/webp,image/*,*/*;q=0.8";
WebHeaderCollection myWebHeaderCollection = request.Headers;
myWebHeaderCollection.Add("Accept-Language", "en-US;q=0.8");
myWebHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
request.KeepAlive = true;
Uri target = new Uri("https://www.irctc.co.in");
cookieJar.Add(new Cookie("language", "en_IN") { Domain = target.Host });
request.CookieContainer = cookieJar;
request.Referer = "https://www.irctc.co.in/eticketing/loginHome.jsf";
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
var response = request.GetResponse();
using (var stream = response.GetResponseStream())
{
pictureBox1.Image = Bitmap.FromStream(stream);
}
// need array, different storage for every cookies
//
foreach (Cookie c in cookieJar.GetCookies(response.ResponseUri))
{
request.CookieContainer.Add(c);
MessageBox.Show("Cookie['" + c.Name + "']: " + c.Value);
}
}
private void button1_Click(object sender, EventArgs e)
{
submitData();
}
private void displayHtml(String html)
{
webBrowser1.Navigate("about:blank");
while (webBrowser1.Document == null || webBrowser1.Document.Body == null)
Application.DoEvents();
webBrowser1.Document.OpenNew(true).Write(html);
}
And finally I submit data after filling captcha to text box and here is error this is redirect me login page again so whats going wrong.
private void submitData()
{
try
{
String user = "myusername";
String pass = "mypassword";
String submit = "Submit";
String captcha=richTextBox1.Text.ToString() ;
ASCIIEncoding encoding = new ASCIIEncoding();
// MessageBox.Show(captcha);
string postData = "j_username=" + user + "&j_password=" + pass + "&j_captcha=" + captcha + "&submit=" + submit + "&tneg=" ;
byte[] data = Encoding.UTF8.GetBytes(postData);
Uri target = new Uri("https://www.irctc.co.in");
cookieJar.Add(new Cookie("language", "en_IN"){ Domain = target.Host });
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://www.irctc.co.in/eticketing/home");
request.CookieContainer = cookieJar;
WebHeaderCollection myWebHeaderCollection = request.Headers;
myWebHeaderCollection.Add("Accept-Language", "en-US;q=0.8");
myWebHeaderCollection.Add("Upgrade-Insecure-Requests", "1");
request.Method = "POST";
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
request.ContentType = "application/x-www-form-urlencode";
request.Referer = "https://www.irctc.co.in/eticketing/loginHome.jsf";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
request.ServicePoint.Expect100Continue = false;
// var bytes = Encoding.UTF8.GetBytes("action=login&from=http%3A%2F%2Fwww.dofus.com%2Ffr&login=user123&password=password1232F&remember=1");
// request.ContentLength = bytes.Length;
request.ContentLength = data.Length;
request.KeepAlive = true;
// request.AutomaticDecompression = DecompressionMethods.GZip;
// request.AutomaticDecompression = DecompressionMethods.Deflate;
// request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br");
// request.SendChunked = true;
// request.TransferEncoding = "gzip, deflate, br";
request.Host = "www.irctc.co.in";
//request.Headers.Add
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
foreach (Cookie c in cookieJar.GetCookies(request.RequestUri))
{
MessageBox.Show("Cookie['" + c.Name + "']: " + c.Value);
}
StreamReader sr = new StreamReader(stream);
//richTextBox1.Text = sr.ReadToEnd();
String myhtml = sr.ReadToEnd().ToString();
displayHtml(myhtml);
sr.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
}
In the method submitData()
request.ContentType = "application/x-www-form-urlencode"
here is a typo, you have missed one 'd'
it should be like this :-
request.ContentType = "application/x-www-form-urlencoded"
ContentType is "application/x-www-form-urlencoded".
If the server is unable to understand the form data type(in this case "application/x-www-form-urlencode" is unknown to the server),then it will reject the request and redirects the user to login page as you mentioned.
You can also check Form ContentType in HTML Forms(w3.org) for more information.
Hope this helps :)
Alright this is the whole function
But the read values are extremely incorrect
I don't know what can be the problem
Edit
Ok it seems like problem is about gzip compression.
How can i decompress the GetResponseStream ?
public static List<object> func_DoHTTPWebRequest(PerVotingSite myPerVote, string srUrl, string srCookiePrev = "", string srRefererParameter = null,
string srBrowserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31")
{
try
{
srUrl = "http://stackoverflow.com/"; // for testing purposes
string srReferer = myPerVote.srReferer;
if (srRefererParameter != null)
srReferer = srRefererParameter;
bool blKeepAlive = myPerVote.blKeepAlive;
int irRequestTimeOut = myPerVote.irRequestsTimeOut;
if (irRequestTimeOut == 0)
irRequestTimeOut = OtomatikVoter.irTimeOut;
bool blKeepCookies = myPerVote.blKeepCookies;
HttpWebRequest hWebReq = (HttpWebRequest)WebRequest.Create(srUrl);
hWebReq.KeepAlive = blKeepAlive;
hWebReq.Referer = srReferer;
hWebReq.Timeout = irRequestTimeOut;
hWebReq.ReadWriteTimeout = irRequestTimeOut;
hWebReq.UserAgent = srBrowserAgent;
hWebReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
WebHeaderCollection myWebHeaderCollection = hWebReq.Headers;
myWebHeaderCollection.Add("Accept-Language", "en-gb,en;q=0.5");
myWebHeaderCollection.Add("Accept-Encoding", "gzip, deflate");
if (srCookiePrev.Length > 1)
myWebHeaderCollection.Add("Cookie", srCookiePrev);
string srCookie = "";
HtmlAgilityPack.HtmlDocument hDoc = new HtmlAgilityPack.HtmlDocument();
using (HttpWebResponse hWebResp = (HttpWebResponse)hWebReq.GetResponse())
{
using (var resultStream = hWebResp.GetResponseStream())
{
if (hWebResp.Headers["Set-Cookie"] != null && blKeepCookies == true)
srCookie = hWebResp.Headers["Set-Cookie"].ToString();
hDoc.Load(resultStream,Encoding.UTF8);
}
}
return new List<object> { hDoc, srCookie, hWebReq };
}
catch (Exception E)
{
SpecialFunctions.writeError(E, "func_DoHTTPWebRequest");
return null;
}
}
And here the read result
This code was working before now i can't figure out why not working
Visual Studio 2012 , C# 5
http://i.stack.imgur.com/QXw1h.png
http://i.stack.imgur.com/QXw1h.png
private void Form1_Load(object sender, EventArgs e)
{
string site = "https://signin.ebay.com/ws/eBayISAPI.dll?co_partnerId=2&siteid=0&UsingSSL=1&MfcISAPICommand=SignInWelcome&userid=USERNAME&pass=PWD&sngBt=Sign%20in";
CookieContainer cookieJar = new CookieContainer();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(site);
request.CookieContainer = cookieJar;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
richTextBox1.Text = sr.ReadToEnd();
foreach (Cookie c1 in response.Cookies)
{
richTextBox1.AppendText(c1.Name.ToString() + "\n\n");
}
}
I've been messing around with Fiddler and the headers for 2 days with nothing better. Please help me retrieve this last cookie. In the browser the URL will log you right in (Change USERNAME and PWD respectively), and returns ds2, ebay, dp1, cssg, nonsession cookies.. the code is missing the ebay cookie.
Request Headers:
Client
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko)
Chrome/24.0.1312.56 Safari/537.17
Transport
Connection: keep-alive
Host: signin.ebay.com
private void Form1_Load(object sender, EventArgs e)
{
string site = "https://signin.ebay.com/ws/eBayISAPI.dll?co_partnerId=2&siteid=0&UsingSSL=1&MfcISAPICommand=SignInWelcome&userid=USERNAME&pass=PWD&sngBt=Sign%20in";
CookieContainer cookieJar = new CookieContainer();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(site);
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3");
request.Headers.Add("Accept-Encoding: gzip,deflate,sdch");
request.Headers.Add("Accept-Language: en-US,en;q=0.8");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17";
request.CookieContainer = cookieJar;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
richTextBox1.Text = sr.ReadToEnd();
foreach (Cookie c1 in response.Cookies)
{
richTextBox1.AppendText(c1.Name.ToString() + "\n\n");
}
}
Fiddler will take me no further? this returns no source, but does return the ebay cookie..
Well finally,
class Program
{
static void Main(string[] args)
{
CookieContainer cookieJar = new CookieContainer();
HTTP http = new HTTP(cookieJar);
string user = "this is not my username";
string pass = "this is not my password";
//some cookies are set before login & they are needed for an user to login, for that reason only you were getting the error
string responseData = http.DownloadString("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn");
string midParamValue = ParseMid(responseData, "name=\"mid\" id=\"mid\" value=\"", "\"");
string bUrlPrfx = ParseMid(responseData, "id=\"bUrlPrfx\" value=\"", "\"");
string rqid = ParseMid(responseData, "id=\"bUrlPrfx\" value=\"", "\"");
string pdata =
string.Format(
"MfcISAPICommand=SignInWelcome&bhid=a1%253Dna%7Ea2%253Dna%7Ea3%253Dna%7Ea4%253DMozilla%7Ea5%253DNetscape%7Ea6%253D5.0%2520%28Windows%29%7Ea7%253D20100101%7Ea8%253Dna%7Ea9%253Dtrue%7Ea10%253DWindows%2520NT%25206.1%253B%2520WOW64%7Ea11%253Dtrue%7Ea12%253DWin32%7Ea13%253Dna%7Ea14%253DMozilla%252F5.0%2520%28Windows%2520NT%25206.1%253B%2520WOW64%253B%2520rv%253A18.0%29%2520Gecko%252F20100101%2520Firefox%252F18.0%7Ea15%253Dfalse%7Ea16%253Den-US%7Ea17%253Dna%7Ea18%253Dsignin.ebay.com%7Ea19%253Dna%7Ea20%253Dna%7Ea21%253Dna%7Ea22%253Dna%7Ea23%253D1366%7Ea24%253D768%7Ea25%253D24%7Ea26%253D738%7Ea27%253Dna%7Ea28%253DFri%2520Jan%252025%25202013%252022%253A20%253A09%2520GMT%252B0530%2520%28India%2520Standard%2520Time%29%7Ea29%253D5.5%7Ea30%253Dpdf%257Cpdf%257Cpdf%257C%7Ea31%253Dyes%7Ea32%253Dna%7Ea33%253Dna%7Ea34%253Dno%7Ea35%253Dno%7Ea36%253Dyes%7Ea37%253Dno%7Ea38%253Donline%7Ea39%253Dno%7Ea40%253DWindows%2520NT%25206.1%253B%2520WOW64%7Ea41%253Dno%7Ea42%253Dno%7Ea43%253D&UsingSSL=1&inputversion=2&lse=true&lsv=11.5.502&mid=AQAAAThpCRHvAAUxMzg5OTM0YzA2MS5hNWFiODMyLjJmNDcyLmZmZTlhOWUwEZMPFiRFo7yUjykHfCAFgp%2Bk9%2Bk*&kgver=1&kgupg=1&kgstate=r&omid=&hmid=&rhr=f&siteid=0&co_partnerId=2&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&rtmData=&bUrlPrfx={0}&rqid={1}&kgct=&userid={2}&pass={3}&keepMeSignInOption=1&sgnBt=Sign+in&htmid={4}&kdata=%251E%251F%2510%251E1359132609409%251E1%251F%2510%251E1359132609409%251E0%251F%2510%251E1359132609410%251E1%251F%2510%251E1359132609410%251E0%251F%251B%251E1359132612808%251E1%251F%2510%251E1359132612837%251E1%251F%2510%251E1359132612838%251E0%251F%251B%251E1359132612977%251E0%251F", bUrlPrfx, rqid, user,pass, midParamValue);
responseData =
http.UploadString("https://signin.ebay.com/ws/eBayISAPI.dll?co_partnerId=2&siteid=0&UsingSSL=1", pdata);
PrintAllCookies(cookieJar);
Console.Read();
}
private static void PrintAllCookies(CookieContainer cookies)
{
Hashtable table = (Hashtable)cookies.GetType().InvokeMember("m_domainTable",
BindingFlags.NonPublic |
BindingFlags.GetField |
BindingFlags.Instance,
null,
cookies,
new object[] { });
foreach (string key in table.Keys)
{
foreach (Cookie cookie in cookies.GetCookies(new Uri(string.Format("http://{0}/", key.StartsWith(".", StringComparison.Ordinal) ? "www" + key : key))))
{
Console.WriteLine("Name = {0} ; Value = {1} ; Domain = {2}", cookie.Name, cookie.Value,
cookie.Domain);
}
}
}
public static string ParseMid(string text, string firstString, string lastString)
{
string str = text;
int pos1 = str.IndexOf(firstString, StringComparison.Ordinal) + firstString.Length;
int pos2 = str.IndexOf(lastString, pos1 + 1, StringComparison.Ordinal);
string finalString = str.Substring(pos1, pos2 - pos1);
return finalString;
}
}
You will need a class that i used, its a simple WebClient that supports CookieContainer
The output :
Have printed cookie value to "none" as i logged in with my username :P
HTTP.cs
public class HTTP : WebClient
{
public HTTP()
: this(new CookieContainer())
{ }
public HTTP(CookieContainer c)
{
CookieContainer = c;
}
public CookieContainer CookieContainer { get; set; }
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
var castRequest = request as HttpWebRequest;
if (castRequest != null)
{
castRequest.CookieContainer = CookieContainer;
castRequest.ServicePoint.Expect100Continue = false;
castRequest.ContentType = "application/x-www-form-urlencoded";
}
return request;
}
}
namespace watcher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CookieContainer cookieJar = new CookieContainer();
HTTP http = new HTTP(cookieJar);
string user = "id";
string pass = "password";
//some cookies are set before login & they are needed for an user to login, for that reason only you were getting the error
string responseData = http.DownloadString("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn");
string midParamValue = ParseMid(responseData, "name=\"mid\" id=\"mid\" value=\"", "\"");
string bUrlPrfx = ParseMid(responseData, "id=\"bUrlPrfx\" value=\"", "\"");
string rqid = ParseMid(responseData, "id=\"bUrlPrfx\" value=\"", "\"");
string hidUrl = ParseMid(responseData, "name=\"hidUrl\" value=\"", "\""); //"name=\"hidUrl\" value="http://my.ebay.com/ws/eBayISAPI.dll?MyeBay"
//string lucky9 = ParseMid(responseData,
string pdata =
string.Format(
"MfcISAPICommand=SignInWelcome&bhid=a1%253Dna%7Ea2%253Dna%7Ea3%253Dna%7Ea4%253DMozilla%7Ea5%253DNetscape%7Ea6%253D5.0%2520%28Windows%29%7Ea7%253D20100101%7Ea8%253Dna%7Ea9%253Dtrue%7Ea10%253DWindows%2520NT%25206.1%253B%2520WOW64%7Ea11%253Dtrue%7Ea12%253DWin32%7Ea13%253Dna%7Ea14%253DMozilla%252F5.0%2520%28Windows%2520NT%25206.1%253B%2520WOW64%253B%2520rv%253A18.0%29%2520Gecko%252F20100101%2520Firefox%252F18.0%7Ea15%253Dfalse%7Ea16%253Den-US%7Ea17%253Dna%7Ea18%253Dsignin.ebay.com%7Ea19%253Dna%7Ea20%253Dna%7Ea21%253Dna%7Ea22%253Dna%7Ea23%253D1366%7Ea24%253D768%7Ea25%253D24%7Ea26%253D738%7Ea27%253Dna%7Ea28%253DFri%2520Jan%252025%25202013%252022%253A20%253A09%2520GMT%252B0530%2520%28India%2520Standard%2520Time%29%7Ea29%253D5.5%7Ea30%253Dpdf%257Cpdf%257Cpdf%257C%7Ea31%253Dyes%7Ea32%253Dna%7Ea33%253Dna%7Ea34%253Dno%7Ea35%253Dno%7Ea36%253Dyes%7Ea37%253Dno%7Ea38%253Donline%7Ea39%253Dno%7Ea40%253DWindows%2520NT%25206.1%253B%2520WOW64%7Ea41%253Dno%7Ea42%253Dno%7Ea43%253D&UsingSSL=1&inputversion=2&lse=true&lsv=11.5.502&mid=AQAAAThpCRHvAAUxMzg5OTM0YzA2MS5hNWFiODMyLjJmNDcyLmZmZTlhOWUwEZMPFiRFo7yUjykHfCAFgp%2Bk9%2Bk*&kgver=1&kgupg=1&kgstate=r&omid=&hmid=&rhr=f&siteid=0&co_partnerId=2&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&rtmData=&bUrlPrfx={0}&rqid={1}&kgct=&userid={2}&pass={3}&keepMeSignInOption=1&sgnBt=Sign+in&htmid={4}&kdata=%251E%251F%2510%251E1359132609409%251E1%251F%2510%251E1359132609409%251E0%251F%2510%251E1359132609410%251E1%251F%2510%251E1359132609410%251E0%251F%251B%251E1359132612808%251E1%251F%2510%251E1359132612837%251E1%251F%2510%251E1359132612838%251E0%251F%251B%251E1359132612977%251E0%251F", bUrlPrfx, rqid, user, pass, midParamValue);
responseData =
http.UploadString("https://signin.ebay.com/ws/eBayISAPI.dll?co_partnerId=2&siteid=0&UsingSSL=1", pdata);
richTextBox1.Text = responseData;
PrintAllCookies(cookieJar);
}
private void PrintAllCookies(CookieContainer cookies)
{
Hashtable table = (Hashtable)cookies.GetType().InvokeMember("m_domainTable",
BindingFlags.NonPublic |
BindingFlags.GetField |
BindingFlags.Instance,
null,
cookies,
new object[] { });
foreach (string key in table.Keys)
{
foreach (Cookie cookie in cookies.GetCookies(new Uri(string.Format("http://{0}/", key.StartsWith(".", StringComparison.Ordinal) ? "www" + key : key))))
{
richTextBox1.AppendText("Name = " + cookie.Name.ToString() + " Value = " + cookie.Value.ToString() + "Domain = " + cookie.Domain.ToString() + "\n\n");
}
}
}
public string ParseMid(string text, string firstString, string lastString)
{
string str = text;
int pos1 = str.IndexOf(firstString, StringComparison.Ordinal) + firstString.Length;
int pos2 = str.IndexOf(lastString, pos1 + 1, StringComparison.Ordinal);
string finalString = str.Substring(pos1, pos2 - pos1);
return finalString;
}
public class HTTP : WebClient
{
public HTTP()
: this(new CookieContainer())
{ }
public HTTP(CookieContainer c)
{
CookieContainer = c;
}
public CookieContainer CookieContainer { get; set; }
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
var castRequest = request as HttpWebRequest;
if (castRequest != null)
{
castRequest.CookieContainer = CookieContainer;
castRequest.ServicePoint.Expect100Continue = false;
castRequest.ContentType = "application/x-www-form-urlencoded";
//castRequest.AllowAutoRedirect = true;
castRequest.Headers.Add("Cache-Control", "max-age=0");
castRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
castRequest.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
//castRequest.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
castRequest.Headers.Add("Accept-Language", "en-US,en;q=0.8");
castRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17";
castRequest.Headers.Add("Origin", "https://signin.ebay.com");
castRequest.Referer = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn";
castRequest.KeepAlive = true;
castRequest.Host = "signin.ebay.com";
}
return request;
}
}
}
}
i added some more headers, the packet looks similar to a normal login packet, but still erroring at either lucky9 or a url redirect? I'm not sure about troubleshooting this further.. i've attempted to modify the url with the &ru=http%3A%2F%2Fmy.ebay.com%2Fws%2FeBayISAPI.dll%3FMyEbayBeta%26MyeBay%3D%26guest%3D1&pageType=3984 header, but it accomplished nothing. Someone else will have to help with the final step.
<script type="text/javascript" src="https://secureir.ebaystatic.com/v4js/z/i5/r32gctn0fu3vjkpge2mjhij3q.js#SYS-ZAM_vjo_e809_1_Ear_en_US"></script>
<script type="text/javascript">vjo.dsf.error.ErrorHandlerManager.register(new vjo.dsf.error.DefaultErrorHandler());
vjo.dsf.error.ErrorHandlerManager.enableOnError(true, false);
vjo.dsf.cookie.VjCookieJar.sCookieDomain = '.ebay.com';vjo.dsf.cookie.VjCookieJar.writeCookielet('ebay','js','1');
</script>
<script language="JavaScript">window.location="http://my.ebay.com/ws/eBayISAPI.dll?MyEbayBeta&MyeBay=&guest=1"</script>
<div class="pagewidth">
<div class="pageminwidth">
<div class="pagelayout">
<div class="pagecontainer">
<div class="GlobalNavigation" id="GlobalNavigation"><div><script type="text/javascript">var _GlobalNavHeaderUtf8Encoding=true,includeHost='https://secureinclude.ebaystatic.com/';</script>
<div class="CentralArea" id="CentralArea"><div> <form name="AlertSuppressor" method="post"><input type="hidden" name="hidUrl" value="http://my.ebay.com/ws/eBayISAPI.dll?MyEbayBeta&MyeBay=&guest=1"></form> <noscript><meta http-equiv="Refresh" content="0; url = http://my.ebay.com/ws/eBayISAPI.dll?MyEbayBeta&MyeBay=&guest=1"></noscript>
<b>If you are seeing this page, your browser settings prevent you from automatically redirecting to a new URL.</b></td></tr></table>
<div class="buttonDiv_space">Continue
<div class="SupportiveNavigation" id="SupportiveNavigation">
<script type="text/javascript">vjo.dsf.cookie.VjCookieJar.writeCookieEx("lucky9", "8067469", 730);
</script>
Name = ebay Value = ###
Name = dp1 Value = ###
Name = cssg Value = ###
Name = s Value = ###
Name = nonsession Value = ###
Name = cid Value = ###
Name = ds1 Value = ###
Name = ns1 Value = ###
Name = secses Value = ###
Name = shs Value = ###