Scan Target From File

NmapNmapBeginner
Practice Now

Introduction

In this challenge, you'll be using Nmap to discover active hosts on a network by performing a ping sweep on a list of IP addresses specified in the targets.txt file. The goal is to identify which hosts are online and save their IP addresses to a new file named online_hosts.txt, with each IP address on a new line.

This task requires you to leverage Nmap's -iL option to read target IP addresses from the input file, and then use tools like grep and awk to extract the online host IP addresses from the Nmap output. Finally, you'll redirect the extracted IP addresses to the online_hosts.txt file, ensuring the correct format for verification.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL nmap(("Nmap")) -.-> nmap/NmapGroup(["Nmap"]) nmap/NmapGroup -.-> nmap/save_output("Save Output to File") nmap/NmapGroup -.-> nmap/host_discovery("Host Discovery Techniques") nmap/NmapGroup -.-> nmap/target_specification("Target Specification") subgraph Lab Skills nmap/save_output -.-> lab-548715{{"Scan Target From File"}} nmap/host_discovery -.-> lab-548715{{"Scan Target From File"}} nmap/target_specification -.-> lab-548715{{"Scan Target From File"}} end

Scan Target From File

This challenge requires you to use Nmap to discover active hosts on a specific network, focusing on a smaller subnet for efficiency.

Tasks

  • Use Nmap to perform a ping sweep on the IP addresses listed in the targets.txt file.
  • Save the IP addresses of the online hosts to a file named online_hosts.txt.

Requirements

  1. You must use Nmap to perform the ping sweep.
  2. The input IP addresses must be read from the file ~/project/targets.txt.
  3. The output, containing the IP addresses of the online hosts, must be saved to the file ~/project/online_hosts.txt.
  4. Each IP address in ~/project/online_hosts.txt should be on a new line.

Examples

If targets.txt contains:

127.0.0.1
127.0.0.2
127.0.0.3

And 127.0.0.1 and 127.0.0.2 are online, then online_hosts.txt should contain:

127.0.0.1
127.0.0.2

Hints

  • Use the -iL option in Nmap to specify the input file containing the list of target IP addresses.
  • Use grep and awk to extract the IP addresses from the Nmap output, and redirect the output of your command to the online_hosts.txt file.
  • If you don't familiar with grep and awk, you can copy and paste the online hosts from the Nmap output to the online_hosts.txt file, make sure each IP address is on a new line.
โœจ Check Solution and Practice

Summary

In this challenge, the objective is to use Nmap to perform a ping sweep on a list of IP addresses specified in the targets.txt file, and then save the IP addresses of the online hosts to a file named online_hosts.txt.

The challenge emphasizes the use of Nmap's -iL option to read target IP addresses from a file, and the use of tools like grep and awk to parse the Nmap output and extract the IP addresses of active hosts. The final step involves redirecting the extracted IP addresses to the online_hosts.txt file, ensuring each IP address is on a new line.