Skip to content

Commit

Permalink
如果没有协议默认尝试https和http
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Jul 22, 2024
1 parent 3309fde commit 5eddca4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log

<!-- next-header -->
## [2024.7.22] - 2024.7.22

### Fixes

- 如果没有协议默认尝试https和http

## [2024.7.20] - 2024.7.20

### Fixes
Expand Down
35 changes: 32 additions & 3 deletions observer_ward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use engine::matchers::FaviconMap;
use engine::request::RequestGenerator;
use engine::results::{FingerprintResult, NucleiResult};
use engine::slinger::http::header::HeaderValue;
use engine::slinger::http::uri::Uri;
use engine::slinger::http::uri::{PathAndQuery, Uri};
use engine::slinger::http::StatusCode;
use engine::slinger::redirect::{only_same_host, Policy};
use engine::slinger::{http_serde, Request, Response};
Expand Down Expand Up @@ -334,7 +334,23 @@ fn input_to_byte(payload: &str) -> Vec<u8> {
}
buf
}

fn set_uri_scheme(scheme: &str, target: &Uri) -> Result<Uri> {
Uri::builder()
.scheme(scheme)
.authority(
target
.authority()
.map_or(target.host().unwrap_or_default(), |a| a.as_str()),
)
.path_and_query(
target
.path_and_query()
.unwrap_or(&PathAndQuery::from_static("/"))
.as_str(),
)
.build()
.map_err(|e| new_io_error(&e.to_string()))
}
pub fn parse_yaml(yaml_path: &PathBuf) -> Result<Template> {
let name = yaml_path
.file_name()
Expand Down Expand Up @@ -478,12 +494,25 @@ impl ObserverWard {
debug!("{}: {}", Emoji("🚦", "start"), target);
let mut runner = ClusterExecuteRunner::new(&target);
match target.scheme_str() {
None => {
// 如果没有协议尝试https和http
let schemes = vec!["https", "http"];
for scheme in schemes {
if let Ok(http_target) = set_uri_scheme(scheme, &target) {
runner.target = http_target;
self.http(&mut runner);
if !runner.matched_result.is_empty() {
break;
}
}
}
}
// 只跑web指纹
Some("http") | Some("https") => {
self.http(&mut runner);
}
// 只跑服务指纹
None | Some("tcp") | Some("tls") => {
Some("tcp") | Some("tls") => {
if let Some(tcp) = &self.cluster_type.tcp_default {
if let Err(_err) = runner.tcp(&self.config, tcp) {
return runner.matched_result;
Expand Down

0 comments on commit 5eddca4

Please sign in to comment.