在指定的过滤器选择字符串或findstr

时间:2019-04-30 11:23:23

标签: findstr select-string

PS C:\ Windows \ system32> nmap -sP 10.0.1.0/24

从2019-04-30 13:13 Vest-Europa(sommertid)开始使用Nmap 7.70(https://nmap.org
适用于10.0.1.1的Nmap扫描报告
主机已启动(延迟为0.12s)。
MAC地址:90:72:40:04:F7:85(Apple)
Nmap扫描报告10.0.1.2
主机已启动(延迟为0.13秒)。
MAC地址:84:C7:EA:43:1D:27(Sony Mobile Communications AB)

如果具有nmap的搜索子网将看起来像这样。 如果我仅对苹果使用select-string进行过滤,它将做出如下响应:

nmap -sP 10.0.2.0/24 | Select-String "Apple"

MAC地址:90:72:40:04:F7:85(Apple)

我如何对其进行过滤以获得:

1.0.1.1的Nmap扫描报告 主机已启动(0.12秒延迟)。 MAC地址:90:72:40:04:F7:85(Apple)

还有Apple Line +前2行吗?

1 个答案:

答案 0 :(得分:0)

nmap -sP 10.0.2.0/24 | Select-String "Apple" -Context 2,0

我找到了解决方案。此代码搜索供应商,并在包含ip之前添加2行。

bash中的相同功能是:

nmap -sP 10.0.2.0/24 | grep -B 2 "Climax"

相关问题