Estas lineas permiten listar los puertos abiertos y dirigir la información a un archivo de Texto: 

 

Puertos.BAT

netstat -an > gports

find «LISTENING» < gports > oports.txt

find «ESTABLISHED» < gports >> oports.txt

del gports

 

Resultado:

  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING

  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING

  TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING

  TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING

  TCP    0.0.0.0:49154          0.0.0.0:0              LISTENING

  TCP    0.0.0.0:49155          0.0.0.0:0              LISTENING

  TCP    0.0.0.0:49157          0.0.0.0:0              LISTENING

  TCP    10.107.194.227:139     0.0.0.0:0              LISTENING

  TCP    [::]:135               [::]:0                 LISTENING

  TCP    [::]:445               [::]:0                 LISTENING

  TCP    [::]:49152             [::]:0                 LISTENING

  TCP    [::]:49153             [::]:0                 LISTENING

  TCP    [::]:49154             [::]:0                 LISTENING

  TCP    [::]:49155             [::]:0                 LISTENING

  TCP    [::]:49157             [::]:0                 LISTENING

  TCP    [::1]:49156            [::]:0                 LISTENING

  TCP    10.107.194.227:64208   172.18.132.51:59683    ESTABLISHED

  TCP    10.107.194.227:64222   172.18.132.35:2502     ESTABLISHED

  TCP    10.107.194.227:64223   172.18.132.35:2502     ESTABLISHED

  TCP    10.107.194.227:64229   172.18.132.200:1025    ESTABLISHED