Skip to content

Commit 1cf37e3

Browse files
authored
Merge pull request #884 from epi052/878-support-raw-urls
878 support raw urls
2 parents ec78ec3 + 9876759 commit 1cf37e3

File tree

13 files changed

+392
-65
lines changed

13 files changed

+392
-65
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "feroxbuster"
3-
version = "2.9.4"
3+
version = "2.9.5"
44
authors = ["Ben 'epi' Risher (@epi052)"]
55
license = "MIT"
66
edition = "2021"

shell_completions/_feroxbuster

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ _feroxbuster() {
2424
'--replay-proxy=[Send only unfiltered requests through a Replay Proxy, instead of all requests]:REPLAY_PROXY:_urls' \
2525
'*-R+[Status Codes to send through a Replay Proxy when found (default: --status-codes value)]:REPLAY_CODE: ' \
2626
'*--replay-codes=[Status Codes to send through a Replay Proxy when found (default: --status-codes value)]:REPLAY_CODE: ' \
27-
'-a+[Sets the User-Agent (default: feroxbuster/2.9.4)]:USER_AGENT: ' \
28-
'--user-agent=[Sets the User-Agent (default: feroxbuster/2.9.4)]:USER_AGENT: ' \
27+
'-a+[Sets the User-Agent (default: feroxbuster/2.9.5)]:USER_AGENT: ' \
28+
'--user-agent=[Sets the User-Agent (default: feroxbuster/2.9.5)]:USER_AGENT: ' \
2929
'*-x+[File extension(s) to search for (ex: -x php -x pdf js)]:FILE_EXTENSION: ' \
3030
'*--extensions=[File extension(s) to search for (ex: -x php -x pdf js)]:FILE_EXTENSION: ' \
3131
'*-m+[Which HTTP request method(s) should be sent (default: GET)]:HTTP_METHODS: ' \

shell_completions/_feroxbuster.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Register-ArgumentCompleter -Native -CommandName 'feroxbuster' -ScriptBlock {
3030
[CompletionResult]::new('--replay-proxy', 'replay-proxy', [CompletionResultType]::ParameterName, 'Send only unfiltered requests through a Replay Proxy, instead of all requests')
3131
[CompletionResult]::new('-R', 'R', [CompletionResultType]::ParameterName, 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)')
3232
[CompletionResult]::new('--replay-codes', 'replay-codes', [CompletionResultType]::ParameterName, 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)')
33-
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.9.4)')
34-
[CompletionResult]::new('--user-agent', 'user-agent', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.9.4)')
33+
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.9.5)')
34+
[CompletionResult]::new('--user-agent', 'user-agent', [CompletionResultType]::ParameterName, 'Sets the User-Agent (default: feroxbuster/2.9.5)')
3535
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'File extension(s) to search for (ex: -x php -x pdf js)')
3636
[CompletionResult]::new('--extensions', 'extensions', [CompletionResultType]::ParameterName, 'File extension(s) to search for (ex: -x php -x pdf js)')
3737
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Which HTTP request method(s) should be sent (default: GET)')

shell_completions/feroxbuster.elv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ set edit:completion:arg-completer[feroxbuster] = {|@words|
2727
cand --replay-proxy 'Send only unfiltered requests through a Replay Proxy, instead of all requests'
2828
cand -R 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)'
2929
cand --replay-codes 'Status Codes to send through a Replay Proxy when found (default: --status-codes value)'
30-
cand -a 'Sets the User-Agent (default: feroxbuster/2.9.4)'
31-
cand --user-agent 'Sets the User-Agent (default: feroxbuster/2.9.4)'
30+
cand -a 'Sets the User-Agent (default: feroxbuster/2.9.5)'
31+
cand --user-agent 'Sets the User-Agent (default: feroxbuster/2.9.5)'
3232
cand -x 'File extension(s) to search for (ex: -x php -x pdf js)'
3333
cand --extensions 'File extension(s) to search for (ex: -x php -x pdf js)'
3434
cand -m 'Which HTTP request method(s) should be sent (default: GET)'

src/banner/container.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ use super::entry::BannerEntry;
22
use crate::{
33
config::Configuration,
44
event_handlers::Handles,
5-
utils::{logged_request, status_colorizer},
5+
utils::{logged_request, parse_url_with_raw_path, status_colorizer},
66
DEFAULT_IGNORED_EXTENSIONS, DEFAULT_METHOD, DEFAULT_STATUS_CODES, VERSION,
77
};
88
use anyhow::{bail, Result};
99
use console::{style, Emoji};
10-
use reqwest::Url;
1110
use serde_json::Value;
1211
use std::{io::Write, sync::Arc};
1312

