From 588867c98b617f3473254e8e2f5147192e3c01db Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Fri, 26 Apr 2024 23:49:39 +0200 Subject: [PATCH 1/3] added visual aid when debugEnabled to see if considered as bot --- assets/js/bestellformular.js | 55 +++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/assets/js/bestellformular.js b/assets/js/bestellformular.js index 3566f48..bd72886 100644 --- a/assets/js/bestellformular.js +++ b/assets/js/bestellformular.js @@ -41,6 +41,15 @@ const textInputs = document.querySelectorAll('input[type="text"]') const captcha = document.querySelectorAll('.captcha') const captchaInput = document.querySelectorAll('.captcha-input') const captchaVerifyButton = document.querySelectorAll('.captcha-verify') +const botBadge = document.createElement('div') +if (debugEnabled) { + botBadge.className = 'bot-badge' + document.body.appendChild(botBadge) + botBadge.setAttribute( + 'style', + 'position: fixed; top: 0; right: 0; z-index: 9999; background-color: red; color: white; font-weight: bold; height:20px; width:20px' + ) +} // Utility variables let startTime = Date.now() @@ -71,6 +80,7 @@ function setUserInteracted() { lastInteractionTime = currentTime userInteracted = true interactionCount++ + checkForBotBehavior() } function handleMouseMove(event) { @@ -110,26 +120,31 @@ function checkForBotBehavior() { honeypotInput2.value !== '' || verifyEmailInput.value !== '' if (debugEnabled) - console.log( - 'Bot Detected: ' + - botDetected + - ' userInteracted:' + - userInteracted + - ' interactionCount:' + - interactionCount + - ' timeSpent:' + - timeSpent + - ' isStraightLine:' + - isStraightLine + - ' mousePositions:' + - mousePositions.length + - ' honeypotInput1:' + - honeypotInput1.value + - ' honeypotInput2:' + - honeypotInput2.value + - ' verifyEmailInput:' + - verifyEmailInput.value - ) + if (!botDetected) { + botBadge.style.backgroundColor = 'green' + } else { + botBadge.style.backgroundColor = 'red' + } + console.log( + 'Bot Detected: ' + + botDetected + + ' userInteracted:' + + userInteracted + + ' interactionCount:' + + interactionCount + + ' timeSpent:' + + timeSpent + + ' isStraightLine:' + + isStraightLine + + ' mousePositions:' + + mousePositions.length + + ' honeypotInput1:' + + honeypotInput1.value + + ' honeypotInput2:' + + honeypotInput2.value + + ' verifyEmailInput:' + + verifyEmailInput.value + ) } function handleSubmit(e) { e.preventDefault() From 683342ed6f6ea49554501976be492d52ba6ed96d Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Fri, 26 Apr 2024 23:49:59 +0200 Subject: [PATCH 2/3] fixed broken bot feedback --- static/php/ajaxmail.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/static/php/ajaxmail.php b/static/php/ajaxmail.php index 07e05f0..62cbefc 100644 --- a/static/php/ajaxmail.php +++ b/static/php/ajaxmail.php @@ -23,10 +23,7 @@ try { $bot = $_POST['tra'] ; - // Überprüfe, ob der Nutzer mit der Seite interagiert hat - $userInteracted = filter_input(INPUT_POST, 'userInteracted'); - - if ($bot) { + if ($bot == 'true') { // Es handelt sich wahrscheinlich um einen Bot $subject = 'Botverdacht - ' . $subject; } From 4f1a638b64e00b4b5e0e76b64539fdc3d27e1dba Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Fri, 26 Apr 2024 23:50:22 +0200 Subject: [PATCH 3/3] removed dummy value in honeypot field --- content/german/bestellung/freiberufliche.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/german/bestellung/freiberufliche.md b/content/german/bestellung/freiberufliche.md index 793d032..01b3624 100644 --- a/content/german/bestellung/freiberufliche.md +++ b/content/german/bestellung/freiberufliche.md @@ -73,7 +73,7 @@ kommentar = 'age und hobbies sind honeypots'
- +