diff --git a/config/generic.json.sample b/config/generic.json.sample index d0dc2299..19b3ba65 100644 --- a/config/generic.json.sample +++ b/config/generic.json.sample @@ -33,6 +33,12 @@ "tor_proxy": { "server": "socks5://127.0.0.1:9050" }, + "global_proxy": { + "enable": false, + "server": "", + "username": "", + "password": "" + }, "email": { "from": "Lookyloo ", "to": "Investigation Team ", @@ -79,7 +85,8 @@ "enable_mail_notification": "Allow users to notify a pre-configured email address about a specific capture", "remote_lacus": "By default, lookyloo will do the capture locally. Enabling this feature means you have a dedicated Lacus instance somewhere", "monitoring": "Enable connection to a remote monitoring instance", - "tor_proxy": "URL to connect to a SOCKS 5 proxy for tor", + "tor_proxy": "URL to connect to a SOCKS 5 proxy for tor - If you capture via a lacus instance, this value is ignored", + "global_proxy": "Proxy configuration to use for *all* the requests (except .onions) - If you capture via a lacus instance, this value is ignored", "email": "Configuration for sending email notifications.", "priority": "Define the priority of a new capture. A capture from the web interface has priority over a capture from the API, same for authenticated user vs. anonymous.", "hide_captures_with_error": "Capturing an URL may result in an error (domain non-existent, HTTP error, ...). They may be useful to see, but if you have a public instance, they will clutter the index.", diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index ace79e1d..90717484 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import base64 +import copy import json import logging import operator @@ -77,6 +78,12 @@ class Lookyloo(): self.is_public_instance = get_config('generic', 'public_instance') self.public_domain = get_config('generic', 'public_domain') + self.global_proxy = {} + if global_proxy := get_config('generic', 'global_proxy'): + if global_proxy.get('enable'): + self.global_proxy = copy.copy(global_proxy) + self.global_proxy.pop('enable') + self.securitytxt = PySecurityTXT(useragent=get_useragent_for_requests()) self.taxonomies = get_taxonomies() @@ -598,7 +605,7 @@ class Lookyloo(): browser=query.get('browser', None), device_name=query.get('device_name', None), user_agent=query.get('user_agent', None), - proxy=query.get('proxy', None), + proxy=self.global_proxy if self.global_proxy else query.get('proxy', None), general_timeout_in_sec=query.get('general_timeout_in_sec', None), cookies=query.get('cookies', None), headers=query.get('headers', None), diff --git a/website/web/__init__.py b/website/web/__init__.py index ee88f869..f74b0f33 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -967,7 +967,8 @@ def _prepare_capture_template(user_ua: Optional[str], predefined_url: Optional[s personal_ua=user_ua, default_public=get_config('generic', 'default_public'), devices=lookyloo.get_playwright_devices(), - predefined_url_to_capture=predefined_url if predefined_url else '') + predefined_url_to_capture=predefined_url if predefined_url else '', + has_global_proxy=True if lookyloo.global_proxy else False) @app.route('/recapture/', methods=['GET']) diff --git a/website/web/templates/capture.html b/website/web/templates/capture.html index 4a502854..31ba52b4 100644 --- a/website/web/templates/capture.html +++ b/website/web/templates/capture.html @@ -297,12 +297,14 @@ + {% if not has_global_proxy %}
+ {%endif%}