
IP アドレスの範囲を指定して、それぞれのスキャン結果を同じフォルダー内の別々のファイルに保存する方法があるかどうか知りたいです。
したがって、1.1.1.1、1.1.1.2、1.1.1.3 をスキャンすると、それらはすべてフォルダー内の IP アドレスをファイル名にしたファイルに保存されます。
私は小さな画面で作業しているので、結果がもっと分かりやすくなると本当に助かります。
答え1
範囲をループし、すべての IP に対して nmap を呼び出して別のファイルに保存する単純な Python3 スクリプトを簡単に使用できます。
これを として保存し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)