souci avec mon code php besoin d'aide

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : souci avec mon code php besoin d'aide

Re: souci avec mon code php besoin d'aide

par moogli » 03 oct. 2014, 17:13

bonjour,

Merci d'utiliser la balise bbcode adéquate (php en l'occurence).

je t'ai déjà répondu sur developpez.com ma réponse ne t'as pas plus ?

@+

souci avec mon code php besoin d'aide

par sardinettejojo » 02 oct. 2014, 18:52

Actuellement je bloque car j'aimerais que quand je tape dans un champs l'URL , j'aimerais que le hostname et le hostip associer au champs soit affiche sur la page et procède tout de même au scan des port :

exemple quand je met google ou toto.fr j'aimerais que l'ip de ce domaine ainsi que le reste soit associer par rapport a url que je pourrais taper dans le champs url car la je rentre url de mon site le code fonctionne sans aucun problème les port ouvert s'affiche.

mais que cela puisse fonctionner individuellement aussi .

voilà un aperçu en image je ne sais pas si vous comprenez ou je veut en venir :

Image

j'aimerais perfectionner le script

avec les paramètres suivant

- Les port Ouvert ou pas ouvert (chose faite)
- Le type de serveur derrière apache ou autre (avec ça version)
- l'ip du domaine ainsi que ces adresse dns et un trace route du domaine
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scanner</title>
<link href="style.css" rel=stylesheet type="text/css">
</head>
<body> 
<br/>
<div id="conteneur">
<br/>
<div id="header">
Scanner de Port
</div>
<table id="tableau">

<?php 
// Récupération du nom depuis l'adresse IP
$hostname = gethostbyaddr("8.8.8.8");

// Récupération de l'adresse ip depuis le nom
$hostip = gethostbyname("www.google.fr");


$hostname = $_POST["hostname"];
$hostip = $_POST["hostip"];

echo '<tr>';
echo '<td class="text_tableau_resultat">'.$hostname.'</td>';
echo '<td class="text_tableau_resultat">'.$hostip.'</td>';
echo '</tr>';
echo '</br>';
echo '</br>';


// Ping avec commande du système (Pour Linux, à adapter si le système est différent)
function ping($host)
{
// exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
return $rval === 0;
}
if (ping("8.8.4.4")) {
echo '<tr>';
echo '<br/><br/><td>Liaison OK</td>';
echo '<td> </td>';
echo '</tr>';
echo '<br/>';
echo '<br/>';
} 
else 
{
echo '<tr>';
echo '<td>Liaison KO<br/><br/></td>';
echo '<td> </td>';
echo '</tr>';
}

// Scanner de ports
$host = $_POST["adresse"];
$ports = array(21, 22, 23, 25, 53, 80, 110, 1433, 3306);
$results = array();
foreach($ports as $port) {
if($pf = @fsockopen($host, $port, $err, $err_string, 1)) {
$results[$port] = true;
fclose($pf);
} else 
{
$results[$port] = false;
}
}
foreach($results as $port=>$val) {
$prot = getservbyport($port,"tcp");
echo '<tr>';
echo "<td><img src='serveur.png' border='0'> Port $port ($prot):</td>";
if($val) {
echo '<td><span class="text_tableau_resultat"><img src="port-ouvert.png" border="0"> Le port est Ouvert !</span></td>';
}
else
{
echo '<td><span class="text_tableau_resultat2"><img src="port-fermer.png" border="0"> Le port n\'est pas ouvert</span></td>';
echo '</tr>';
}
}
?>
</table>


<br/>

<form method="POST" action="scan-tools.php">
<table id="tableau2">
 <tr>
  <td align="right" width="100" class="text_tableau2"> Hostname :</td>
  <td align="right" width="300"><input name="hostname" type="text"></td>
 </tr>
 <tr>
  <td align="right" width="100" class="text_tableau2"> L'URL / WWW :</td>
  <td align="right" width="300"><input name="adresse" type="text"></td>
 </tr>
 <tr>
  <td align="right" width="100" class="text_tableau2"> Adresse IP:</td>
  <td align="right" width="300"><input name="hostip" type="text"></td>
 </tr>
  <tr>
  <td> </td>
  <td> </td>
 </tr>
 <tr>
  <td align="right" width="100"> </td>
  <td align="right" width="300"><button type="submit">Lancer le Scan !</button></td>
 </tr>
</table>
<br/>
</form>
</div>
<br/>
<div id="footer"><br/></div>
</body> 
</html>