Tuesday, May 21, 2019

Using PowerShell as a port scanner

I've been having a lot of servers lately that have been stood up for me by the hero's in our IT department (that is not sarcasm - these guys are awesome) without having the right holes poked in the firewall.

For instance, SQL Server listens, by default on port 1433. (NOTE: Best practice for server hardening is to change the default instance name and port)

To test this, I'd been using a clunky old port scanner that I wasn't happy with.

I therefore googled and found this excellent blog post by jblanchard.

The portion that I actually use is this:

PowerShell port scanner:
1..1024 | % {echo ((new-object Net.Sockets.TcpClient).Connect("10.0.0.100",$_)) "Port $_ is open!"} 2>$null

I usually change the first bit to 1433 (or whatever specific port I want to check )
1433 | % {echo ((new-object Net.Sockets.TcpClient).Connect("Myserver.MyDomain.com",$_)) "Port $_ is open!"} 2>$null

No comments:

DBT-50000 when using DBCA.bat on Windows (Oracle 19.11)

I’ve been having some trouble getting DBCA to run in order to create databases. Thought I’d share it with you, and thus document it for la...