nmap,port扫描,获取sshserver的ip地址

// 查看局域网的ip地址
arp - a         // 同一个网段。假设用虚拟机桥接则不行
sudo nmap -sS 192.168.1.*   //或者sudo nmap -sS -p 22 192.168.1.0/24; if you ip address is in 192.168.1.1-255.

注意:不同的參数对扫描时间和扫描结果有影响。可以尝试不同的參数组合(sudo nmap -sP -PS22 –open 10.10.40.1/24),只是记得加上sudo,不然因为nmap不能发送raw package而可能探測不到主机。一般探測都要指定扫描某些特定port(ssh 22,http 80等)。不然会非常费时间。

注意,nmap不要求目标机器在同一个网段。可是这样就不能得到目标主机的mac地址,比如虚拟机NAT模式扫描。假设在同一个网段(或者桥接模式)。则可以得到很多其它信息(mac地址。vendor名称等等)

几个经常使用命令(执行nmap - -help):

sudo nmap -sn 192.168.1.*       // Ping scan, diable port scan,高速找到主机。
// -p 指定port。--open仅仅显示打开的port;高速找打开22port的主机,ssh登陆用
sudo nmap -sS -p22 --open 192.168.1.*

nmap各个參数的功能:

-sP 渗透内网之后推断当前网络哪些主机在线。 -p 22 port号。ssh默认port为22 ; -sS为TCP SYN 扫描 (又称半开放,或隐身扫描):
    e.g. :  sudo nmap -p 22 --open -sV 10.0.0.0/24
    nmap : the executable name
-p 22 : specifies the port to test
--open : suppress output for clients that are not listening
-sV : display the version string reported by the scanned server
-sP : Check which hosts are live and up in Network, with this option nmap skips port detection and other things, its fast.
-sS : stealthy Scan
-PS : TCP ACK (PA) and TCP Syn (PS);or just -PA
    10.0.0.0/24 : the target network, could have been 192.168.0.0/24
    (/24 specifies a subnet of 255.255.255.0, look up slash notation)
原文地址:https://www.cnblogs.com/gcczhongduan/p/5229743.html