Nmap端口扫描阵列

时间:2015-01-20 18:59:11

标签: arrays bash nmap

我正在做一个nmap bash脚本,我只是想知道是否有可能为我的port命令使用数组列表。例如:

port=[23,45,75,65]
for i in 21 do

nmap -p x,y 192.168.1.$i

done

e.g。在x,y地方,我想使用数字23,45

2 个答案:

答案 0 :(得分:0)

扫描一个端口数组已经内置到nmap中。有关语法的更多详细信息,请参阅http://nmap.org/book/man-port-specification.html,但此处的摘录可能会为您提供所需内容:

For example, the argument -p U:53,111,137,T:21-25,80,139,8080 would scan UDP ports 53, 111,and 137, as well as the listed TCP ports.

答案 1 :(得分:0)

我不确定这是不是你想要的,但你可以试试这个:

ports="23,45,75,65"

for i in 21 do
    nmap -p "$ports" 192.168.1.$i
done

你也可以这样做:

ports="23,45,75,65"
targets="1-25"
nmap -p "$ports" "192.168.1.$targets"
相关问题