Defending Against Port Scans


1. Close unnecessary services on the targeted systems
Windows:
netstat -aon
tasklist /SVC /FI "pid eq <PID>"
for /f "tokens=2,3,5" %i in ('netstat -n -o ^| findstr /v "Active Proto"') do @echo [Local] %i && @echo [Remote] %j && tasklist /SVC /FI "pid eq %k" | findstr "\." && wmic process where "ProcessID=%k" get ExecutablePath | find /V "ExecutablePath" && echo.
Get-NetTCPConnection | select local*,remote*,state,@{Name="ProcessName";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}}, @{Name="ProcessPath";Expression={(Get-Process -Id $_.OwningProcess) | Select-Object Path }} | Format-Table -AutoSize
taskkill /F /PID <PID>
tasklist /FI /IM <Process name>

Linux:
netstat -tulpn
kill <PID>

Reference: https://www.acunetix.com/blog/articles/close-unused-open-ports/

2. Employ TCP Wrappers
Scanner will not receive any additional information from the port unless the scan is coming from a host or domain specified in the /etc/hosts.allow file. *


3. Limiting information provided by web server *
Apache *

3.1 httpd.conf
ServerTokens Prod
ServerSignature Off

3.2 Altered using modSecurity *


IIS
%windir%\system32\inetsrv\UrlScan\URLScan.ini
Set RemoveServerHeader to 1


4. Firewall



5. Port Knocking
Port Knocking Technique

Popular posts from this blog

Remote Desktop Protocol (RDP) Security

Penetration Testing - Network

Damn Vulnerable Web Services (DVWS) - Walkthrough

Offensive Security Testing Guide

Server Message Block (SMB) Security

Host Configuration Assessment - Windows