Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views15 pages

Nmap Comandos

Nmap is a powerful network scanning tool used by administrators to discover hosts, services, and vulnerabilities within a network. It offers various scanning options, including TCP SYN, TCP connect, and UDP scans, allowing users to identify open ports and services running on devices. Regular network scanning with Nmap is essential for maintaining security and compliance by detecting unauthorized devices and potential threats.

Uploaded by

Deymar Callisaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views15 pages

Nmap Comandos

Nmap is a powerful network scanning tool used by administrators to discover hosts, services, and vulnerabilities within a network. It offers various scanning options, including TCP SYN, TCP connect, and UDP scans, allowing users to identify open ports and services running on devices. Regular network scanning with Nmap is essential for maintaining security and compliance by detecting unauthorized devices and potential threats.

Uploaded by

Deymar Callisaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Nmap, short for network mapper, is a versatile tool network administrators use to

discover hosts and services on a computer network. You can also use it to identify
network vulnerabilities, enumerate open ports, and even determine what operating
systems are running on a network.

Nmap is helpful, whether you’re trying to audit network security or simply map out
your network before making changes.

Why is network scanning so important?


Network scanning is crucial for identifying vulnerabilities, unauthorized devices,
and security gaps within a network. By regularly scanning your network, you can
detect and address potential threats before they are exploited by malicious actors.

Network scanning also provides insights into network topology and device status,
aiding in efficient network management and compliance with security policies and
regulations.

Nmap is one of the best tools for scanning computer networks. For example, when
managing a large corporate network Nmap lets you see which devices are online.

To cite one of the most common nmap uses cases; host discovery, you can quickly
ping all devices in a subnet without running a port scan. This allows you to see
all active hosts, making it simpler to monitor your network's health.

In a corporate setting, identifying open ports is also essential. Open ports can be
entry points for attackers. Using a simple Nmap command, you can check if a
specific device has HTTP and HTTPS services running. This is particularly useful
for scanning web servers to ensure they're configured correctly.

Nmap offers a plethora of other options and scripts to tailor your scans precisely
to your needs. This article will explore those use cases and applications.

The different Nmap commands and their use cases


Scanning a single host
Nmap makes it a straightforward process to scan a single host. You just specify the
target's IP address or hostname. For example, if you want to scan the
`scanme.nmap.org` host. You'd simply run:

This tells Nmap to scan that specific hostname. If the hostname resolves to an IP
address, like `64.13.134.52`, the command `nmap 64.13.134.52` would do the exact
same thing.

You can also use CIDR notation for finer control. For example, `nmap
scanme.nmap.org/32` scans just the single IP tied to the hostname. Assuming it's
`64.13.134.52`, the command remains the same.

If you are working within a company's internal network, you might come across a
situation where you need to scan an entire range of IP addresses.

Say your company's network is configured as `192.168.10.0/24`. Running `nmap


