Network Scanning and Vulnerability Detection with Nmap and Ruby
Nmap Commands for IP Discovery
To perform a network sweep for active IPs, you can use the following Nmap command. This will scan a list of IP ranges and output the results to a file:
Next, use grep
to extract only the IPs that are up:
Note: Running these commands will alert the Network Operations Center (NOC) that someone is scanning the network.
Common Open Ports
When scanning networks, certain ports are typically open:
- Microsoft Remote Desktop (TCP 3389)
- Secure Shell (SSH) (TCP 22, 2222)
- HTTP/HTTPS (TCP 80, 443)
Scan Specific Ports
To scan for common ports (22, 80, 443, 3389, 2222), use the following Nmap command:
To view the open ports from the scan, use cat
:
Alternative Methods for Finding IPs
You can also find IPs by obtaining the reverse IP from a DNS server. For example, to resolve the host mail.jeremiahonealtechsupport.com
, you can run a reverse DNS lookup.
Scan a Subnet
To scan a specific subnet, use this Nmap command:
Discover Network Services
To sweep for open ports across a list of hosts, use the following Nmap command:
To check for open ports in the scan results, use this command:
To perform a full TCP scan on all ports, use:
Ruby Script to Parse Nmap Results
Here’s a Ruby script that parses Nmap’s XML output and extracts information about open ports:
Export Full Sweep Results to CSV
To convert the full-sweep results into a CSV file, use the following:
EternalBlue (MS17-010) Vulnerability
MS17-010, also known as the EternalBlue vulnerability, is a critical flaw in Microsoft’s SMBv1 protocol, patched in March 2017. Exploited by the EternalBlue exploit, it allows remote code execution (RCE) on unpatched systems, enabling attackers to gain SYSTEM-level access and propagate malware across networks. EternalBlue was used in the WannaCry and NotPetya ransomware attacks, which disrupted systems globally by targeting vulnerable SMBv1 services. To detect this vulnerability, use Nmap’s smb-vuln-ms17-010
script to scan port 445. Mitigation involves applying the MS17-010 patch, disabling SMBv1, and restricting access to SMB ports. This incident highlights the importance of patching systems and disabling outdated protocols to prevent widespread exploitation and worm-like propagation.
No comments:
Post a Comment