Actuellement je bloque car, 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 l'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 :



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

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 
<!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>