Hi there I know its my first post but I have been struggling with this for way too long.
I am trying to create a script that can pass data to telnet using curl or i should say libcurl I guess.
I can achieve what I am trying to do using sockets but unfortunately the host the script is to go on blocks these sorts of connections using sockets however as yet they haven't blocked curl.
I can get it to connect to the telnet but thats as far as i seem to get using the following
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
function curl_telnet($query,$server,$timeout=10) {
if (!function_exists('curl_init')) {
user_error('"curl_init()" function does not exist.', E_USER_WARNING);
return false;
}
$ch = curl_init($server);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $query);
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$result=curl_telnet("BLAAT",'telnet://*.*.*.*:6402')?'good':'fail';
echo "$result\n";
?>
Ok so basically this will connect to an eggdrop and pass some data to it the script on the eggdrop works fine as i say it works ok using sockets but I cant seem to figure out how to post to the data to the telnet connection using curl.
I have read the information on the curl website and i confess it confused me I'm no php guru and while I sort of understand what the stdin is I have no idea how I would go about writing the data to it so that it can be sent to the telnet server.
The libcurl TELNET support will read data on stdin and pass to the remote
peer, while it will pass incoming network data to the usual internal mumbo
jumbo.
So, to automate telnet with curl, you need:
- set telnet options (if you have any special ideas)
- make a connection to the remote host with 'telnet://hostname'
Then you'll get the data the host sends you the "normal" way, while you need
to somehow pass data to stdin to get them over to the other side.
Anyone that could at least point me in the right direction please ive looked at popen and process_open and again I feel I may be out of my depth with those.