Skip to content

Commit

Permalink
new: tcp.ports line grabber will send some data with newlines at the …
Browse files Browse the repository at this point in the history
…beginning
  • Loading branch information
evilsocket committed Jan 31, 2024
1 parent ae864f2 commit 0c43394
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plugins/tcp_ports/grabbers/line.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tokio::io::AsyncReadExt;
use tokio::io::{AsyncReadExt, AsyncWriteExt};

use super::Banner;
use crate::utils::net::StreamLike;
Expand Down Expand Up @@ -29,13 +29,16 @@ async fn read_line_from(mut stream: Box<dyn StreamLike>) -> String {
pub(crate) async fn line_grabber(
address: &str,
port: u16,
stream: Box<dyn StreamLike>,
mut stream: Box<dyn StreamLike>,
timeout: Duration,
) -> Banner {
log::debug!("grabbing line banner from {}:{} ...", address, port);

let mut banner = Banner::default();

// send something
let _ = stream.write_all("hello\r\n\r\n".as_bytes()).await;

let timeout = std::time::Duration::from_millis((timeout.as_millis() / 2) as u64);
if let Ok(line) = tokio::time::timeout(timeout, read_line_from(stream)).await {
if !line.is_empty() {
Expand Down

0 comments on commit 0c43394

Please sign in to comment.