192.168.10.0/24` will scan all 256 hosts from `192.168.10.0` to `192.168.10.255`.
This is handy when you need to check the whole subnet for active devices or
services.

Now, let's say you're dealing with a range that includes sensitive devices. You
might want to exclude certain IPs. If you prefer not to scan a specific server,
like `scanme.nmap.org`, within a range, you use the `--exclude` option. For
instance:

This command scans the entire range `64.13.134.0` to `64.13.134.255`, skipping


`scanme.nmap.org`. You can also exclude multiple addresses. Maybe there’s another
critical server, `insecure.org`, that you want to avoid in your scan:

This method is quite versatile and keeps you from accidentally disrupting critical
services.

If you need maximum flexibility, Nmap also supports octet range addressing. This
allows you to scan multiple specific IPs with a single command. Let's say you want
to scan IPs `192.168.3.1`, `192.168.4.1`, `192.168.5.1`, and `192.168.7.1`. You'd
run:

Another use-case could be scanning all IP addresses ending in `13.37` across the
entire Internet. Here's how you do that:

Nmap is also robust enough to handle large lists of hosts. If you have a file from
a DHCP server listing thousands of current leases, you just feed the list into Nmap
using the `-iL` option.

For example, if you have a file called `hosts.txt`, you would run:

Even if the list is dynamically generated, you can use shell commands to pipe the
list into Nmap:

All these methods show how flexible and powerful Nmap can be when scanning single
hosts, ranges, or specific sets of IPs. Whether you’re dealing with a corporate
network or just a single server, Nmap adapts to your needs.

Scanning multiple hosts


Nmap makes it easy to specify multiple targets. On the command line, anything that
isn't an option is considered a target host specification. You would list the IP
addresses or hostnames you want to scan.

Let's say you want to scan `scanme.nmap.org` and a local IP like `192.168.0.1` in
one go. You would write:

This command will scan both targets sequentially.

Sometimes, you might want to scan a whole network of adjacent hosts. For that, Nmap
supports CIDR notation. If you want to scan a complete subnet, say the
`192.168.1.0/24` network, which covers all 256 addresses from `192.168.1.0` to
`192.168.1.255`, you'd write:

Nmap also supports more complex target specifications using octet ranges. If you
want to skip certain IP addresses, you can use this feature. For instance, to scan
all addresses from `192.168.1.1` to `192.168.1.254` while skipping `.0` and `.255`,
you would use this command:

This way, you won't hit the network and broadcast addresses, which can sometimes
cause issues.

Nmap allows mixing different types of target specifications. You could combine a
hostname, a CIDR block, and a range in one command. An example command would be:

This will scan `scanme.nmap.org`, a `/16` subnet range, and a more complex set of
addresses within the `10.0.0.0` network.

For automated or extensive scanning tasks, it's often more practical to read
targets from a file instead of listing them all on the command line. You can use
the `-iL` option followed by a filename. If your file `hosts.txt` contains a list
of target IPs or hostnames, you'd scan them like this:

Each entry in `hosts.txt` can be in any of the formats accepted by Nmap, such as IP
addresses, hostnames, or ranges.

To exclude certain hosts from your scan, use the `--exclude` option. For example,
if you want to scan the `192.168.1.0/24` subnet but skip `192.168.1.1` and
`192.168.1.2`, you’d type:

That's how you can specify multiple hosts and networks with Nmap. Using these
options, you can craft precise and efficient scans that meet your specific needs.

Scanning an entire subnet


When you need to scan a whole network of adjacent hosts, Nmap has got you covered
with CIDR notation. This is perfect for network admins who want to check up on an
entire subnet. You just append `/<numbits>` to an IP address or hostname, and Nmap
will scan every IP address where the first `<numbits>` match the address you
provided.

For example, if you use `192.168.10.0/24`, Nmap will scan all 256 hosts between
`192.168.10.0` and `192.168.10.255`. This range includes both the network address
and the broadcast address. This means you’ll cover everything from the first host
(`192.168.10.1`) to the last (`192.168.10.254`). It’s a quick and efficient way to
scan a class C subnet.

Let's say you only want to scan a smaller network. If you use `192.168.10.0/28`,
you'll be scanning 16 IP addresses, from `192.168.10.0` to `192.168.10.15`. This
can be handy when dealing with smaller subnets or specific segments of a larger
network.

CIDR isn't limited to just the private IP ranges. You could also scan public IP
spaces. For instance, `scanme.nmap.org/16` would scan 65,536 IP addresses between
`64.13.0.0` and `64.13.255.255`. This includes the host, scanme.nmap.org, which
resolves to `64.13.134.52`. This range is much larger, so make sure to have the
necessary permissions and bandwidth before initiating such a scan.

If you want to mix things up, you can combine different target specifications. For
example, `nmap scanme.nmap.org 192.168.0.0/16 10.0.0,1,3-7.-` tells Nmap to scan a
single host (scanme.nmap.org), all hosts in a class B subnet (`192.168.0.0/16`),
and a more specific set of hosts in the 10.0.0.x range.

Nmap also supports octet range addressing if you find CIDR notation too
restrictive. For example, `192.168.0-255.1-254` will scan all addresses in the
range while skipping those ending in `.0` or `.255`. This is especially useful when
you know certain addresses may be subnet network or broadcast addresses.

In conclusion, using CIDR notation with Nmap is straightforward and powerful. It


allows you to scan large networks efficiently, providing a comprehensive picture of
the specified subnet.

`nmap -sS` - TCP SYN scan


The TCP SYN scan (`-sS`) is your go-to buddy for a quick and stealthy
reconnaissance of a network. Whether you’re looking to scan a home network or map
out a corporate network, understanding and utilizing the SYN scan is crucial.

Often dubbed the "stealth scan" because it never completes the TCP handshake, the
TCP SYN scan is less likely to be logged by most firewalls and intrusion detection
systems. But remember, "stealth" doesn’t mean invisible—it’s still detectable if
someone is watching closely.

When you run a TCP SYN scan, Nmap sends SYN packets, which are requests to start a
TCP connection, to the target ports. If a port is open, the target responds with a
SYN/ACK packet, indicating it's ready to establish a connection.

Nmap then sends a RST packet to tear down the connection before it's fully
established, hence the "half-open" scanning. Closed ports respond with an RST
packet, while filtered ports might ignore the request or send an ICMP unreachable
message.

To run an SYN scan with Nmap you just use the `-sS` option followed by your target.
For example:

This command will scan the most common 1,000 ports of the specified IP address. If
you want to scan all 65,535 ports, you can add the `-p-` option:

Sometimes you might want to scan a specific range of ports. Nmap makes this easy
too:

Want to be a bit more thorough? Combining SYN scan with service version detection
`-sV` can give you more info:

This scan will tell you what services are running on the open ports and their
versions. It's super useful for identifying potential vulnerabilities.
SYN scans aren't just limited to single IP addresses. You can scan entire subnet
ranges:

For added stealth, you can combine TCP SYN scan with decoy scanning using the `-D`
option. This will send spoofed packets to the target from various IP addresses,
making it harder for the target to identify your real IP:

In this command, `RND:10` uses 10 random decoys. Keep in mind that while decoys add
a layer of obfuscation, they also increase the time it takes for your scan to
complete.

For environments where packet filtering is aggressive, SYN scan’s resilience


shines. It's reliable, fast, and doesn't require special privileges on some systems
to run.

`nmap -sT` - TCP connect scan


When you use the `nmap -sT` command, you're telling Nmap to perform a TCP connect
scan. What does that mean?

Essentially, Nmap will attempt to make a full connection with each port it scans.
It’s like knocking on a door and waiting for someone to respond with either a "Come
on in!" or a "Sorry, we're closed." This is different from a stealthy scan because
it completes the three-way handshake (SYN, SYN-ACK, ACK) with the target machine.

Why would you use a TCP connect scan? It's a reliable method that works even when
you don't have special privileges on the network. It's also useful when dealing
with firewalls or packet filters that might block stealthier scans.

The downside? This method is noisier. It’s easier for admins to detect because it
involves completing the handshake.

Let's look at an example. Suppose you want to scan a server on your network to find
open ports. You’d run:

This command tells Nmap to do a TCP connect scan on the IP address `192.168.1.10`.
Nmap will then go through the common ports and try to establish a connection with
each one. If a port responds, it's considered open, and Nmap will report it back to
you.

Now, if you want to scan a specific range of ports, you can modify the command a
bit. For instance, let's say you're interested in ports 20 to 80. You'd run:

This tells Nmap to limit the scan to ports between 20 and 80. It’s handy when
you’re only interested in certain services, like FTP, SSH, and HTTP.

What if you want to scan multiple hosts? It’s easy. You just list them out or
specify a range. For example:


Or even:

This will scan the specified IP addresses or range using the TCP connect method.
Each machine’s open ports will be reported back.

It’s also worth noting that you can save the scan results to a file for later
analysis. Just add the `-oN` option followed by a filename. For example:

This saves the scan results in a human-readable format in the file


`scan_results.txt`.

Using the TCP connect scan is pretty straightforward. It’s effective when
reliability is a priority, even if it's a bit more noticeable. Remember, though,
that running these scans without permission can lead to trouble, so always have the
proper authorization.

`nmap -sU` - UDP scan


UDP scanning is a bit trickier compared to TCP. That’s mainly because UDP, unlike
TCP, doesn’t require packet acknowledgment from open ports. This lack of response
can make it feel like you are poking around in the dark. Still, there are some
techniques you can use to get around this problem.

First up, let’s understand what happens when a port is closed. When you send a UDP
packet to a closed port, many hosts will respond with an ICMP_PORT_UNREACH message.

Most of the time, you can rely on this behavior to deduce that a port is closed. If
you don’t get that message, there’s a good chance the port is open. But remember,
this isn’t foolproof. Neither UDP packets nor the ICMP errors are guaranteed to
arrive, so some packets might just get lost in the void.

Here’s a simple command to perform a UDP scan on a target:

Notice the `sudo`? That’s because you need root privileges to read the ICMP port
unreachable errors directly. If you're on a tight schedule, keep in mind that UDP
scans can be painstakingly slow.

Some hosts implement rate limiting to control the flood of ICMP error messages they
send out. For instance, Linux limits these responses to about 80 every four
seconds, which can test your patience.

Let me give you a classic example. Suppose you’re trying to find the elusive
`rpcbind` service on a Solaris machine. Here’s the command you'd use:

Pretty straightforward, right? But what if `rpcbind` is hiding on some high,


undocumented UDP port above 32770? You’d want to scan a range:

This way, you cover a broad swath, increasing your chances of locating that sneaky
service.
If you’re not root but still want to scan UDP ports, there’s another method using
non-blocking sockets. This isn't as reliable, but you can try it out with:

This method checks for a second write() failure to identify closed ports. It’s a
hacky approach but it can work in a pinch.

`nmap -sV` - Identifying services running on open ports


The `-sV` flag tells Nmap to perform version detection. It's like having a
magnifying glass on those open ports, giving you details about the service versions
and potentially the OS running on the target.

For instance, if you want to scan a single IP address, you can simply type:

This command will check all the open ports on `192.168.1.1` and provide you with
details on what services are running and their versions.

Let's say you want to scan a whole subnet while excluding certain IP addresses. You
can specify a range and exclusions like this:

Here, Nmap will scan all the hosts in the `192.168.0.0/24` subnet, but skip
`192.168.0.1` and `192.168.0.255`. This is useful for avoiding devices that might
react negatively to being scanned.

Sometimes, you have a list of hosts you need to scan. Save your IPs in a file, say
`hosts.txt`, and point Nmap to it:

This reads the list of targets from `hosts.txt` and performs the service version
detection on each of them.

Another cool trick is scanning for random web servers across the internet. You can
do this by specifying the `-iR` flag followed by the number of random hosts you
want to scan:

This command scans ten random IPs for open port 80, and only tells you about the
open ones.

When speed is an issue, you might want to skip DNS resolution for faster results.
Use the `-n` option:

This skips the DNS resolution step while still performing service version detection
on `scanme.nmap.org`.

Each of these commands gives you a deeper insight into your network or target,
helping you understand what's running where and potentially identifying
vulnerabilities. It's like having a map that not only shows where things are but
gives you extra details about what's at each location.
`nmap -O` - Detecting the OS of a remote host
The `nmap -O` command is useful when you're trying to understand more about the
devices on your network. Imagine you're trying to secure a corporate network and
need to know what OS each device runs. `nmap -O` can help with that.

Let's say you want to find out the operating system of a device with the IP address
`192.168.1.1`. You'd type:

Hitting enter runs the scan, and once it's done, you get detailed information about
the host's OS. For instance, it might tell you if the device is running Windows,
Linux, or another operating system. It's pretty cool how accurate it can be!

Here's another example. If you want to scan a range of IP addresses to see what OS
they're running, you could use:

This command scans IPs from `192.168.1.1` to `192.168.1.20` and tries to identify
the operating systems. It’s super helpful in environments with mixed OS
deployments.

There’s also an option to combine the OS detection with port scanning using the `-
p` flag. For instance:

This command not only checks the OS of the target device but also looks at ports 22
(SSH), 80 (HTTP), and 443 (HTTPS). This combined approach can give you a detailed
snapshot of the device’s security posture.

It’s worth noting that OS detection isn’t foolproof. Some firewalls and security
systems might block this kind of activity. But when it works, it’s incredibly
insightful. Use it to keep an eye on your network and make sure everything is as it
should be.

`nmap -A` - Conducting multiple scans at once


The `nmap -A` command enables OS detection, version detection, script scanning, and
traceroute all at once. It's the Swiss Army knife for network scanning.

We will explain with a basic example. Running `nmap -A 192.168.1.1` will give you a
comprehensive scan of a single IP address. You'll get information on the operating
system, service versions, available scripts, and even the network path to the
target.

If you're dealing with an entire subnet, simply modify the command to include a
range. For instance, `nmap -A 192.168.1.0/24` will scan all devices in the
192.168.1.x subnet. This is particularly useful when you need a quick inventory of
all devices on your network.

Now, let's say you want to scan a specific range of ports. You can combine `-A`
with the `-p` flag to specify the ports. For example, `nmap -A -p 80,443
192.168.1.1` will only scan ports 80 and 443 on the target IP. This can save time
and focus your scan on the most critical services.

What if you need to perform the scan more stealthily to avoid triggering alarms?

Adding the `-sS` flag for a SYN scan can help. So, `nmap -A -sS 192.168.1.1` will
perform a comprehensive scan similar to the default but with a stealthier approach.

When dealing with multiple hosts across different subnets, you can list them in a
file and use the `-iL` option. For instance, create a file called `targets.txt`
with IP addresses or subnets listed line by line. Then run `nmap -A -iL
targets.txt` to scan all those targets in one go.

Finally, if you need to export the results, you can add the `-oN` flag followed by
a filename. For example, `nmap -A 192.168.1.1 -oN scan_results.txt` will save the
output to `scan_results.txt`. This is handy for documentation or further analysis.

Using `nmap -A`, you get a wealth of information that can help you understand and
secure your network better. It's powerful, versatile, and essential for any network
admin or security professional.

‘Nmap --exclude’ - Excluding specific hosts from your scan


There are times when you need to exclude certain hosts from your scans. This could
be due to lack of authorization, to avoid potential issues, or simply to save time.

Nmap makes this easy with the `--exclude` option. It's a lifesaver when you know
there are certain IP addresses you should avoid.

Suppose you're scanning a network, but you want to skip a couple of IP addresses
because they belong to critical systems. You can do this by specifying the IPs in
the `--exclude` option.

For instance, to scan the `192.168.1.0/24` network excluding `192.168.1.102` and


`192.168.1.254`, you'd run:

This command scans the entire 192.168.1.0/24 network while skipping `192.168.1.102`
and `192.168.1.254`.

But what if you have a longer list of IPs to exclude? Typing them all out can be
cumbersome. You can put all the IPs into a file and use the `--excludefile` option
to tell Nmap to read the list from there.

For example, suppose you have a file named `exclude_list.txt` with the following
entries:

You can execute the scan like this:


The `--exclude` option doesn't mix well with IP ranges that use commas like
`192.168.0.10,20,30`. In such cases, it's better to use `--excludefile`.

Another real-world scenario might be scanning a larger private network. Let's say
you want to scan the 10.x.x.x network but avoid the 10.6.x.x subnet and a
particularly sensitive host:

This tells Nmap to scan the entire 10.x.x.x range, except for the 10.6.x.x subnet
and `ultra-sensitive-host.company.com`.

Other times, consultants need to scan client networks but want to exclude their own
machine. You could do:

When specifying hosts to exclude, you can mix and match IP addresses, hostnames,
and CIDR notations. This makes it flexible and powerful for avoiding scans where
they shouldn't happen. Always double-check your exclude list to prevent
unintentional scans on critical systems.

‘nmap --script=default’ - Conducting quick network scans


When I need to perform a script scan using Nmap's most essential scripts, I use the
`-sC` option. This is actually shorthand for `--script=default`. Running this
command enables a set of default scripts designed to provide useful and actionable
information without being overly intrusive.

For instance, let's say you are scanning a company's internal network. Using `nmap
-sC 192.168.1.0/24`, I'll get a wealth of details such as open ports, services, and
potential vulnerabilities.

These scripts are carefully selected to balance speed, usefulness, and safety. They
are designed to give you valuable insights quickly, without overwhelming me with
irrelevant data.

However, it’s worth mentioning that some scripts in the default category can be a
bit intrusive. They might do things like checking for anonymous FTP login (`ftp-
anon`) or identifying SMB shares (`smb-enum-shares`). Because of this, it's crucial
to have permission before running these scans on a network that isn't yours.

If you ever get curious about what specific scripts are included in the default
category, you can use the `--script-help` option to see descriptions of each
script.

For example, running `nmap --script-help default` brings up a detailed list. It


tells you what each script does, such as `http-auth` which retrieves the
authentication scheme and realm of web services that require authentication, or
`smb-os-discovery` which tries to determine the operating system over the SMB
protocol.

In some cases, you may want to run specific scripts outside the default set. Using
`--script <script-name>` allows you to specify exactly which script to run. For
example, if you are only interested in checking for open FTP servers allowing
anonymous logins, you would use `nmap --script ftp-anon 192.168.1.0/24`. This way,
you can focus your scan on a particular area of concern.

Nmap also lets you use Boolean expressions to combine multiple script categories.
For instance, if you want to run all default and safe scripts, you can use `nmap --
script="default or safe" 192.168.1.0/24`. This command loads a broader range of
scripts while still ensuring that they adhere to Nmap's safety guidelines.

Script arguments can further customize the behavior of these scans. For instance,
you might have a script that needs specific login credentials or other parameters.

Using the `--script-args` option, you can pass these arguments directly to the
script. An example would be `nmap --script ftp-brute --script-args
userdb=/path/to/userlist.txt,passdb=/path/to/passlist.txt 192.168.1.0/24`, which
uses specific user and password lists for a brute-force attack.

In summary, the `default` script category in Nmap is my go-to for quick,


informative scans. It saves you time and provides a solid foundation of
information, all while being easy to use with just a simple `-sC` or `--
script=default` command.

nmap --script=vuln - Checking network vulnerabilities


Using `nmap --script=vuln` is a great way to check for vulnerabilities within your
company's network. This command allows you to leverage Nmap's scripting engine to
run various vulnerability detection scripts. It's like having a toolkit of mini
security scanners bundled into one powerful command.

When you run `nmap --script=vuln`, Nmap will execute multiple scripts that are
designed to detect commonly known vulnerabilities. This can save you a lot of time
compared to running individual scripts manually.

Here are some examples. Say you want to scan a server with the IP address
192.168.1.1 for vulnerabilities. You would open your terminal and type:

This command will start a scan on the specified IP address and return a report of
any vulnerabilities that the scripts detect. The output includes details on what
was found, making it easy to understand the potential risks.

If you want to scan an entire subnet, for instance, the 192.168.1.0/24 range, the
command would look like this:

This will perform a vulnerability scan on all devices within that subnet. It's
especially useful for getting a comprehensive overview of your network's security
posture.

Now, let’s say you have some hosts specified in a file called `hosts.txt` and you
want to scan all of them. Your command would be:

This tells Nmap to read the list of hosts from `hosts.txt` and execute the
vulnerability scan on each one.

One of my favorite features is the ability to combine this with other Nmap options.
For instance, if you want to increase verbosity to get more detailed output, you
can add `-v`:

Or if you want to save the scan results to a file for later analysis, you can use
the `-oN` option:

Remember, while `nmap --script=vuln` is powerful, it's important to use it


responsibly. Ensure you have permission to scan the network or devices in question
to avoid any legal issues.

This command can be a vital part of your network security toolkit, helping you
identify and mitigate vulnerabilities before they can be exploited.

‘nmap --script=auth’ - Scanning for authentication mechanisms


Running `nmap --script=auth` searches for a variety of authentication-related
issues across different services. For example, you can use the `http-auth` script
to discover the authentication schemes and realms used by a web service that
requires login credentials.

This is particularly useful for identifying what kind of authentication (like


Basic, Digest, NTLM) is enforced on a given web application. You can execute this
script with the following command:

This command checks the `/login` path on port 80 of your target host and retrieves
details about the authentication used. When you run this, you might see an output
similar to this:

If you are dealing with SSH servers, the `ssh-auth-methods` script shows what
authentication methods the SSH server supports. This can help in determining
whether weak or easily guessable authentication methods are available. You can run
this script like this:

Assuming `<username>` is a valid username on the target SSH server, this script
will display all the supported authentication methods, as shown below:

For services running on Microsoft SQL Server, the `ms-sql-empty-password` script


checks if the `sa` (system administrator) account has an empty password, which is a
critical vulnerability. You can execute this using the following command:

The output will tell you whether the `sa` account is vulnerable to unauthorized
access due to an empty password.

Similarly, for discovering Windows user accounts through SMB, you can use the `smb-
enum-users` script. This script attempts to enumerate as many users as possible on
a remote Windows system. Run it like this:

This command outputs a list of user accounts available on the system, which can be
essential for both administrative tasks and penetration testing.

Each script in the `auth` category serves a unique purpose, enabling you to assess
different aspects of authentication across various services and protocols.
By leveraging these scripts, you can gain significant insights into the security
posture of your network’s authentication mechanisms.

Timing templates - How to speed up network scans


One of the quickest ways to speed up your Nmap scans is by using timing templates.
These templates adjust various advanced timing parameters to strike a balance
between speed and accuracy.

nmap -T4
When you use `nmap -T4 <hostname>`, Nmap increases the speed of your scans. This is
achieved by optimizing several internal variables such as probe parallelism and
response timeouts.

For instance, `-T4` makes Nmap more aggressive in sending packets and reduces the
waiting time for responses. The result is a scan that completes much faster than
the default settings.

To give you a practical example, imagine you need to scan your company's subnet:
`nmap -T4 192.168.1.0/24`. This command will speed up the scan significantly,
allowing you to get results in minutes instead of hours.

The `-T4` template is designed to handle networks that are relatively stable and
responsive, which is typically the case for most corporate environments.

However, be cautious. While `-T4` speeds things up, it might not be suitable for
networks experiencing high latency or packet loss. In such situations, important
packets might get lost, reducing the accuracy of your scan. Always test and
validate your scan settings to ensure they meet your specific needs.

Here's another example. If you're performing a service version detection scan, you
could use: `nmap -sV -T4 <hostname>`. This command combines version detection with
the `-T4` timing template, giving you detailed information about the services
running on your targets much more quickly.

The ‘-T4` nmap command is a popular choice for balancing speed and reliability.
But, if you need even faster scans and are willing to trade off some accuracy, `-
T5` is an option, though it often sends packets faster than the network can handle.

