You are not logged in.
I'm trying to use curl to login to my campus wireless without messing with browser(I need to go to some random webpage, then got redirected, confirm the certificates, and finally enter my login and password) which is quite annoying.
But when i try to do the same with curl i get the following:
$ curl -Lk anywebsite.com -F "UserName=123456&Password=414124&button=Login"
curl: (52) Empty reply from server
Here's the source of authorisation page (translated) which I got with `curl -Lk anywebsite.com`
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MIPT WiFi Network</title>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<SCRIPT LANGUAGE="JavaScript">
var blur = 0;
var starttime = new Date();
var startclock = starttime.getTime();
var mytimeleft = 0;
function doTime() {
window.setTimeout( "doTime()", 1000 );
t = new Date();
time = Math.round((t.getTime() - starttime.getTime())/1000);
if (mytimeleft) {
time = mytimeleft - time;
if (time <= 0) {
window.location = "?res=popup3&uamip=10.55.84.1&uamport=80";
}
}
if (time < 0) time = 0;
hours = (time - (time % 3600)) / 3600;
time = time - (hours * 3600);
mins = (time - (time % 60)) / 60;
secs = time - (mins * 60);
if (hours < 10) hours = "0" + hours;
if (mins < 10) mins = "0" + mins;
if (secs < 10) secs = "0" + secs;
title = "Online time: " + hours + ":" + mins + ":" + secs;
if (mytimeleft) {
title = "Remaining time: " + hours + ":" + mins + ":" + secs;
}
if(document.all || document.getElementById){
document.title = title;
}
else {
self.status = title;
}
}
function popUp(URL) {
if (self.name != "chillispot_popup") {
chillispot_popup = window.open(URL, 'chillispot_popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=375');
}
}
function doOnLoad(result, URL, userurl, redirurl, timeleft) {
if (timeleft) {
mytimeleft = timeleft;
}
if ((result == 1) && (self.name == "chillispot_popup")) {
doTime();
}
if ((result == 1) && (self.name != "chillispot_popup")) {
chillispot_popup = window.open(URL, 'chillispot_popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=375');
}
if ((result == 2) || result == 5) {
document.form1.UserName.focus()
}
if ((result == 2) && (self.name != "chillispot_popup")) {
chillispot_popup = window.open('', 'chillispot_popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=200');
chillispot_popup.close();
}
if ((result == 12) && (self.name == "chillispot_popup")) {
doTime();
if (redirurl) {
opener.location = redirurl;
}
else if (userurl) {
opener.location = userurl;
}
else if (opener.home) {
opener.home();
}
else {
opener.location = "about:home";
}
self.focus();
blur = 0;
}
if ((result == 13) && (self.name == "chillispot_popup")) {
self.focus();
blur = 1;
}
}
function doOnBlur(result) {
if ((result == 12) && (self.name == "chillispot_popup")) {
if (blur == 0) {
blur = 1;
self.focus();
}
}
}
</script>
</head>
<body onLoad="javascript:doOnLoad(5, '?res=popup2&uamip=10.55.84.1&uamport=80&userurl=http%3a%2f%2f10.55.84.1%2f&redirurl=&timeleft=','http://10.55.84.1/', '', '')" onBlur = "javascript:doOnBlur(5)" bgColor = '#c0d8f4'>
<h1 style="text-align: center;">Enter to the network</h1>
<form name="form1" method="post" action="">
<INPUT TYPE="hidden" NAME="challenge" VALUE="bc71e0cfa4a5207b2be2840c10b8d2c9">
<INPUT TYPE="hidden" NAME="uamip" VALUE="10.55.84.1">
<INPUT TYPE="hidden" NAME="uamport" VALUE="80">
<INPUT TYPE="hidden" NAME="userurl" VALUE="http://10.55.84.1/">
<center>
<table border="0" cellpadding="5" cellspacing="0" style="width: 217px;">
<tbody>
<tr>
<td align="right">Login:</td>
<td><input STYLE="font-family: Arial" type="text" name="UserName" size="20" maxlength="128"></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input STYLE="font-family: Arial" type="password" name="Password" size="20" maxlength="128"></td>
</tr>
<tr>
<td align="center" colspan="2" height="23"><input type="submit" name="button" value="Login" onClick="javascript:popUp('?res=popup1&uamip=10.55.84.1&uamport=80')"></td>
</tr>
</tbody>
</table>
</center>
</form>
</body>
</html>
Where did go wrong?
Offline
I only glanced over it, but it looks like you just need to add the hidden fields to your post variables:
<INPUT TYPE="hidden" NAME="challenge" VALUE="bc71e0cfa4a5207b2be2840c10b8d2c9">
<INPUT TYPE="hidden" NAME="uamip" VALUE="10.55.84.1">
<INPUT TYPE="hidden" NAME="uamport" VALUE="80">
<INPUT TYPE="hidden" NAME="userurl" VALUE="http://10.55.84.1/">
The "challenge" might be a problem if you want to automate this. I would write a Perl script to retrieve the page with curl and ask me for my name and password, then use that to format the next curl command.
Also, double-check that the form is actually posted back to that page (the JavaScript function is filling in the empty 'action' attribute of the html form).
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
well, i retrieved challenge value manually and tried to post everything but still the same error.
Also, double-check that the form is actually posted back to that page (the JavaScript function is filling in the empty 'action' attribute of the html form).
How can i do that?
Offline
Follow the JavaScript
The form submit button is connected by "onClick" to the "popup" function. That function opens a popup window if the window isn't named "chillispot_popup", etc.
From what I can tell, the form is posted to that page (the one you posted), but because the web designer has an apparent fetish for JavaScript and stupid popups it might just not be possible to do everything with curl.
I did notice that you're using "-F" for the form data. Try "-d" instead. The former is for multipart data (e.g. post data and file uploads), the latter for regular form data.
Also, if the IP of that site isn't 10.55.84.1, try replacing the URL in the curl line with "http://10.55.84.1" which seems to be a target page.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
web designer has an apparent fetish for JavaScript and stupid popups it might just not be possible to do everything with curl
well I was prepared I'd finally have to bug him
Try "-d" instead.
"-F" and "-d" didn't make the difference, still geting the same error.
great thanx, i think the topic's not solved but closed
Offline