Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

cURL problems


ghost's Avatar
0 0

I can't return output from a site over https. I can't figure out what's wrong. Any help is appreciated. There are no errors:

set_time_limit(0);
$username = $_POST['username'];
$password = $_POST['password'];
$fname    = $_POST['fname'];
$lname    = $_POST['lname'];
if (isset($username) && isset($password)) {
	$fp = fopen("cookies.txt", "w");
	fclose($fp);
	$url = "https://www.site.com/login.aspx?VAM_Group=&__VIEWSTATE=dDwtNjY0NzAwNDE5O3Q8O2w8aTwxPjs%2BO2w8dDxwPGw8b25yZXNldDs%2BO2w8aWYgKHdpbmRvdy5zZXRUaW1lb3V0KSB3aW5kb3cuc2V0VGltZW91dCgnVkFNX09uUmVzZXQoZmFsc2UpXDsnLCAxMDApXDs7Pj47Oz47Pj47bDxjaGtSZW1lbWJlcjs%2BPu%2Bc0tMGmVCGFJavhbpxz5OxbyDe&Username=$username&Password=$password&btnLogin=Login&chkRemember=on";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_USERAGENT, "cURL UAT VooDoo script V.1");
	curl_setopt($ch, CURLOPT_REFERER, "https://www.site.com/");
	curl_setopt($ch, CURLOPT_HEADER, 1);
	curl_setopt($ch, CURLOPT_COOKIEJAR, $fp);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $fp);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
	$output = curl_exec($ch);
	curl_close($ch);
	echo $output;
}
?>
<html>
<head>
<title>User Information Lookup (UAT DB)</title>
</head>
<body>
<center>
<h1>User Information Lookup</h1>
<i>Be careful when using this piece of software.  I take no responsability for misuse of this code.</i>
</center>
<br><br>
<b>Your Information</b>
<br>*note - Be careful when logging in.  Your login info gets sent when getting the information.  Remember to be safe...
<pre>
<form method="POST" action="<?php $SERVER['php_self'];?>">
Username: <input type="text" name="username" value="">
Password: <input type="password" name="password" value="">
<input type="submit" value="login">
</form>
</pre>
<br>
<b>Lookup Information</b>
<br><i>You only need one field, but remember, multiple results may return.</i>
<pre>
<form method="POST" action="<?php $SERVER['php_self'];?>">
First Name: <input type="text" name="fname" value="">
Last Name:  <input type="text" name="lname" value="">
<input type="submit">
</form>
</pre>
</body>
</html>```

ghost's Avatar
0 0

Have you tried a var_dump of $output? Also, curl_error and curl_errno might provide some insight, if it's failing.


ghost's Avatar
0 0

CURLE_SSL_CONNECT_ERROR (35)

Which is what i figured, it's my script not being able to appropriately communicate over https. I can't figure out how to do that. I must be missing some needed option.


ghost's Avatar
0 0

F*CK, i know the problem. Thanks anyways Zephyre. :happy:


ghost's Avatar
0 0

So, what was the problem? I'm dying to know! ;)


ghost's Avatar
0 0

Man, it's so emberassing. The problem was there is no www in the url nameā€¦ :angry:


ghost's Avatar
0 0

Well, we've all been there. I was kinda hoping it was something to do with PHP, since I have no experience with cURL whatsoever. Anyways, congrats on finding the error. :)