nmap -S的使用
时间: 2024-05-24 18:06:25 浏览: 164
nmap命令中的"-S"选项用于指定源IP地址。通过使用"-S"选项,您可以指定要在扫描中伪装的源IP地址。这对于欺骗目标主机非常有用,使其认为扫描来自另一个IP地址。
以下是使用nmap命令的"-S"选项的示例:
```shell
nmap -S 192.168.0.100 192.168.0.1
```
上述命令将使用源IP地址192.168.0.100进行扫描,目标IP地址为192.168.0.1。通过指定源IP地址,您可以隐藏真实的扫描源,并欺骗目标主机。
请注意,使用"-S"选项需要具有足够的权限才能伪装源IP地址。
相关问题
nmap -v scanme.nmap.org 扫描与 nmap -vv scanme.nmap.org 扫描的区别是什么
根据提供的引用[1],nmap是一款网络探测和安全审计工具。使用-v选项可以增加扫描的详细程度,使用-vv选项可以进一步增加详细程度。因此,nmap -v scanme.nmap.org扫描的详细程度比nmap -vv scanme.nmap.org扫描的详细程度要少。
下面是两个命令的示例:
1. nmap -v scanme.nmap.org扫描的输出示例:
```shell
Starting Nmap 7.80 ( https://nmap.org ) at 2021-08-17 09:30 PDT
Initiating Ping Scan at 09:30
Scanning scanme.nmap.org (45.33.32.156) [2 ports]
Completed Ping Scan at 09:30, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 09:30
Completed Parallel DNS resolution of 1 host. at 09:30, 0.02s elapsed
Initiating Connect Scan at 09:30
Scanning scanme.nmap.org (45.33.32.156) [1000 ports]
Discovered open port 80/tcp on 45.33.32.156
Discovered open port 22/tcp on 45.33.32.156
Completed Connect Scan at 09:30, 0.11s elapsed (1000 total ports)
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up (0.11s latency).
Other addresses for scanme.nmap.org (not scanned): 2600:3c03::f03c:91ff:fe18:bb2f
Not shown: 998 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds
```
2. nmap -vv scanme.nmap.org扫描的输出示例:
```shell
Starting Nmap 7.80 ( https://nmap.org ) at 2021-08-17 09:31 PDT
Initiating Ping Scan at 09:31
Scanning scanme.nmap.org (45.33.32.156) [2 ports]
Packet capture filter (device eth0): icmp and ((ip[20:2] - ip[16:2]) - ((ip[0]&0xf)<<2)) != 0
Completed Ping Scan at 09:31, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 09:31
Completed Parallel DNS resolution of 1 host. at 09:31, 0.02s elapsed
Initiating Connect Scan at 09:31
Scanning scanme.nmap.org (45.33.32.156) [1000 ports]
Discovered open port 80/tcp on 45.33.32.156
Discovered open port 22/tcp on 45.33.32.156
Completed Connect Scan at 09:31, 0.11s elapsed (1000 total ports)
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up, received syn-ack (0.11s latency).
Other addresses for scanme.nmap.org (not scanned): 2600:3c03::f03c:91ff:fe18:bb2f
Not shown: 998 filtered ports
Reason: 998 no-responses and 2 host-prohibited
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 56
80/tcp open http syn-ack ttl 56
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds
```
nmap -Pn -sU -sV -p1-65535扫描太慢了,能不能用python脚本优化一下,加快扫描速度。可以提通一个脚本样例给我不?
当然可以,您可以使用Python的nmap模块来实现优化扫描速度的功能,以下是一个简单的示例代码:
```python
import nmap
nm = nmap.PortScanner()
nm.scan(hosts='127.0.0.1', arguments='-Pn -sU -sV -p1-65535')
for host in nm.all_hosts():
print('Host: %s (%s)' % (host, nm[host].hostname()))
for proto in nm[host].all_protocols():
print('Protocol: %s' % proto)
lport = nm[host][proto].keys()
for port in lport:
print('Port: %s\tState: %s' % (port, nm[host][proto][port]['state']))
```
这段代码使用nmap模块首先构造一个nmap.PortScanner对象,在其中设置扫描的IP地址和扫描参数,然后通过循环遍历所有扫描到的主机和端口,并输出相应的信息。您可以按照自己的需求进行自定义修改。
阅读全文