@@ -478,7 +477,7 @@ by Ben "epi" Risher {} ver: {}"#,
478477
pub async fn check_for_updates(&mut self, url: &str, handles: Arc<Handles>) -> Result<()> {
479478
log::trace!("enter: needs_update({}, {:?})", url, handles);
480479

481-
let api_url = Url::parse(url)?;
480+
let api_url = parse_url_with_raw_path(url)?;
482481

483482
let result = logged_request(&api_url, DEFAULT_METHOD, None, handles.clone()).await?;
484483
let body = result.text().await?;

src/config/container.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use super::utils::{
66
use crate::config::determine_output_level;
77
use crate::config::utils::determine_requester_policy;
88
use crate::{
9-
client, parser, scan_manager::resume_scan, traits::FeroxSerialize, utils::fmt_err,
9+
client, parser,
10+
scan_manager::resume_scan,
11+
traits::FeroxSerialize,
12+
utils::{fmt_err, parse_url_with_raw_path},
1013
DEFAULT_CONFIG_NAME,
1114
};
1215
use anyhow::{anyhow, Context, Result};
@@ -673,7 +676,7 @@ impl Configuration {
673676
for denier in arg {
674677
// could be an absolute url or a regex, need to determine which and populate the
675678
// appropriate vector
676-
match Url::parse(denier.trim_end_matches('/')) {
679+
match parse_url_with_raw_path(denier.trim_end_matches('/')) {
677680
Ok(absolute) => {
678681
// denier is an absolute url and can be parsed as such
679682
config.url_denylist.push(absolute);

src/event_handlers/scans.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
use super::command::Command::AddToUsizeField;
1717
use super::*;
1818
use crate::statistics::StatField;
19-
use reqwest::Url;
19+
use crate::utils::parse_url_with_raw_path;
2020
use tokio::time::Duration;
2121

2222
#[derive(Debug)]
@@ -325,7 +325,9 @@ impl ScanHandler {
325325
self.data.add_directory_scan(&target, order).1 // add the new target; return FeroxScan
326326
};
327327

328-
if should_test_deny && should_deny_url(&Url::parse(&target)?, self.handles.clone())? {
328+
if should_test_deny
329+
&& should_deny_url(&parse_url_with_raw_path(&target)?, self.handles.clone())?
330+
{
329331
// response was caught by a user-provided deny list
330332
// checking this last, since it's most susceptible to longer runtimes due to what
331333
// input is received

src/extractor/container.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ use crate::{
1111
StatField::{LinksExtracted, TotalExpected},
1212
},
1313
url::FeroxUrl,
14-
utils::{logged_request, make_request, send_try_recursion_command, should_deny_url},
14+
utils::{
15+
logged_request, make_request, parse_url_with_raw_path, send_try_recursion_command,
16+
should_deny_url,
17+
},
1518
ExtractionResult, DEFAULT_METHOD,
1619
};
1720
use anyhow::{bail, Context, Result};
@@ -122,7 +125,7 @@ impl<'a> Extractor<'a> {
122125
) -> Result<()> {
123126
log::trace!("enter: parse_url_and_add_subpaths({:?})", links);
124127

125-
match Url::parse(url_to_parse) {
128+
match parse_url_with_raw_path(url_to_parse) {
126129
Ok(absolute) => {
127130
if absolute.domain() != original_url.domain()
128131
|| absolute.host() != original_url.host()
@@ -475,7 +478,7 @@ impl<'a> Extractor<'a> {
475478
ExtractionTarget::ResponseBody | ExtractionTarget::DirectoryListing => {
476479
self.response.unwrap().url().clone()
477480
}
478-
ExtractionTarget::RobotsTxt => match Url::parse(&self.url) {
481+
ExtractionTarget::RobotsTxt => match parse_url_with_raw_path(&self.url) {
479482
Ok(u) => u,
480483
Err(e) => {
481484
bail!("Could not parse {}: {}", self.url, e);
@@ -524,7 +527,7 @@ impl<'a> Extractor<'a> {
524527

525528
for capture in self.robots_regex.captures_iter(body) {
526529
if let Some(new_path) = capture.name("url_path") {
527-
let mut new_url = Url::parse(&self.url)?;
530+
let mut new_url = parse_url_with_raw_path(&self.url)?;
528531

529532
new_url.set_path(new_path.as_str());
530533

@@ -654,7 +657,7 @@ impl<'a> Extractor<'a> {
654657
&client
655658
};
656659

657-
let mut url = Url::parse(&self.url)?;
660+
let mut url = parse_url_with_raw_path(&self.url)?;
658661
url.set_path(location); // overwrite existing path
659662

660663
// purposefully not using logged_request here due to using the special client

src/filters/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use crate::event_handlers::Handles;
44
use crate::filters::similarity::SIM_HASHER;
55
use crate::nlp::preprocess;
66
use crate::response::FeroxResponse;
7-
use crate::utils::logged_request;
7+
use crate::utils::{logged_request, parse_url_with_raw_path};
88
use crate::DEFAULT_METHOD;
99
use anyhow::Result;
1010
use regex::Regex;
11-
use reqwest::Url;
1211
use std::sync::Arc;
1312

1413
/// wrapper around logic necessary to create a SimilarityFilter
@@ -23,7 +22,7 @@ pub(crate) async fn create_similarity_filter(
2322
handles: Arc<Handles>,
2423
) -> Result<SimilarityFilter> {
2524
// url as-is based on input, ignores user-specified url manipulation options (add-slash etc)
26-
let url = Url::parse(similarity_filter)?;
25+
let url = parse_url_with_raw_path(similarity_filter)?;
2726

2827
// attempt to request the given url
2928
let resp = logged_request(&url, DEFAULT_METHOD, None, handles.clone()).await?;

0 commit comments

Comments
 (0)