Hi !
Denkt ihr, das meine kleine funktion hier sicher ist? geht um die frage ob ein angreifer evtl code über das whois programm was ja auf dem server ausgeführt wird einschleusen könnte.
Gruss
ichi
	
							
						
					Denkt ihr, das meine kleine funktion hier sicher ist? geht um die frage ob ein angreifer evtl code über das whois programm was ja auf dem server ausgeführt wird einschleusen könnte.
Gruss
ichi
PHP-Code:
	
	
<?PHP
// example
echo domaintype($_GET['domain']);
function domaintype($domain) {
    // returns domain type
    // 0  = already registred
    // 1  = .de domain (free)
    // 2  = .c/n/o domain (free)
    // 3  = .info domain (free)
    // 4  = .biz domain (free)
    // 99 = invalid domain
    
    // cut everything before the first "."
    $domain = strtolower($domain);
    preg_match( "/\..*/", $domain, $array );
    if ($array[0] == ".de" or $array[0] == ".com" or $array[0] == ".net" or $array[0] == ".org" or $array[0] == ".info" or $array[0] == ".biz"){ $result = "0"; }
    else {$result = 99;}
    
    // check if domain contains 3-63x "a-z,0-9,-" followed by an . followed by 2-4x "a-z"
    preg_match( "/[0-9,a-z,A-Z,\-]{3,63}\.[a-z,A-Z]{2,4}/", $domain, $array );
    if ($array[0] != $domain){$result = 99;}
    
    if ($result != 99){
        $command = "whois ".$domain;
        $proc = popen("($command)2>&1","r");
           while (!feof($proc)) $c .= fgets($proc, 1000);
        pclose($proc);
        
        // .de
        if ( strstr($c, "free") ) {$result = 1;}
        // .cno
        elseif ( strstr($c, "No match") ) {$result = 2;}
        // .info
        elseif ( strstr($c, "NOT FOUND") ) {$result = 3;}
        // .biz
        elseif ( strstr($c, "Not found:") ) {$result = 4;}
        // invalid
        elseif ( strstr($c, "invalid") ) {$result = 99;}
        // registred
        else {$result = 0;}
    }
    
    return $result;
}
?>
 
          
Kommentar