More mitm detection

main
Bob Mottram 2024-12-16 13:19:51 +00:00
parent 683cc9bc7e
commit 22a858b813
7 changed files with 68 additions and 42 deletions

View File

@ -24,6 +24,7 @@ from httpcodes import http_404
from announce import create_announce
from posts import save_post_to_box
from daemon_utils import post_to_outbox
from daemon_utils import detect_mitm
from fitnessFunctions import fitness_performance
from follow import follower_approval_active
from webapp_post import individual_post_as_html
@ -212,10 +213,12 @@ def announce_button(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(announce_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
announce_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True

View File

@ -25,6 +25,7 @@ from bookmarks import undo_bookmark_post
from follow import follower_approval_active
from webapp_post import individual_post_as_html
from fitnessFunctions import fitness_performance
from daemon_utils import detect_mitm
def bookmark_button(self, calling_domain: str, path: str,
@ -167,10 +168,12 @@ def bookmark_button(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(bookmark_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
bookmark_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True
@ -372,10 +375,12 @@ def bookmark_button_undo(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(bookmark_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
bookmark_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True

View File

@ -27,6 +27,7 @@ from posts import get_original_post_from_announce_url
from fitnessFunctions import fitness_performance
from like import update_likes_collection
from webapp_post import individual_post_as_html
from daemon_utils import detect_mitm
def like_button(self, calling_domain: str, path: str,
@ -214,10 +215,12 @@ def like_button(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(liked_post_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
liked_post_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True
@ -463,10 +466,12 @@ def like_button_undo(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(liked_post_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
liked_post_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True

View File

@ -22,6 +22,7 @@ from blocking import mute_post
from follow import follower_approval_active
from webapp_post import individual_post_as_html
from fitnessFunctions import fitness_performance
from daemon_utils import detect_mitm
def mute_button(self, calling_domain: str, path: str,
@ -129,10 +130,12 @@ def mute_button(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(nickname):
timezone = account_timezone.get(nickname)
mitm = False
if os.path.isfile(mute_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
mute_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(nickname):
bold_reading = True
@ -301,10 +304,12 @@ def mute_button_undo(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(nickname):
timezone = account_timezone.get(nickname)
mitm = False
if os.path.isfile(mute_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
mute_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(nickname):
bold_reading = True

View File

@ -24,6 +24,7 @@ from session import establish_session
from httpcodes import http_404
from posts import get_original_post_from_announce_url
from daemon_utils import post_to_outbox
from daemon_utils import detect_mitm
from fitnessFunctions import fitness_performance
from reaction import update_reaction_collection
from follow import follower_approval_active
@ -243,10 +244,12 @@ def reaction_button(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(reaction_post_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
reaction_post_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True
@ -514,10 +517,12 @@ def reaction_button_undo(self, calling_domain: str, path: str,
timezone = None
if account_timezone.get(self.post_to_nickname):
timezone = account_timezone.get(self.post_to_nickname)
mitm = False
if os.path.isfile(reaction_post_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
reaction_post_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(self.post_to_nickname):
bold_reading = True

View File

@ -47,6 +47,7 @@ from fitnessFunctions import fitness_performance
from securemode import secure_mode
from context import get_individual_post_context
from conversation import convthread_id_to_conversation_tag
from daemon_utils import detect_mitm
def _show_post_from_file(self, post_filename: str, liked_by: str,
@ -121,10 +122,12 @@ def _show_post_from_file(self, post_filename: str, liked_by: str,
if account_timezone.get(nickname):
timezone = account_timezone.get(nickname)
mitm = False
if os.path.isfile(post_filename.replace('.json', '') +
'.mitm'):
mitm = True
mitm = detect_mitm(self)
if not mitm:
mitm_filename = \
post_filename.replace('.json', '') + '.mitm'
if os.path.isfile(mitm_filename):
mitm = True
bold_reading = False
if bold_reading_nicknames.get(nickname):

View File

@ -207,7 +207,7 @@ def post_to_outbox_thread(self, message_json: {},
return True
def _detect_mitm(self) -> bool:
def detect_mitm(self) -> bool:
"""Detect if a request contains a MiTM
"""
mitm_domains = ['cloudflare']
@ -524,7 +524,7 @@ def update_inbox_queue(self, nickname: str, message_json: {},
self.server.blocked_cache_last_updated,
self.server.blocked_cache_update_secs)
mitm = _detect_mitm(self)
mitm = detect_mitm(self)
if debug:
print('INBOX: saving post to queue')