Powershell: Login with Invoke-WebRequest to a website fails

89 views Asked by At

im trying to Login to a website with Powershell. It always fails with 403 code.

$LoginUri = "https://xxxx.netstock.co/session/new"
$LoginResp = Invoke-WebRequest -Uri $LoginUri -SessionVariable "Session"
$LoginBody = @{
    authenticity_token = $LoginResponse.InputFields[1].value
    login = "hereisthelogin"
    password = "hereisthepassword"
    submit = "Log in"
}

$LoginResp = Invoke-WebRequest -Uri $LoginUri -WebSession $Session -Body $LoginBody -Method "POST"

Result: Invoke-WebRequest : Der Remoteserver hat einen Fehler zurückgegeben: (403) Unzulässig.

Does anyone have an idea why? Is there anything "non standard" on this website?

1

There are 1 answers

2
groophy lifefor On

sites do not look very favorably on automated account opening, so they may put some obstacles of their own, these return the 403 code, that is, it is not related to powershell, it will give the same error in any request, I guess I think it returns 403 due to the cors system.