Overall, the `-T4` timing template is a powerful option for optimizing your Nmap
scans. It helps you gather the necessary information efficiently, making it a
favorite for network administrators and security professionals alike.

‘nmap -T0’ to ‘nmap -T5’ - Slowing down network scans


When you use `nmap -T0`, you're telling Nmap to go as slow as possible. This option
is called "Paranoid". It's useful if you're trying to evade Intrusion Detection
Systems (IDS) because it inserts long delays between the probes—making it harder
for the IDS to detect a scan.

For example, you might use:

This command will scan the IP `192.168.0.1` with the most caution.

Next is `nmap -T1`, known as "Sneaky". Similar to `-T0`, it’s also slow but
slightly faster. This is handy for scanning over a congested network while still
trying to avoid detection. You can use:

Using `nmap -T2` invokes the "Polite" template. It speeds up the scan a bit more
but is still designed to minimize the load on the network and reduce the risk of
triggering IDS alarms.

For example:

Then there's `nmap -T3`, or the "Normal" template. This one is the default if you
don’t specify a timing template. It balances speed and reliability. It's the go-to
for most standard scans:

The "Aggressive" template, `nmap -T4`, ramps things up. It's much faster and sends
probes more frequently. This is great for larger networks when speed is essential,
and you’re less concerned about detection:

