windows高危端口使用批量排查

发布时间:2023年12月26日
@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

文章来源:https://blog.csdn.net/weixin_43372364/article/details/135224560
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。