> For the complete documentation index, see [llms.txt](https://eclipse-16.gitbook.io/eclipse-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eclipse-16.gitbook.io/eclipse-docs/hacking/network/networks.md). Agents can also search and read this documentation through its [MCP server](https://eclipse-16.gitbook.io/eclipse-docs/~gitbook/mcp).

# Networks

### Subnetworks

A subnet (short for subnetwork) is a smaller, divided section of a larger IP network. Subnets help organize and manage IP addresses, improve network performance, and enhance security by separating traffic. Each subnet has its own range of IPs, defined by a **subnet mask** (like 255.255.255.0), which determines how many devices can exist within it. For example, a /24 subnet allows 256 addresses (254 usable). Subnetting is mainly used in networking to control traffic, reduce congestion, and efficiently use IP address space.

### Network Enumeration&#x20;

To scan hosts, we can utilize the Nmap tool. Nmap scans networks for live hosts, open ports, and running services to help with troubleshooting and security assessments.&#x20;

Here are a few short examples of common Nmap uses:

* **Ping scan (find live hosts):** `nmap -sn 192.168.1.0/24`
* **Scan specific ports:** `nmap -p 80,443 10.10.12.13`
* **Service/version detection:** `nmap -sV 10.10.12.13`
* **OS detection:** `nmap -O 10.10.12.13`
* **Aggressive scan (detailed info):** `nmap -A 10.10.12.13`
* **Subnet scan:** `nmap 10.10.12.0/29`

&#x20;

### Live Hosts

To discover or dig for live hosts&#x20;

### ARP Request

ARP or Address Resolution Protocol works as follows: Computer\_1 sends an ARP request asking who has the IP address of xx.xx.xxx.xxx, and Computer\_2 replies that it has the IP Address needed for the MAC Address of xxx.xxx.xxx.xxx. It allows this step of designatating the target before the TCP Threeway Handshake.&#x20;

We run `nmap -PR -sn MACHINE_IP/24` to discover all the live systems on the same subnet as our target machine.

<figure><img src="https://tryhackme-images.s3.amazonaws.com/user-uploads/5f04259cf9bf5b57aed2c476/room-content/14c31c66e002e2f50b0f8525c8d8e456.png" alt=""><figcaption></figcaption></figure>

Because ICMP echo requests tend to be blocked, you might also consider ICMP Timestamp or ICMP Address Mask requests to tell if a system is online. Nmap uses timestamp request (ICMP Type 13) and checks whether it will get a Timestamp reply (ICMP Type 14). Adding the `-PP` option tells Nmap to use ICMP timestamp requests. As shown in the figure below, you expect live hosts to reply.

### TCP Threeway Handshake

The TCP three-way handshake is the process used to establish a reliable connection between a client and a server before data transfer begins. It ensures both sides are synchronized and ready to communicate. First, the client sends a **SYN** (synchronize) packet to the server, requesting a connection. The server replies with a **SYN-ACK** (synchronize-acknowledge) packet, confirming receipt and signaling readiness. Finally, the client responds with an **ACK** (acknowledge) packet, completing the handshake and opening the connection.

For example, if your computer wants to connect to a web server, it first sends a SYN packet. The server receives it and replies with a SYN-ACK. When your computer replies with an ACK, both sides know the connection is set up, and only then does the web page data start flowing. This system ensures reliability by confirming that both the sender and receiver are aware of and agree on the connection before any actual data exchange happens.

<figure><img src="https://tryhackme-images.s3.amazonaws.com/user-uploads/5f04259cf9bf5b57aed2c476/room-content/23e7f481f78de8d3e89ef845b747002d.png" alt=""><figcaption></figcaption></figure>

"[We can send a packet with the SYN (Synchronize) flag set to a TCP port, 80 by default, and wait for a response. An open port should reply with a SYN/ACK (Acknowledge); a closed port would result in an RST (Reset).](https://tryhackme.com/room/nmap01#:~:text=We%20can%20send%20a%20packet%20with%20the%20SYN%20\(Synchronize\)%20flag%20set%20to%20a%20TCP%20port%2C%2080%20by%20default%2C%20and%20wait%20for%20a%20response.%20An%20open%20port%20should%20reply%20with%20a%20SYN/ACK%20\(Acknowledge\)%3B%20a%20closed%20port%20would%20result%20in%20an%20RST%20\(Reset\).)"

You can tell Nmap to perform a TCP SYN ping using the **`-PS`** option followed by a port number, a range, a list, or any mix of them. For instance, **`-PS21`** checks port `21`, **`-PS21-25`** scans ports `21` through `25`, and **`-PS80,443,8080`** targets ports `80`, `443`, and `8080` specifically.

| Option | Purpose                          |
| ------ | -------------------------------- |
| `-n`   | no DNS lookup                    |
| `-R`   | reverse-DNS lookup for all hosts |
| `-sn`  | host discovery only              |

| Scan Type              | Example Command                             |
| ---------------------- | ------------------------------------------- |
| ARP Scan               | `sudo nmap -PR -sn MACHINE_IP/24`           |
| ICMP Echo Scan         | `sudo nmap -PE -sn MACHINE_IP/24`           |
| ICMP Timestamp Scan    | `sudo nmap -PP -sn MACHINE_IP/24`           |
| ICMP Address Mask Scan | `sudo nmap -PM -sn MACHINE_IP/24`           |
| TCP SYN Ping Scan      | `sudo nmap -PS22,80,443 -sn MACHINE_IP/30`  |
| TCP ACK Ping Scan      | `sudo nmap -PA22,80,443 -sn MACHINE_IP/30`  |
| UDP Ping Scan          | `sudo nmap -PU53,161,162 -sn MACHINE_IP/30` |