Another example is scanning with debug mode enabled to see the timing report:

You might see a timing report in your output like:

Lastly, `nmap -T5`, known as "Insane". This one’s the fastest and most aggressive.
It’s best used only in environments where you have substantial control over the
network, like a testing lab, since it can overwhelm network devices and services:

Choosing the right template depends on your specific needs. If you're scanning a
large range of IPs and time is of the essence, you might lean toward `-T4` or `-
T5`.

If you're more concerned about stealth and minimizing network impact, go for `-T0`
or `-T1`. For most users, sticking with the default `-T3` is adequate.

`nmap -max-parallelism` - How to limit the number of simultaneous scans


When using `nmap` for scanning, sometimes you need to control how many probes are
sent in parallel. That's where the `--max-parallelism` option is handy. It allows
you to set a limit on the number of probes that are sent simultaneously, which can
be useful in various scenarios.

For instance, if you're scanning a network with limited bandwidth, you might want
to use the `--max-parallelism` option to avoid overwhelming the network. By setting
a low number, you can ensure that your scan is less intrusive. Here's a basic
example:

In this command, we have set the maximum parallelism to 5. This means that Nmap
will send out no more than 5 probes at a time. This can help prevent network
congestion, especially on slower networks.
Using the `--max-parallelism` option can also be beneficial when scanning a large
number of hosts. If your network infrastructure can handle more traffic, you might
want to increase the number of parallel probes to speed up the scan. For example:

In this command, you are scanning an entire /24 subnet with a parallelism level of
20. This will speed up the scan compared to a lower parallelism setting. However,
keep in mind that setting the parallelism too high can lead to packet loss and
inaccurate results.

Another scenario where `--max-parallelism` is useful is when dealing with network


devices that have strict rate limiting. Some devices might drop or block probes if
too many are sent in a short period. By adjusting the parallelism, you can avoid
triggering these limits:

In this example, we have combined `--max-parallelism 10` with `--max-retries 1` to


ensure that only 10 probes are sent at a time, and each probe is retried only once.
This can be particularly useful for environments with strict security measures.

The `--max-parallelism` option is a versatile tool that allows you to fine-tune


your Nmap scans based on network conditions and requirements. By adjusting the
number of parallel probes, you can achieve a balance between scan speed and network
stability, making your scanning process more efficient and effective

You might also like