RustScan icon indicating copy to clipboard operation
RustScan copied to clipboard

CLI option to also show closed ports

Open fabianbees opened this issue 1 year ago • 3 comments

This PR introduces the new CLI option --closed, which enables the option to also show ports which are closed.

From a security perspective, it is very useful information to see whether we got any response at all for a given port, even when the response is a RST (conn-refused). It can indicate that our request was denied (or specifically blocked by a firewall).

Currently this behavior is behind the --closed CLI flag and not enabled by default. Nmap, for example, shows closed ports by default.

Regarding the output of the --closed option, it mimics the output for open ports, but instead of Open it shows Closed right before the IP Address.

If the -g (grepable) option is set, first all open ports are printed for each IPs, then the text closed ports: is printed and the same output is repeated for all closed ports.

Here is an example:
.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
| {}  }| { } |{ {__ {_   _}{ {__  /  ___} / {} \ |  `| |
| .-. \| {_} |.-._} } | |  .-._} }\     }/  /\  \| |\  |
`-' `-'`-----'`----'  `-'  `----'  `---' `-'  `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog         :
: https://github.com/RustScan/RustScan :
 --------------------------------------
TreadStone was here 🚀

[~] The config file is expected to be at "/********/.rustscan.toml"
[~] Automatically increasing ulimit value to 50000.
Closed [10.100.0.1]:22
Open [10.100.0.1]:2222
10.100.0.1 -> [2222]
closed ports:
10.100.0.1 -> [22]
And with the -g option:
10.100.0.1 -> [2222]
closed ports:
10.100.0.1 -> [22]

fabianbees avatar Jan 23 '25 07:01 fabianbees

I have rebased the feature onto master.

fabianbees avatar Feb 10 '25 09:02 fabianbees

@bee-san Can you please also have a look at this PR?

fabianbees avatar Mar 03 '25 08:03 fabianbees

thanks for this! has a merge conflict :(

bee-san avatar Nov 27 '25 02:11 bee-san