PowerShell ile uzak bir domaine ait DNS kayıtlarına hangi portunun erişilebilir durum da olduğunu tespit edebilirsiniz

İlk olarak ping komutununa benzeyen size özet rapor sunan komutla başlamak isterim.

Test-NetConnection -ComputerName  <domain adı>

PS C:\Users\Administrator> Test-NetConnection -ComputerName  ozan.com
 
 
ComputerName           : ozanmemis.com
RemoteAddress          : 192.168.2.158
InterfaceAlias         : uplink
SourceAddress          : 192.168.2.237
PingSucceeded          : True
PingReplyDetails (RTT) : 5 ms

Daha fazla detaylı bilgi almak için

Test-NetConnection -ComputerName <domain adı>  -InformationLevel  Detailed

PS C:\Users\Administrator> Test-NetConnection -ComputerName  ozan.com  -InformationLevel  Detailed
 
 
ComputerName           : ozan.com
RemoteAddress          : 192.168.2.158
NameResolutionResults  : 192.168.2.158
InterfaceAlias         : uplink
SourceAddress          : 192.168.2.237
NetRoute (NextHop)     : 192.168.2.225
PingSucceeded          : True
PingReplyDetails (RTT) : 5 ms

PowerShell komutları ile tracert çıktısı almak isterseniz aşağıdaki komutu kullabilirsiniz.

Test-NetConnection  <domain adı>  -TraceRoute

PS C:\Users\Administrator> Test-NetConnection  ozan.com  -TraceRoute
 
 
ComputerName           : ozan.com
RemoteAddress          : 192.168.2.158
InterfaceAlias         : uplink
SourceAddress          : 192.168.2.237
PingSucceeded          : True
PingReplyDetails (RTT) : 0 ms
TraceRoute             : *.*.*.225
                         10.*.*.190
                         10.*.*.30
                         192.168.2.158

Uzak bir sunucu üzerinde aktif olan portu kontrol etmek için aşağıdaki komutu kullanabilrisiniz.

Test-NetConnection -ComputerName <Domain adı> -Port 80

PS C:\Users\Administrator> Test-NetConnection -ComputerName ozan.com -Port 80
 
 
ComputerName     : ozan.com
RemoteAddress    : 192.168.2.158
RemotePort       : 80
InterfaceAlias   : uplink
SourceAddress    : 192.168.2.237
TcpTestSucceeded : True

Domain sorgulama yada CMD de yakından tanıdığınız nslookup komutu için PowerShell üzerinde Resolve-DnsName komutunu kullanabilirsiniz.

Resolve-DnsName <domain adı>

Resolve-DnsName ozan.com
 
Name                                           Type   TTL   Section    IPAddress
----                                           ----   ---   -------    ---------
         ozan.com                              A      3599  Answer     192.168.2.158

Aynı komutun varyasyonaları aşağıkdaki gibidir.

PS C:\Users\Administrator> Resolve-DnsName ozan.com ns
 
Name                    Type   TTL   Section    NameHost
----                         ----   ---   -------    --------
ozan.com              NS     3599  Answer     ns4.ozan.net
ozan.com              NS     3599  Answer     ns3.ozan.net
ozan.com              NS     3599  Answer     ns1.ozan.net
ozan.com              NS     3599  Answer     ns2.ozan.net
 
 
PS C:\Users\Administrator> Resolve-DnsName ozan.com mx
 
Name                              Type   TTL   Section    NameExchange                              Preference
----                                  ----       ---   -------     ------------                                     ----------
ozan.com                        MX     3599  Answer     mx01.ozan.net                              10
 
 
PS C:\Users\Administrator> Resolve-DnsName ozan.com a
 
Name                                           Type   TTL   Section    IPAddress
----                                                ----   ---   -------    ---------
ozan.com                                     A      3599  Answer     192.168.2.158
 
 
PS C:\Users\Administrator> Resolve-DnsName ozan.com txt
 
Name                                     Type   TTL   Section    Strings
----                                          ----   ---   -------    -------
ozan.com                               TXT    3599  Answer     {v=spf1 a mx a:mail.emreozanmemis.com
                                                                 ip4:192.168.2.227 -all}

Bir diğer önemli komutumuz Get-NetTCPConnection bu komut ile netstat komutuyla laışkın olduğunuz bilgisayar yada sunucunuzun gitmek istediği IP ve portları listeler

PS C:\Users\Administrator> Get-NetTCPConnection
 
LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting OwningProcess
------------                        --------- -------------                       ---------- -----       -------------- -------------
::                                  53373     ::                                  0          Bound                      3080
::                                  53372     ::                                  0          Bound                      3080
::                                  53371     ::                                  0          Bound                      3080
::                                  53370     ::                                  0          Bound                      3080
::1                                 53704     ::1                                 5985       TimeWait                   0
::1                                 53702     ::1                                 5985       TimeWait                   0
fe80::ec86:f3c2:2bf3:2530%26        53373     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        53372     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        53371     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        53370     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
::                                  51794     ::                                  0          Listen                     144
::                                  49673     ::                                  0          Listen                     756
::                                  49670     ::                                  0          Listen                     732
::                                  49669     ::                                  0          Listen                     2600
::                                  49668     ::                                  0          Listen                     2852
::                                  49667     ::                                  0          Listen                     2444
::                                  49666     ::                                  0          Listen                     1716
::                                  49665     ::                                  0          Listen                     1328
::                                  49664     ::                                  0          Listen                     588
::                                  47001     ::                                  0          Listen                     4
::                                  30000     ::                                  0          Listen                     6340
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53373      Established Datacenter     4
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53372      Established Datacenter     4
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53371      Established Datacenter     4
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53370      Established Datacenter     4
::                                  5985      ::                                  0          Listen                     4
::                                  5357      ::                                  0          Listen                     4
::                                  3389      ::                                  0          Listen                     1044
::                                  1688      ::                                  0          Listen                     6820
::                                  445       ::                                  0          Listen                     4
::                                  443       ::                                  0          Listen                     4
::                                  135       ::                                  0          Listen                     1020
0.0.0.0                             53699     0.0.0.0                             0          Bound                      716
0.0.0.0                             52729     0.0.0.0                             0          Bound                      2988
0.0.0.0                             52636     0.0.0.0                             0          Bound                      716
178.18.199.237                      53703     52.114.158.91                       443        TimeWait                   0
178.18.199.237                      53699     178.18.203.68                       443        Established Datacenter     716
178.18.199.237                      52729     40.67.248.104                       443        Established Internet       2988
178.18.199.237                      52636     178.18.203.68                       443        Established Datacenter     716
0.0.0.0                             51794     0.0.0.0                             0          Listen                     144
0.0.0.0                             49673     0.0.0.0                             0          Listen                     756
0.0.0.0                             49670     0.0.0.0                             0          Listen                     732
0.0.0.0                             49669     0.0.0.0                             0          Listen                     2600
0.0.0.0                             49668     0.0.0.0                             0          Listen                     2852
0.0.0.0                             49667     0.0.0.0                             0          Listen                     2444
0.0.0.0                             49666     0.0.0.0                             0          Listen                     1716
0.0.0.0                             49665     0.0.0.0                             0          Listen                     1328
0.0.0.0                             49664     0.0.0.0                             0          Listen                     588
0.0.0.0                             30000     0.0.0.0                             0          Listen                     6340
192.168.2.237                      5985      178.18.203.68                       51497      Established Datacenter     4
192.168.2.237                      5985      178.18.203.68                       51503      Established Datacenter     4
192.168.2.237                      3389      213.129.128.243                     56029      Established Internet       1044
192.168.2.237                      3389      51.143.161.146                      60961      CloseWait   Internet       1044
192.168.2.237                      3389      85.97.199.193                       52504      Established Internet       1044
192.168.2.237                      3389      91.235.177.126                      58732      Established Internet       1044
192.168.2.237                      3389      223.197.184.103                     64908      CloseWait   Internet       1044
192.168.2.237                      3389      91.235.177.126                      55739      Established Internet       1044
192.168.2.237                      3389      107.173.58.52                       61154      Established Internet       1044
192.168.2.237                      3389      163.172.22.247                      9514       Established Internet       1044
192.168.2.237                      3389      185.198.72.246                      54146      Established Datacenter     1044
0.0.0.0                             3389      0.0.0.0                             0          Listen                     1044
0.0.0.0                             1688      0.0.0.0                             0          Listen                     6820
192.168.1.25                        139       0.0.0.0                             0          Listen                     4
192.168.2.237                      139       0.0.0.0                             0          Listen                     4
0.0.0.0                             135       0.0.0.0                             0          Listen                     1020

Sadece IP adreslerini görüntülemek isterseniz Get-NetTCPConnection -State Established komutu ile yapabilirsiniz.

PS C:\Users\Administrator> Get-NetTCPConnection -State Established
 
LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting OwningProcess
------------                        --------- -------------                       ---------- -----       -------------- -------------
fe80::ec86:f3c2:2bf3:2530%26        53373     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        53372     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        53371     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        53370     fe80::ec86:f3c2:2bf3:2530%26        5985       Established Datacenter     3080
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53373      Established Datacenter     4
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53372      Established Datacenter     4
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53371      Established Datacenter     4
fe80::ec86:f3c2:2bf3:2530%26        5985      fe80::ec86:f3c2:2bf3:2530%26        53370      Established Datacenter     4
192.168.2.237                      53705     178.18.203.68                       443        Established Internet       716
192.168.2.237                      52729     40.67.248.104                       443        Established Internet       2988
192.168.2.237                      52636     178.18.203.68                       443        Established Datacenter     716
192.168.2.237                      5985      178.18.203.68                       51601      Established Datacenter     4
192.168.2.237                      5985      178.18.203.68                       51594      Established Datacenter     4
192.168.2.237                      3389      213.129.128.243                     52558      Established Internet       1044
192.168.2.237                      3389      85.97.199.193                       52504      Established Internet       1044