溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

nmap掃描端口給出的結(jié)果為什么與Python不同

發(fā)布時(shí)間:2022-02-23 10:47:38 來源:億速云 閱讀:206 作者:iii 欄目:開發(fā)技術(shù)

這篇“nmap掃描端口給出的結(jié)果為什么與Python不同”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“nmap掃描端口給出的結(jié)果為什么與Python不同”文章吧。

我有一個(gè)易受攻擊的框與IP 192.168.41.2和端口掃描與nmap導(dǎo)致:

nmap -T4 -p- 192.168.41.2
Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-27 15:13 EDT
Nmap scan report for 192.168.41.2
Host is up (0.00024s latency).
All 65535 scanned ports on 192.168.41.2 are closed
MAC Address: 00:50:56:EA:44:EB (VMware)

Nmap done: 1 IP address (1 host up) scanned in 2.72 seconds

告訴我沒有開放的端口。然后,我用Python腳本檢查結(jié)果:

from scapy.all import *
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('ip')
args = parser.parse_args()
ip = args.ip

ports = [i for i in range(65535)]

def synScan(host):
    resp, _ = sr(IP(dst=host)/TCP(sport=5555, dport=ports, flags='S'), timeout=2, verbose=0)
    print(f'Open ports on {host}:\n')
    for s, r in resp:
        if s[TCP].dport == r[TCP].sport:
            print(f'TCP Port {s[TCP].dport} is open.')


synScan(ip)

通過運(yùn)行執(zhí)行腳本,導(dǎo)致:python3 port_scanner.py 192.168.41.2

Open ports on host 192.168.41.2:
TCP Port 0 is open.
TCP Port 1 is open.
TCP Port 2 is open.
TCP Port 3 is open.
TCP Port 4 is open.
TCP Port 5 is open.
TCP Port 6 is open.
TCP Port 7 is open.
TCP Port 8 is open.
TCP Port 9 is open.
TCP Port 10 is open.
TCP Port 11 is open.
TCP Port 12 is open.
TCP Port 13 is open.
TCP Port 14 is open.
TCP Port 15 is open.
TCP Port 16 is open.
TCP Port 17 is open.
TCP Port 18 is open.
TCP Port 19 is open.
TCP Port 20 is open.
TCP Port 21 is open.
TCP Port 22 is open.
TCP Port 23 is open.
TCP Port 24 is open.
...
...

我的問題是我應(yīng)該更信任哪種掃描?Nmap 是非常流行的網(wǎng)絡(luò)掃描儀和替罪羊是相當(dāng)受歡迎的, 但在這里你看到的結(jié)果。

解答

如果您收到了對(duì)SYN包的應(yīng)答,那么該端口將被認(rèn)定為打開的。這是錯(cuò)誤的。例如,如果是RST報(bào)文,則關(guān)閉該端口。這個(gè)腳本告訴我們端口是否被過濾了。

因此,如果您想使用scapy,還必須檢查應(yīng)答包是否也設(shè)置了SYN包。

以上就是關(guān)于“nmap掃描端口給出的結(jié)果為什么與Python不同”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI