Skip to content

Commit

Permalink
fix: fixed parse_target by stripping elements that caused problems
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Nov 4, 2023
1 parent 5706061 commit f024462
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ impl Session {

// perform pre-emptive target validation
for target in &targets {
if let Err(e) = parse_target(target, 0) {
return Err(e);
}
parse_target(target, 0)?;
}

let runtime = Runtime::new(options.concurrency);
Expand Down
14 changes: 14 additions & 0 deletions src/utils/target/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ pub(crate) fn parse_target(target: &str, default_port: u16) -> Result<(String, u
));
}

// remove <proto>:// if present
let target = if target.contains("://") {
target.split_once("://").unwrap().1
} else {
target
};

// remove /<whatever> if present
let target = if target.contains('/') {
target.split_once('/').unwrap().0
} else {
target
};

let num_colons = target.matches(':').count();
let (address, port) = if num_colons <= 1 {
// domain or ipv4
Expand Down

0 comments on commit f024462

Please sign in to comment.