mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hey everybody!
I was asked to make a script.. but before i extract the info i want to from the website i need to login by filling the usual username password html form...
With assistance from here i managed to get some kind of result but.. not what i expected.
I get either 302 Found or Error 403
this is the URL and this:
Code:
ON *:SOCKOPEN:soul: {
  sockwrite -n $sockname POST /forum/index.php/board,361.0.html HTTP/1.1
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: 21
  sockwrite -n $sockname host: soulriders.net
  sockwrite -n $sockname
  sockwrite -n $sockname user=OrFeAsGr&passwrd=blablabla5&cookielength=60
}

ON *:SOCKREAD:soul: {
  var %s
  sockread %s
  echo -at %s
  if (*OrFeAsGr* iswm %s) {
    echo -at 4 %s
  }
}

is my so far code. The forms that need to be filled are:
Html:
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">1 Hour</option>
<option value="1440">1 Day</option>
<option value="10080">1 Week</option>
<option value="43200">1 Month</option>
<option value="-1" selected="selected">Forever</option>

What am i doing wrong?
Thanks for any help in advance!
-OrFeAsGr-

Last edited by OrFeAsGr; 03/06/16 12:15 AM.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
302 Found is a redirection response, it likely means the login attempt worked and the website is redirecting you to the next page. You should follow the redirection by making a request to the URL provide by the Location header.

A 403 response is an authorization issue, which likely means the password was wrong.

Both responses are expected in their respective scenarios.

The tl;dr of this is that there's much more to logging into a website than submitting a single form. Your script has to handle redirects and cookies the way a regular web browser would be expected to.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Thx for the help :)) Much appreciated!


Link Copied to Clipboard