Login bot

03/10/2017 14:17 ssamko#1
Hello guys,
I want to do login script to Dark Orbit(they have changed web to https). So what I want are 2 things
1) Log in script (with name+password) -> post+get
2) Log in script just with session -> get+cookies

I know how requests work and right now I work on the 2nd solution but after adding cookies to that request it seems that it ignores them.(for http it works)
I am hopeless. I was able to do this Session login for ssl in php and python, but in C# it doesnt work, and I have no idea why. Do you have some kind of solution or tip ?

Thnx for your help.

PS: 100 EG to person who will succesfully help me with both types of login throught http requests(I dont want browser-object login) :D

My main code:
Code:
//string name = "jasomdarkorbit";
        //string pass = "123456";
        const string URL = "https://www.darkorbit.com";

        string html = "";
        string url = URL + "/indexInternal.es?action=internalStart";

        //For getting fresh session for this request go to darkorbit.com log in with: name=jasomdarkorbit, password=123456.
        string cookies = "dosid=63660eb0d3b6fdc9dcc868c19cf3bf96;";

        html = GET(url, cookies);
        Debug.WriteLine(html);
My get method code:
Code:
public static string GET(string url, string cookie = null)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
        request.Headers.Set(HttpRequestHeader.Cookie, cookie);

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        Stream responseStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(responseStream);

        string result = reader.ReadToEnd();

        responseStream.Close();
        reader.Close();
        response.Close();

        return result;
    }
03/10/2017 17:49 ecks de#2
Try to initialize a Cookie Container like this:
Code:
CookieContainer einkeks = new CookieContainer();
pass it to the WebRequest like this:
Code:
request.CookieContainer = einkeks;
and then get the response stream.

or do it with selenium XD
03/10/2017 18:00 ssamko#3
Quote:
Originally Posted by Uncle Tom View Post
Try to initialize a Cookie Container like this:
Code:
CookieContainer einkeks = new CookieContainer();
pass it to the WebRequest like this:
Code:
request.CookieContainer = einkeks;
and then get the response stream.

or do it with selenium XD
you mean this ? (doesnt work)
Code:
            CookieContainer einkeks = new CookieContainer();
            request.CookieContainer = einkeks;
            request.CookieContainer.Add(new Uri("https://darkorbit.com"), new Cookie("dosid", "4ad14a3d9de4a91508d8c4ca67a32215"));
I am gonna check that selenium

EDIT: I dont wanna GET cookies from response but SET them in request
03/30/2017 11:20 #Saiirex#4
How are you getting the first cookies?

I think you have to save them in a cookiecontainer and use it later.
03/30/2017 16:46 Ludder231#5
check this out(not mine)