Accessing via Curl

Asked

Viewed 124 times

1

I have the following challenge:

Log in to a website with the following data:

POST */kodoreq.php HTTP/1.1
Host: eofclub.in
Cookie: logado=sim
User-Agent: Lynx/3.15

usuario=desafio&senha=987654321&submit=sim

I’ve tried it in many ways and I can’t

class Program
{
    static void Main(string[] args)
    {


        string usuario = "desafio";
        string senha = "987654321";
        string submit = "sim";
        System.Net.ServicePointManager.Expect100Continue = false;

        Uri url = new Uri("http://eofclub.in/desafio/kodo/35p42s5436po63nnsr9o20rssp6647q3/kodoreq.php");
        UTF8Encoding encoding = new UTF8Encoding();
        string postData = "{ \"usuario\" : \"" + usuario + "\", \"senha\": \"" + senha + "\", \"submit\": \"" + submit + "\"}";


        byte[] data = Encoding.GetEncoding("UTF-8").GetBytes(postData);

        CookieContainer cookieContainer = new CookieContainer();
        Cookie usuarioCookie = new Cookie("logado", "sim", "/") { Domain = url.Host };
        cookieContainer.Add(usuarioCookie);

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);            
        request.CookieContainer = cookieContainer;
        request.Method = "POST";
        request.ContentType = "application/json";            
        request.UserAgent = "Lynx/3.15";
        request.ContentLength = data.Length;


        Stream stream = request.GetRequestStream();
        stream.Write(data, 0, data.Length);
        stream.Close();

        WebResponse response = request.GetResponse();
        stream = response.GetResponseStream();


        StreamReader sr = new StreamReader(stream);
        Console.WriteLine(sr.ReadToEnd());

        sr.Close();
        stream.Close();

        Console.ReadKey();
    }
  • But you can’t because specifically?

  • Btw, do not use code snnipets for C#code. They are only for client-side code.

  • It always displays the error "invalid".

  • The idea of the challenge is to get to the result... here is the answer, you will find out how to get it or follow from that point... proximo lvl .. /o9ps9p2ro0n89r3n4o958rr7o7o01r9r/

  • Thanks, but anyway I’ll keep trying, thanks for the help @Leandroangelo

1 answer

0


You did not enter the Header User-Agent:. Secretly it seems that the server is also waiting for the format application/x-www-form-urlencoded.

I also advise to use the HttpClient which is the latest form of making requests HTTP.

Your code would look like this:

request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Lynx/3.15";

It’s like a challenge HttpClient

  • I tried that way, but couldn’t, updated the code and anyway I’ll try with httpclient too

  • Being able to do it this way, I started with httpClient to learn

Browser other questions tagged

You are not signed in. Login or sign up in order to post.