new: Global proxy setting.

Overwrites any proxy given by the user. Still uses the tor proxy when
needed.

Related: https://github.com/Lookyloo/lookyloo/issues/318
pull/719/head
Raphaël Vinot 2023-06-13 11:53:27 +02:00
parent 97a668aa91
commit 0505edff0e
4 changed files with 20 additions and 3 deletions

View File

@ -33,6 +33,12 @@
"tor_proxy": {
"server": "socks5://127.0.0.1:9050"
},
"global_proxy": {
"enable": false,
"server": "",
"username": "",
"password": ""
},
"email": {
"from": "Lookyloo <lookyloo@myorg.local>",
"to": "Investigation Team <investigation_unit@myorg.local>",
@ -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.",

View File

@ -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),

View File

@ -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/<string:tree_uuid>', methods=['GET'])

View File

@ -297,12 +297,14 @@
</div>
</div>
{% if not has_global_proxy %}
<div class="row mb-3">
<label for="proxy" class="col-sm-2 col-form-label">Proxy:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="proxy" id="proxy" placeholder="Expected format: [scheme]://[username]:[password]@[hostname]:[port]">
</div>
</div>
{%endif%}
<div class="row mb-3">
<label for="httpauth" class="col-sm-2 col-form-label">HTTP Authentication</label>