Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support asynchronous mode #1391

Merged
merged 19 commits into from
Oct 11, 2024
Merged

Support asynchronous mode #1391

merged 19 commits into from
Oct 11, 2024

Conversation

zrquan
Copy link
Contributor

@zrquan zrquan commented Sep 7, 2024

Description

This PR adds the --async parameter to enable asynchronous mode (close #643). In asynchronous mode, coroutines are used instead of threads to send network requests (use httpx).

I ran a few quick tests and found that the asynchronous mode really speeds up the scanning process. (uvloop can makes it even faster)

python dirsearch.py -u https://security-crawl-maze.app -e html -t 50  150.96s user 5.89s system 98% cpu 2:38.45 total
python dirsearch.py -u https://security-crawl-maze.app -e html --async  41.34s user 0.94s system 40% cpu 1:43.80 total
python dirsearch.py -u https://security-crawl-maze.app -e html --async -t 50  33.49s user 0.65s system 53% cpu 1:03.24 total

This PR isn't quite finished yet!

  • I just copied and modified the existing code, so it needs to be refactored.
  • The rate-limiting logic is likely to require further optimisation.
  • HttpNtlmAuth hasn't been implemented yet.
  • There might be some bugs in concurrency and timeout control.
  • Should we replace requests with httpx? Since httpx supports both synchronous and asynchronous modes. There should be a new issue for discussion.
  • Handle all request exceptions properly.
  • Change the minimum version requirement to Python3.9. (httpx requires 3.8+)
  • Adjust log/output in async mode.
  • Fix errors from pickle (requester, loop, future...)
  • httpx doesn't let me choose different proxy for each request.

Requirements

  • Add your name to CONTRIBUTORS.md
  • If this is a new feature, then please add some additional information about it to CHANGELOG.md

@zrquan zrquan changed the title Support async mode Support asynchronous mode Sep 7, 2024
@zrquan
Copy link
Contributor Author

zrquan commented Sep 10, 2024

Should we think about raising the minimum version requirement to Python3.9?

@maurosoria
Copy link
Owner

I like this!

We can jump to even newer versions if it is worth it.

DM me on twitter if you want to chat with us.

@zrquan zrquan marked this pull request as ready for review September 20, 2024 13:52
@maurosoria maurosoria merged commit 87343d3 into maurosoria:master Oct 11, 2024
9 checks passed
@maurosoria
Copy link
Owner

Thank you so much and congratulations for such important contribution!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moving from threads to asyncio
2 participants