0

if i scan which nmap one target and i use output grepable option (-oG) if have this output

nmap -sS -oG - 192.168.1.1
Status: Up
Host: 192.168.1.1 ()  Ports: 20/closed/tcp//ftp-data///, 21/open/tcp//ftp///, 22/closed/tcp//ssh///, 43/closed/tcp//whois///, 80/open/tcp//http///
# Nmap done at Thu Dec 12 11:32:36 2

As you can see the line who indicate the ports number have no newline. For use grep it's no easy... :)

I'am on debian wheezy, i use bash, how can i correct this?

Thanks

4

2 回答 2

1

好吧,尽管他们称其为“grepable”输出,但它更多的是由 awk、sed 或 Perl 等工具解析的。

NMAP 网站上有很多有用的信息。

这些字段也由制表符分隔,所以我会从例如开始。cut -f5 file获取您想要的字段,然后您可以使用 say 进行精细解析awk -F/ '{print $2}'。我不确定输出的哪一部分是感兴趣的。

Perl 也可以按照他们网页上的描述解析输出,但这可能不是必需的。

于 2013-12-12T11:04:53.303 回答
0

该输出没有任何问题。Grepable 格式设计为每个主机有一行,因此您可以 grep 为所有打开特定端口的主机。

如果你想要的只是那些打开的端口的列表,你可以告诉 Nmap 只打印那些带有--open选项的端口:

sh$ nmap -p 80,22 localhost -oG - -n -Pn --open
# Nmap 6.41SVN scan initiated Thu Dec 12 08:40:03 2013 as: nmap -p 80,22 -oG - -n -Pn --open localhost
Host: 127.0.0.1 ()  Status: Up
Host: 127.0.0.1 ()  Ports: 22/open/tcp//ssh///  Ignored State: closed (1)
# Nmap done at Thu Dec 12 08:40:03 2013 -- 1 IP address (1 host up) scanned in 0.08 seconds
于 2013-12-12T14:46:46.567 回答