windows高危端口使用批量排查

@echo off

REM 设置要检测的多个端口
set "PORTS=111 389 445 873 1521 2049 2181 2222 2375 2379 288 3128 3306 3389 3690 3888 4000 4040 4848 4899 5000 5005 5601 5631 5632 5900 5984 6123 6379 7001 7051 7077 7180 7182 7848 8019 8020 8042 8048 8051 8069 8080 8081 8088 8161 8443 8649 8848 8880 3888 9000 9001 9042 9043 9083 9092 9100 9200 9300 9990 10000 11000 19888 20880 25000 25010 27017 50000 50030 50070 50090 60000 60010 60030 27017 27018 8083 8084 8085 8086"

REM 清空结果文件
echo Port Checking Results > port_results.txt
echo. >> port_results.txt

REM 逐个检查端口并将结果追加到文件中
for %%P in (%PORTS%) do (
    REM 使用 Test-NetConnection 检查端口状态并将结果追加到文件
    powershell -Command "$result = Test-NetConnection -ComputerName localhost -Port %%P -InformationLevel Quiet; if ($result) { 'Port %%P is open' } else { 'Port %%P is closed' }" >> port_results.txt
    echo Results for port %%P appended to port_results.txt
)

echo All results saved to port_results.txt
pause

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值