Exemple d'utilisation

Cet exemple active l'identification du système d'exploitation de la machine cible.


#!/usr/bin/perl -W
use strict;
use Nmap::Scanner;

my $scan = new Nmap::Scanner;
$scan->add_target('jupiter');
$scan->guess_os;

my $results = $scan->scan;
print $results->as_xml;

Exécuté, le programme affiche la sortie au format XML.


<?xml version="1.0"?>
<results>
  <hosts>
   <host name="jupiter" status="up">
    <address address="192.168.1.2" type="ipv4"/>
    <osguess>
    <port-used state=""  protocol=""  port-id="" />

    <match name="Apple Mac OS X 10.1 - 10.1.4"  accuracy="100" />

    <match name="Apple Mac OS X 10.1.5-10.2.6"  accuracy="100" />

    <uptime seconds=""  last-boot="" />

    <tcp-sequence index="9999999"  class="truly random"  difficulty="Good luck!"  values="77845BAD,1F86F4B1,FDB43F17,CEA19358,4C613B93,188F61B3" />

    <tcp-ts-sequence class="2HZ"  values="A026E196,A026E197,A026E197,A026E197,A026E197,A026E198" />

    <ip-id-sequence class="Incremental"  values="9BD6,9BD7,9BD8,9BD9,9BDA,9BDB" />

</osguess>

    <ports>
    <tcp>
      <port number="21" owner="" protocol="tcp" state="open" ><service name="ftp" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="22" owner="" protocol="tcp" state="open" ><service name="ssh" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="25" owner="" protocol="tcp" state="open" ><service name="smtp" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="80" owner="" protocol="tcp" state="open" ><service name="http" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="139" owner="" protocol="tcp" state="open" ><service name="netbios-ssn" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="427" owner="" protocol="tcp" state="open" ><service name="svrloc" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="548" owner="" protocol="tcp" state="open" ><service name="afpovertcp" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>
      <port number="587" owner="" protocol="tcp" state="open" ><service name="submission" proto="" rpcnum="" lowver="" highver="" method="table" conf="3" /></port>

    </tcp>
    <udp>

    </udp>
    <ip>

    </ip>
    <extraports state="closed" count="1636" />
  </ports>
  </host>
  </hosts>

</results>


Journées Perl 2004 29 / 32