#24785 [Fbk->Opn]: Warning: fsockopen() [function.fsockopen]: php_hostconnect: connect failed
ID: 24785
User updated by: laudanp at yahoo dot com
Reported By: laudanp at yahoo dot com
-Status: Feedback
+Status: Open
Bug Type: Sockets related
Operating System: Redhat 7.3
PHP Version: 4CVS-2003-07-23 (stable)
New Comment:
Good point. Prior to 4.3.x there was no need for "@" as the error
didn't show. After it, but prior to the CVS "fix", using "@" didn't
seem to matter. The error showed itself.
I just added the "@" to the fsockopen line and the Trojan scan works
without the error.
Amazing. So it's now resolved.
Previous Comments:
------------------------------------------------------------------------
[2003-07-24 03:45:33] wez@php.net
Sounds like expected behaviour to me.
Why is this wrong?
If you want to suppress the warning messages generated by PHP, you can
use the @ operator.
------------------------------------------------------------------------
[2003-07-23 21:15:30] laudanp at yahoo dot com
Description:
------------
Please reference: http://bugs.php.net/bug.php?id=21653, as it is the
same for this bug report. I was asked to file a new one. The CVS
codebase I'm using is: php4-STABLE-200307031530.tar.gz. The following
line is where the error occurs in my script:
$handle = fsockopen($this-> targetIP, $index, $errno, $errstr, $this->
timeout);
You may see the script in action here:
http://www.computercops.biz/modules.php?name=TCP_Scanner
or
http://www.computercops.biz/modules.php?name=Trojan_TCP_Scan
I obtain that fsockopen error.
It was stated by wez in the above referenced bug report that he removed
a duplicate error message. I grabbed the latest cvs after that and it
still wasn't working.
Below is the code that I include in a parent PHP script. Its the
"core" though.
Reproduce code:
---------------
<?php
# COPYRIGHT PAUL LAUDANSKI / COMPUTERCOPS.BIZ
$trojans = array("21" => "Nerte 7.8.1",
"23" => "TruvaAti 1.2 beta"
);
flush();
while (list ($portno, $descno) = each ($trojans)) {
flush();
$fp = fsockopen($REMOTE_ADDR, $portno, $errno, $errstr,
1);
if(!$fp) {
echo "Connection Refused: ";
echo "Port $portno used by $descno.";
echo "<BR>";
} else {
echo "<FONT COLOR=red><B>ESTABLISHED
CONNECTION</b>: ";
echo "Possible $descno Trojan found on port
$portno.</FONT>";
echo "<BR>";
$start = time();
socket_set_timeout($fp, 5);
$ccspstrNumberFound++;
fclose($fp);
}
}
?>
Expected result:
----------------
Starting Trojan TCP Scan ...
Connection Refused: Port 21 used by Nerte 7.8.1.
Connection Refused: Port 23 used by TruvaAti 1.2 beta.
etc...
Actual result:
--------------
Starting Trojan TCP Scan ...
Warning: fsockopen(): unable to connect to xxx.xxx.xxx.xxx:21 in
/www/computercops/modules/Trojan_TCP_Scan/ccspTrojans.php on line 137
Connection Refused: Port 21 used by Nerte 7.8.1.
Warning: fsockopen(): unable to connect to xxx.xxx.xxx.xxx:23 in
/www/computercops/modules/Trojan_TCP_Scan/ccspTrojans.php on line 137
Connection Refused: Port 23 used by TruvaAti 1.2 beta.
etc...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24785&edit=1
Thread (5 messages)