"; //echo $p."
"; $f = tempnam('','CS');//http://php.net/manual/en/function.tempnam.php //echo $f."
"; shell_exec("ssh-keyscan -p ".$p." ".$h." > ".$f); $r=shell_exec("ssh-keygen -l -f ".$f." 2>&1"); //http://www.linuxweblog.com/blogs/sandip/20090101/verifying-ssh-key-fingerprint unlink($f); $pieces = explode(" ", $r);//http://php.net/manual/en/function.explode.php if(count($pieces)==4)//http://php.net/manual/en/function.count.php { echo $pieces[1]; } else { echo "ERROR: Failed to get fingerprint."; } } if(isset($_POST["host"])) { $h=$_POST["host"]; $h_length=strlen($h); if(($h_length>=1)&&($h_length<=1024)) { if(DoesItHaveInvalidChar($h)) { echo "ERROR: Host contains invalid character."; } elseif(substr($h,0,1)=="-")//http://php.net/manual/en/control-structures.elseif.php //http://php.net/manual/en/function.substr.php { echo "ERROR: The first character of host is \"-\"."; } else { $p = 22; if(isset($_POST["port"])) { if(intval($_POST["port"])>0)//http://php.net/manual/en/function.intval.php { $p = intval($_POST["port"]); } } ExecuteCommand($h,$p); } } else echo "ERROR: String length of host is not between 1 and 1024."; } else echo "ERROR: Host is not set."; ?>
Home