NMap 將結果儲存到單獨的檔案中

NMap 將結果儲存到單獨的檔案中

我想知道是否有任何方法可以指定 IP 位址範圍並將每個位址的掃描結果保存到相同資料夾中的單獨檔案中。

因此掃描1.1.1.1、1.1.1.2、1.1.1.3,它們都保存到一個資料夾中,檔案名稱作為其IP位址。

我正在小螢幕上工作,這確實有助於使結果更容易理解。

答案1

您可以非常輕鬆地使用一個簡單的 Python3 腳本來循環範圍,為每個 ip 呼叫 nmap 並將其保存到不同的檔案中。

將其另存為nmapper.py並啟動python3 nmapper.py。 (如果您沒有安裝 Python3,您可能需要將其重寫為 bash 或您喜歡的任何內容。)

### just imports ###
import subprocess 
from netaddr import iter_iprange
### create range of IPs here ###
generator = iter_iprange('192.168.1.1', '192.168.1.2', step=1)
### launch nmap for ∀ instance and save it as .txt ###
for ip in generator:         
    stdout = subprocess.getoutput("nmap " + str(ip))
    with open(str(ip)+".txt",'w') as f: f.write(stdout)

相關內容