tags:

views:

44

answers:

3

Or is it possible?

+2  A: 

Pretty much you would have to write a port scanner in PHP.

KramerC
How to do it in php?
Google for it. There are plenty of port scanners, if not in PHP, there will be in C. The code won't be that hard to convert to PHP
AntonioCS
+2  A: 

look at http://www.phpclasses.org/browse/package/1581.html

the file is :

<?php 
//Author: Sean Burke 
//Version: 1.0 
//This Class aids in determining the status of ports and also what service they are. 
//To contribute to the port listing email your lists  to [email protected] 
class portscan { 
    var $port, 
    $host, 
    $action, 
    $result, 
    $pname, 
    $plist, 
    $sresult, 
    $hlist; 
    function status() { 
        $sc=socket_create (AF_INET, SOCK_STREAM, getprotobyname("TCP")); 
        if (@socket_connect($sc,$this->host,$this->port)) { 
            $this->result="open\n"; 
        } 
        else { 
            $this->result="closed\n"; 
        } 
    } 
    function name() { 
        $fp=fopen('ports.txt','r'); 
        $temp=fread($fp,filesize('ports.txt')); 
        fclose($fp); 
        $temp=explode("\n",$temp); 
        for($a=0;$a<sizeof($temp);$a++) { 
            $temp2=explode("||",$temp[$a]); 
            if ($this->port==$temp2[0]) { 
                    $this->pname=$temp2[1]; 
                    $found==1; 
            } 
        } 
        if ($found==NULL) { 
            $this->pname=="NA"; 
        } 
    } 
    function scan($sfile) { 
        if(is_file($sfile)) { 
            $fp=fopen($sfile,'r'); 
            $file=$sfile; 
        } 
        else { 
            $fp=fopen('ports.txt','r'); 
            $file='ports.txt'; 
        } 
        $temp=fread($fp,filesize($file)); 
        fclose($fp); 
        $temp=explode("\n",$temp); 
        for($a=0;$a<sizeof($temp);$a++) { 
            $temp2=explode("||",$temp[$a]); 
            if($temp2[0]!=NULL) { 
                $this->port=$temp2[0]; 
                $this->status(); 
                $this->name(); 
                $this->sresult[$a]=$this->port."||".$this->result."||".$this->pname; 
            } 
        } 
    } 

} 
$scan=new portscan; 
$scan->port=80; 
$scan->host="lcnhosting.com"; 
$scan->status(); 
$scan->name(); 
print "PORT: ".$scan->port.": ".$scan->result." SERVICE: ".$scan->pname."\n";  
$scan->scan(NULL); 
print sizeof($scan->sresult)."\n"; 
for($a=0;$a<sizeof($scan->sresult);$a++) { 
    print $scan->sresult[$a]."\n"; 
} 
?> 
Haim Evgi
Call to undefined function socket_create()
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.
Haim Evgi
http://il2.php.net/manual/en/sockets.installation.php
Haim Evgi
What's in ports.txt?
look in the link i post ,the file contain :80||HTTPd21||FTPd22||SSH23||Telnet513||Rlogin25||SMTP143||IMAP110||POP33306||MySQL53||Named6666||IRCd6667||IRCd6668||IRCd6669||IRCd7000||IRCd
Haim Evgi
No,it requires signup to see the contents.
i suggest to signup is free
Haim Evgi
+1  A: 

exec nmap and parse the result

jspcal