How to detect live hosts in the intranet

How to detect live hosts in the intranet

During penetration testing, when we take down a server as a springboard to further penetrate the intranet, we often need to collect intranet assets through host survival detection and port scanning.

We can roughly divide the host scanning scenarios into three types: 1) directly execute under the webshell, scan and detect through the system's built-in commands or upload script tools; 2) penetrate the intranet through the rebound shell, and penetration testing frameworks such as msf come with some scanning modules; 3) scan the intranet through the socks proxy (such as proxychains+Nmap scanning).

Choose the most appropriate weapon in the appropriate scenario. For example, protocols that support survival detection include ARP, ICMP, SMB, UDP, NETBIOS, SNMP, etc.; port scanning methods that support port scanning include ACK scanning, SYN scanning, TCP scanning, UDP scanning, ICMP scanning, etc.

1. ping command

We often use ping to check network connectivity and telnet to test the connectivity of a specified port. Using the system's own commands to complete segment C detection is inefficient, but it is not easy to trigger security rules. If the server has a firewall turned on or ping is prohibited, the detection results will be affected.

Use the ping command to scan segment C in Windows:

  1. for /l %i in (1,1,255) do @ping 192.168.64.%i -w 1 -n 1|find /i " ttl ="

Use the ping command to scan segment C in Linux:

  1. for k in $( seq 1 255);do ping -c 1 192.168.99.$k|grep "ttl"|awk -F "[ :]+" '{print $4}'; done

In addition, you can also combine the system's own traceroute, arp, netstat and other commands to collect intranet information, curl and wget can be used for port detection.

2. Powershell

Scan the IP address survival through PowerShell script:

  1. powershell.exe -exec bypass -Command "Import-Module ./Invoke-TSPingSweep.ps1;Invoke-TSPingSweep -StartAddress 192.168.1.0 -EndAddress 192.168.1.255"

Script download address: https://gallery.technet.microsoft.com/scriptcenter/Invoke-TSPingSweep-b71f1b9b

Use PowerShell to implement basic port scanning functions.

Scanning multiple ports of a single IP:

  1. PS C:\Users\Bypass > 1..1024 | % {echo ((new-object Net.Sockets.TcpClient).Connect("192.168.246.44",$_)) "Port $_ is open!"} 2 > $null

Scanning a single port in a certain IP segment:

  1. foreach ($ip in 1..20) {Test-NetConnection -Port 80 -InformationLevel "Detailed" 192.168.1.$ip}

Scanner for a certain IP range & multiple ports

  1. 1..20 | % { $ a = $_; 1..1024 | % {echo ((new-object Net.Sockets.TcpClient).Connect("10.0.0.$a",$_)) "Port $_ is open!"} 2 > $null}

3. Intranet host detection based on MSF

When using msf to perform a rebound shell to penetrate the intranet, a quick scan is performed through the scanning module that comes with msf.

Host survival detection:

  1. auxiliary/scanner/discovery/arp_sweep ARP scan
  2. auxiliary/scanner/discovery/udp_sweep UDP scan
  3. auxiliary/scanner/netbios/nbname NETBIOS scan
  4. auxiliary/scanner/snmp/snmp_enum SNMP Scan
  5. auxiliary/scanner/smb/smb_version SMB Scan

Port Scanning:

  1. auxiliary/scanner/portscan/ack TCP ACK port scan
  2. auxiliary/scanner/portscan/ftpbounce FTP bounce port scanning
  3. auxiliary/scanner/portscan/syn SYN port scan
  4. auxiliary/scanner/portscan/tcp TCP port scanning
  5. auxiliary/scanner/portscan/xmas TCP XMas port scanning

4. Nmap scans the intranet

Nmap is a port scanner that can be used for host discovery, port scanning, version detection, OS detection, etc.

Usage scenario: Establish socks proxy, proxychains+Nmap scan intranet.

Support multiple scanning modes:

  • -sT: TCP scan
  • -sS: SYN scan-
  • sA: ACK scan
  • -sF: FIN scan
  • -sU: UDP scan
  • -sR: RPC scan
  • -sP: ICMP scan

Quickly scan all ports:

  1. nmap -sS -p 1-65535 -v 192.168.99.177

<<:  Interviewer: Do you understand secure data transmission?

>>:  Is WeChat and QQ file transfer too inhumane? Here's how to fix it

Recommend

Why use MAC address when we have IP address?

IP address and MAC address are both very importan...

Read this article only three times and you will never forget network layering!

This article is reprinted from the WeChat public ...

The "Six Mountains" that Block Operator Innovation

The recent discussion about the advanced construc...

PacificRack: $12/year KVM-1GB/20GB/2TB/Los Angeles Data Center

PacificRack is a domain name under QN Data Center...

5G latency is less than 1 millisecond and will it replace Wi-Fi? Not true!

As the fifth generation of mobile communication n...

5G becomes a strong driving force for edge computing

Edge computing is one of the most exciting new co...

The future of blockchain

The rise of the digital currency market represent...

A Preliminary Study on Software Defined Network (SDN)

【51CTO.com Quick Translation】Before 2008, the ent...

What role can fiber optic technology play in education?

In the ever-evolving field of education, technolo...

10 best practices to make your first IoT project a success

A recent Cisco study found that 75% of IoT projec...

What magical things happen when you enter a URL in your browser?

After entering the URL in the browser, the websit...