Ejemplos
Escanear rango de puertos
Para escanear un rango de puertos en este caso del 1 al 65535 nmap -sS -A -p 1-65535 [Link]
Escanear puertos UDP
Para escanear los puertos UDP (opcin -sU) bien conocidos (opcin por defecto), haremos: nmap -sU -A [Link]
Escaneo haciendo ping
Con la opcin -sP lanzaremos un ping a todas las IPs de la red (ping scan), para saber qu hosts se encuentran activos nmap -sP [Link]/24
Obtener sistema operativo
En este ejemplo agregamos -A que nos manda la salida y agrega el tipo de sistema operativo nmap -A [Link] #o tambien se puede hacer con nmap -sS -O [Link]
Stealth Xmas Tree scan
En el siguiente ejemplo, realizamos un Stealth Xmas Tree scan (-sX) hacia el host [Link], en los puertos 25(SMTP), 53(DNS), le indicamos a nmap que no genere pings hacia el host, y tratamos de engaar al host (-D, Decoy), hacindole creer que los scans se estn generando desde los hosts [Link] y [Link]. nmap -p 25,53 -sX -P0 -D [Link],[Link] [Link]
Guardando los resultados de tus scans.
Nmap permite guardar los resultados de un scan, en varios tipos de formato de archivo: Normal, XML, Grepable, All, y en formato "S" (s| nmap -sX -O [Link] -oN archivo_de_resultados.txt
Bounce Attack.
Para determinar si la victima es vulnerable al "bounce attack" entonces lo utilizamos asi: nmap -b [Link]
Bounce Attack.
Ahora si deseo realizar un scan muy suave para no ser detectado por algun firewall utilizo estas opciones con el -f ya que algunos firewall poseen metodos para detectar este tipo de scan. nmap -sF -f -p 21 23 110 143 [Link]
Opciones Nmap
-h Muestar la ayuda. -sP ping "scan". Este es utilizado solo para saber si determinado(s) host(s) estn en ese momento vivos o conectados, normalmente esto lo realiza nmap enviado paquetes a el puerto 80 de un host pero si este tiene un filtrado de ese puerto podrs ser detectado de todas formas. -sU Es un Scan de Puertos abiertos con protocolo UDP, solo root puede ejecutarlo. -sS Ping oculto, entrega solo la respuesta final para dejar menos registros. -b ftp "bounce attack" utilizado para ver si se puede utilizar un host para pasar una conexin ftp a travs de el y no hacer el ftp a otro host desde tu maquina directamente. -f Utiliza pequeos paquetes fragmentados para el SYN , Xmas , FIN o barrido nulo. -P0 No hace "ping" al host en cuestin , necesario para el scan o "barrido" a sistemas de deteccin de ataques sensibles. -PT Utiliza el Ping de tcp para determinar si un host esta conectado para el caso de -sT y -sP esta opcin aunque no es suministrada va implcita en el mtodo. -PT21 Utiliza el Ping tcp para hacer prueba de conexin a el puerto 21 o a cualquier otro especificado despus del -PT ejm: -PT110 . -PI Utiliza paquetes icmp para determinar que hosts estn conectados y es especial si deseas hacer un scan a travs de un firewall. -PB Hace la misma funcin que el barrido (scan) TCP y ICMP, se le puede especificar un puerto destino despues de la "B". -PS Utiliza el TCP SYN sweep en lugar de el valor por defecto que es el ack sweep utilizado en el Ping TCP. -O Utiliza el TCP/IP "fingerprinting" para determinar que Sistema operativo esta corriendo un host remoto. -p o puertos: ejm: '-p 23' solo intenta hacer conexin con el(los) host(s) en el puerto especificado para extraer de all la informacin necesaria para la operacin de scan. Otros ejemplos '-p 20-100,31330-' hace un barrido entre los puertos 20-30 y entre 31330-65535. por defecto el barrido es entre los puertos 1 y el 1024 mas los que parezcan en el /etc/services. -F Barrido Rpido a "Fast Scan" solo examina los puertos que estn en el /etc/services. -I Toma informacin de quien es el dueo del proceso que se esta ejecutando pero solo se puede ejecutar con el -sT por lo cual deja una traza enorme en el log de la vctima por ello debe evitar utilizar esta opcin. -n no hace conversiones DNS para hacer el -sP mas rapido.
-R Intenta Convertir utilizando DNS (o sea del ip te muestra el hostname ejm: le das [Link] y te muestra que es [Link]). -o guarda el mismo resultado mostrado por pantalla en un archivo en formato entendible para los humanos. -m lo mismo que lo anterior pero la salida es en un formato de maquina. -i Lee las IPs de las vctimas desde un archivo. -g Indica que puerto local se utilizara para enviar los paquetes para el scan. -S Si quieres especificar una IP para que sea la fuente del scan, ideal para hacer "Scan Spoofing" o encubrir tu scan. -v Verbose. Muestra mas Informacin. -V Imprime la versin de nmap y sale. -e . Enviar los paquetes a travs de esta interface en tu host puede ser eth0,ppp0,ppp1 etc.
Manual
Syntax nmap [Scan Type(s)] [Options] {target specification} TARGET SPECIFICATION: -iL -iR --exclude <host1[,host2][,host3],...> --excludefile <exclude_file> HOST DISCOVERY: -sL -sP -P0 -PS/PA/PU [portlist] -PE/PP/PM -n/-R --dns-servers <serv1[,serv2],...> --system-dns SCAN TECHNIQUES: List Scan - simply list targets to scan Ping Scan - go no further than determining if host is online Treat all hosts as online -- skip host discovery TCP SYN/ACK or UDP discovery to given ports ICMP echo, timestamp, and netmask request discovery probes Never do DNS resolution/Always resolve [default: sometimes] Specify custom DNS servers Use OS's DNS resolver Input from list of hosts/networks Choose random targets Exclude hosts/networks Exclude list from file
-sS/sT/sA/sW/sM -sN/sF/sX --scanflags <flags> -sI <zombie host[:probeport]> -sO -b <ftp relay host>
TCP SYN/Connect()/ACK/Window/Maimon scans TCP Null, FIN, and Xmas scans Customize TCP scan flags Idlescan IP protocol scan FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER: -p <port ranges> -F -r SERVICE/VERSION DETECTION: -sV --version-intensity <level> --version-light --version-all --version-trace OS DETECTION: -O --osscan-limit --osscan-guess TIMING AND PERFORMANCE: Options which take <time> are in milliseconds, unless you append 's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m). -T[0-5] --min-hostgroup/max-hostgroup <size> --min-parallelism/max-parallelism <time> Set timing template (higher is faster) Parallel host scan group sizes Probe parallelization Enable OS detection Limit OS detection to promising targets Guess OS more aggressively Probe open ports to determine service/version info Set from 0 (light) to 9 (try all probes) Limit to most likely probes (intensity 2) Try every single probe (intensity 9) Show detailed version scan activity (for debugging) Only scan specified ports Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080 Fast - Scan only the ports listed in the nmap-services file) Scan ports consecutively - don't randomize
--min-rtt-timeout/max-rtttimeout/initial-rtt-timeout <time> --max-retries <tries> --host-timeout <time> --scan-delay/--max-scan-delay <time>
Specifies probe round trip time. Caps number of port scan probe retransmissions. Give up on target after this long Adjust delay between probes
FIREWALL/IDS EVASION AND SPOOFING: -f; --mtu <val> -D <decoy1,decoy2[,ME],...> -S <IP_Address> -e <iface> -g/--source-port <portnum> --data-length <num> --ttl <val> --spoof-mac <mac address/prefix/vendor name> --badsum OUTPUT: -oN/-oX/-oS/-oG <file> -oA <basename> -v -d[level] --packet-trace --iflist --log-errors --append-output --resume <filename> --stylesheet <path/URL> --webxml --no-stylesheet Output scan in normal, XML, s|<rIpt kIddi3, and Grepable format, respectively, to the given filename. Output in the three major formats at once Increase verbosity level (use twice for more effect) Set or increase debugging level (Up to 9 is meaningful) Show all packets sent and received Print host interfaces and routes (for debugging) Log errors/warnings to the normal-format output file Append to rather than clobber specified output files Resume an aborted scan XSL stylesheet to transform XML output to HTML Reference stylesheet from [Link] for more portable XML Prevent associating of XSL stylesheet w/XML output fragment packets (optionally w/given MTU) Cloak a scan with decoys Spoof source address Use specified interface Use given port number Append random data to sent packets Set IP time-to-live field Spoof your MAC address Send packets with a bogus TCP/UDP checksum
MISC: -6 -A --datadir <dirname> --send-eth/--send-ip --privileged -V Enable IPv6 scanning Enables OS detection and Version detection Specify custom Nmap data file location Send using raw ethernet frames or IP packets Assume that the user is fully privileged Print version number