【问题标题】:Replace specific command line automatically and save the results自动替换特定命令行并保存结果
【发布时间】:2021-05-01 01:04:21
【问题描述】:

我想通过使用单个端口扫描命令行从我的一个服务器 IP 获取范围端口扫描结果。 (请不要向我推荐其他端口扫描器,例如具有端口范围扫描功能的 nmap :()

命令行示例如下 (我只是想用多个端口扫描一个特定的IP)

root@localhost: serverstats IP:Port

root@localhost: serverstats 1.1.1.1:2000
Result/output↓↓↓
root@localhost:  {"online": true}

我想做的事

root@localhost: serverstats 1.1.1.1:2200  〜    serverstats 1.1.1.1:2500  (About 300 ports)

命令结果/输出 -> root@localhost: {"online": true}

使用上述单端口扫描命令扫描单个 IP 上的 300 个端口范围,并将命令结果/输出自动保存在文本文件中,如下所示:)

300ports.log ↓

{"online": true}
{"online": false}
{"online": false}
{"online": true}
{"online": false}
..... (and remaining 295 port scan results)

谢谢!

【问题讨论】:

    标签: bash shell command-line automation command-line-arguments


    【解决方案1】:
    IP="1.1.1.1"
    for (( i=1;i<=300;i++ ));
    do 
       serverstats "$IP:$i"
    done | grep -E '\{"online": (false|true)}' > 300ports.log
    

    循环 300 次以生成端口号并使用这些来生成 serverstats 命令。将输出传送到 grep 以搜索输出以及“false”或“true”并将 grep 输出重定向到 300port.log

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-31
      • 1970-01-01
      • 2019-05-11
      • 2011-12-29
      • 2015-07-21
      • 1970-01-01
      • 1970-01-01
      • 2022-11-30
      相关资源
      最近更新 更多