Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in receiving the token #1

Open
IGNATOV93 opened this issue Jan 26, 2024 · 6 comments
Open

error in receiving the token #1

IGNATOV93 opened this issue Jan 26, 2024 · 6 comments
Labels
question Further information is requested

Comments

@IGNATOV93
Copy link

When requesting a token, it is simply not in the response.Has the authorization address changed? or have you closed a loophole for third-party authorization?

@sachinsenal0x64
Copy link
Owner

Hey, I will check this problem asp

@IGNATOV93
Copy link
Author

hi, is it also not possible to do authorization? Maybe there are some thoughts?

@sachinsenal0x64
Copy link
Owner

sachinsenal0x64 commented Jan 30, 2024

When requesting a token, it is simply not in the response.Has the authorization address changed? or have you closed a loophole for third-party authorization?

Hey, it's still working. They use sessions, where the cookie contains the token. Just pass the cookie itself, remember “success 1” mean you're authenticated. :)

image

image

@sachinsenal0x64
Copy link
Owner

@sachinsenal0x64 sachinsenal0x64 added the question Further information is requested label Jan 30, 2024
@IGNATOV93
Copy link
Author

as a result, the token is not issued anyway ,However, I write in c# static public async Task L(string email, string password)
{
var url = "https://dash.sonicbit.net/login";
var httpClient = new HttpClient();
var htmlContent = await httpClient.GetStringAsync(url);

    var htmlDocument = new HtmlDocument();
    htmlDocument.LoadHtml(htmlContent);

    var csrfTokenNode = htmlDocument.DocumentNode.SelectSingleNode("//meta[@name='csrf-token']");
    if (csrfTokenNode == null)
    {
        Console.WriteLine("CSRF token not found");
        return;
    }
    var csrfToken = csrfTokenNode.GetAttributeValue("content", string.Empty);
    Console.WriteLine(csrfToken);

    var headers = new Dictionary<string, string>

{
{"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37"}
};

    var loginData = new Dictionary<string, string>

{
{"_token", csrfToken},
{"_method", "POST"},
{"email", email},
{"password", password},
};

    var loginEndpoint = "https://dash.sonicbit.net/login_user";
    var initialResponse = await httpClient.GetAsync(url);
    if (!initialResponse.Headers.Contains("Set-Cookie"))
    {
        Console.WriteLine("No cookies found in the response");
        return;
    }
    var cookieContainer = new CookieContainer();
    using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
    using (var client = new HttpClient(handler) { BaseAddress = new Uri(url) })
    {
        foreach (var cookie in initialResponse.Headers.GetValues("Set-Cookie"))
        {
            cookieContainer.SetCookies(new Uri(url), cookie);
        }

        client.DefaultRequestHeaders.Clear();
        foreach (var header in headers)
        {
            client.DefaultRequestHeaders.Add(header.Key, header.Value);
        }

        var response = await client.PostAsync(loginEndpoint, new FormUrlEncodedContent(loginData));
        var responseContent = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseContent);

        var cookies = cookieContainer.GetCookies(new Uri(url));
        foreach (Cookie cookie in cookies)
        {
            Console.WriteLine($"{cookie.Name}: {cookie.Value}");
        }
    }

}                                                                         

@sachinsenal0x64
Copy link
Owner

Really Weird Issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants