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

Allow dirsearch to use a non-default network interface #1323

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## [Unreleased]
- Support non-default network interface

## [0.4.3] - October 2nd, 2022
- Automatically detect the URI scheme (`http` or `https`) if no scheme is provided
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
- [Akshay Ravi](https://www.linkedin.com/in/c09yc47/)
- [kosyan62](https://https://github.com/kosyan62)
- [Maxence Zolnieurck](https://github.com/mxcezl)
- [huyphan](https://github.com/huyphan)

Special thanks to all the people who are named here!

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ Options:
--max-rate=RATE Max requests per second
--retries=RETRIES Number of retries for failed requests
--ip=IP Server IP address
--interface=NETWORK_INTERFACE
Network interface to use

Advanced Settings:
--crawl Crawl for new paths in responses
Expand Down
14 changes: 13 additions & 1 deletion lib/connection/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from requests.auth import AuthBase, HTTPBasicAuth, HTTPDigestAuth
from requests.packages import urllib3
from requests_ntlm import HttpNtlmAuth
from requests_toolbelt.adapters.socket_options import SocketOptionsAdapter
from urllib.parse import urlparse

from lib.core.data import options
Expand Down Expand Up @@ -83,9 +84,20 @@ def __init__(self):
if options["data"] and "content-type" not in self.headers:
self.set_header("content-type", guess_mimetype(options["data"]))

socket_options = []
if options["network_interface"]:
socket_options.append(
(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, options["network_interface"].encode("utf-8"))
)

for scheme in ("http://", "https://"):
self.session.mount(
scheme, HTTPAdapter(max_retries=0, pool_maxsize=options["thread_count"])
scheme,
SocketOptionsAdapter(
max_retries=0,
pool_maxsize=options["thread_count"],
socket_options=socket_options,
)
)

def _fetch_agents(self):
Expand Down
1 change: 1 addition & 0 deletions lib/parse/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ def parse_arguments():
help="Number of retries for failed requests",
)
connection.add_option("--ip", action="store", dest="ip", help="Server IP address")
connection.add_option("--interface", action="store", dest="network_interface", help="Network interface to use")

# Advanced Settings
advanced = OptionGroup(parser, "Advanced Settings")
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ pyparsing>=2.4.7
beautifulsoup4>=4.8.0
mysql-connector-python>=8.0.20
psycopg[binary]>=3.0
requests-toolbelt>=1.0.0
Loading