From 7e8573e75a0d8b96371ac9335f5036d72e99ce2c Mon Sep 17 00:00:00 2001 From: Shrecknt <58538423+Shrecknt@users.noreply.github.com> Date: Thu, 22 Feb 2024 13:47:35 -0800 Subject: [PATCH] add option to change scanner port --- README.md | 1 + Snowstorm.toml.example | 1 + crates/config/src/lib.rs | 7 ++++++- crates/io/src/pnet/mod.rs | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcc1ff3..5f10343 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,6 @@ nano Snowstorm.toml # modify Snowstorm.toml to your liking cd web npm run build cd .. +iptables -A INPUT -p tcp --dport 61000 -j DROP # prevent os from closing the connections cargo r -r --bin snowstorm ``` \ No newline at end of file diff --git a/Snowstorm.toml.example b/Snowstorm.toml.example index a636c2d..300ebae 100644 --- a/Snowstorm.toml.example +++ b/Snowstorm.toml.example @@ -27,6 +27,7 @@ secret = "some random key" [scanner] enabled = true interface_name = "eth0" +source_port = 61000 task_size_sanity_limit = 1000000 mode_duration = 300 push_to_db = true diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d3bdf0a..d1f8123 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -64,6 +64,8 @@ pub struct ScannerConfig { #[default = false] pub enabled: bool, pub interface_name: String, + #[serde(default = "default_source_port")] + pub source_port: u16, pub task_size_sanity_limit: u64, pub mode_duration: u64, #[serde(default = "_true")] @@ -113,6 +115,9 @@ pub struct OauthForgejoConfig { pub user_api_uri: String, } -fn _true() -> bool { +const fn _true() -> bool { true } +const fn default_source_port() -> u16 { + 61000 +} diff --git a/crates/io/src/pnet/mod.rs b/crates/io/src/pnet/mod.rs index 27dbc5c..1e7552e 100644 --- a/crates/io/src/pnet/mod.rs +++ b/crates/io/src/pnet/mod.rs @@ -27,7 +27,7 @@ impl PnetScanner { state: Arc>, sender: Sender<(PingResult, Vec)>, ) -> Self { - let source_port = SourcePort::Number(61000); + let source_port = SourcePort::Number(config::get().scanner.source_port); let socket = StatelessTcp::new(source_port); let syn_writer = socket.write.clone(); tokio::spawn(async move { receive::start_server(socket, sender).await });