Skip to content

Commit

Permalink
refactor(shoot): use verbose mode to grab info else don't even make a…
Browse files Browse the repository at this point in the history
… request
  • Loading branch information
pwnwriter committed Nov 3, 2023
1 parent fc52b80 commit d15d64c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ jobs:
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Install deps
run: wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
run: dpkg -i google-chrome-stable_current_amd64.deb
run: apt-get install -f
- name: Run Test over domains
run: curl -qfsSL "https://raw.githubusercontent.com/Azathothas/CertStream-Domains/main/Data/np_ccTLDs/certstream_domains_np_all_24h_httpx.txt" | awk '{print $1}' | grep -i 'http' | sort -u | hxn -b "$(which google-chrome)" --stdin

4 changes: 2 additions & 2 deletions src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ pub struct Cli {
#[arg(long, default_value = "10")]
pub timeout: u64,

/// Silent mode (suppress all console output)
/// verbose mode to show status code,title and more
#[arg(long)]
pub silent: bool,
pub verbose: bool,
}

#[cfg(test)]
Expand Down
28 changes: 14 additions & 14 deletions src/cli/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn run(
width,
height,
timeout,
silent,
verbose,
}: Cli,
) -> anyhow::Result<()> {
let browser = Path::new(&binary_path);
Expand Down Expand Up @@ -73,17 +73,17 @@ pub async fn run(
if stdin {
env::set_current_dir(dump_dir)?;
let urls = super::hxn_helper::read_urls_from_stdin()?;
take_screenshot_in_bulk(&browser, urls, tabs, timeout, silent).await?;
take_screenshot_in_bulk(&browser, urls, tabs, timeout, verbose).await?;
} else {
match (url, file_path) {
(None, Some(file_path)) => {
let urls = super::hxn_helper::read_urls_from_file(file_path)?;
env::set_current_dir(dump_dir)?;
take_screenshot_in_bulk(&browser, urls, tabs, timeout, silent).await?;
take_screenshot_in_bulk(&browser, urls, tabs, timeout, verbose).await?;
}
(Some(url), None) => {
env::set_current_dir(dump_dir)?;
take_screenshot(&browser, url, timeout, silent).await?;
take_screenshot(&browser, url, timeout, verbose).await?;
}
_ => unreachable!(),
}
Expand Down Expand Up @@ -134,7 +134,7 @@ async fn take_screenshot(
browser: &Browser,
url: String,
timeout: u64,
silent: bool,
verbose: bool,
) -> anyhow::Result<()> {
let parsed_url = Url::parse(&url)?;
let client = reqwest::Client::builder()
Expand All @@ -143,15 +143,8 @@ async fn take_screenshot(
.trust_dns(true)
.build()?;

let response = time::timeout(
Duration::from_secs(timeout),
client.get(parsed_url.clone()).send(),
)
.await
.context(format!("[-] Timed out URL = {url}"))??;

let filename = format!("{}.png", url.replace("://", "-").replace('/', "_"));
let page = browser.new_page(parsed_url).await?;
let page = browser.new_page(parsed_url.clone()).await?;
page.save_screenshot(
CaptureScreenshotParams::builder()
.format(CaptureScreenshotFormat::Png)
Expand All @@ -160,7 +153,14 @@ async fn take_screenshot(
)
.await?;

if !silent {
if verbose {
let response = time::timeout(
Duration::from_secs(timeout),
client.get(parsed_url.clone()).send(),
)
.await
.context(format!("[-] Timed out URL = {url}"))??;

match page.get_title().await {
Ok(Some(title)) => show_info(url.clone(), title, response.status()),
_ => {
Expand Down

0 comments on commit d15d64c

Please sign in to comment.