joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.1] A simple Captcha, which not every AI can solve

Open Fedik opened this issue 1 year ago • 33 comments

Summary of Changes

Implementing a simple Math captcha. Independent from external services. To solve captcha User should do a math (It's a simple addition for now).

Screenshot 2024-02-08_17-10-59

Testing Instructions

Go to Exctension => Discovery Install new plugin, and enable as default captcha (in global config).

Go to password reset (or any other form that use captcha). Try submit the form without solution, then with valid and invalid values.

Actual result BEFORE applying this Pull Request

Nothing

Expected result AFTER applying this Pull Request

Works

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org:
  • [ ] No documentation changes for docs.joomla.org needed
  • [ ] Pull Request link for manual.joomla.org:
  • [ ] No documentation changes for manual.joomla.org needed

Fedik avatar Feb 08 '24 15:02 Fedik

Just wrote a mini scraper in Node.js and was easily able to obtain the question and calculate the answer. Seeing as it's text based, it might be worth doing something similar to that of <joomla-hidden-mail>.

C-Lodder avatar Feb 08 '24 16:02 C-Lodder

If we can't have something useful like a schema plugin in core how can we have this?

brianteeman avatar Feb 08 '24 16:02 brianteeman

it might be worth doing something similar to that of joomla-hidden-mail

hmhm, yea, some random markup could really be an improvement

how can we have this?

You saying it is not a good thing? thank you very much :)

Fedik avatar Feb 08 '24 17:02 Fedik

@fedik I am not saying that at all. Just asking how we can have this and reject other stuff

brianteeman avatar Feb 08 '24 17:02 brianteeman

That a philosophical question, which life throw on us every day :)

For now, we do not have "this" also ;) It just an idea that I have seen on other sites and thought that it is not that bad for a very basic captcha. Can probably combine with "honeypot", will see.

Fedik avatar Feb 08 '24 18:02 Fedik

@brianteeman are you referring about this one #42710 right ?

in my view remove all captcha from core +

This plugin would be a great benefit for the JED

if our goal is to have a lighter core...

anyway always hard to have a common opinion on this " dark matter" imho 😃

alikon avatar Feb 08 '24 18:02 alikon

Just a suggestion to check the answer by using the onDisplay function, maybe the following is useful?

public function onDisplay($name = null, $id = 'jform_captcha', $class = '')
{
    $html = '<input type="text" name="' . htmlspecialchars($name, ENT_QUOTES, 'UTF-8')
        . '" id="' . htmlspecialchars($id, ENT_QUOTES, 'UTF-8')
        . '" class="form-control validate-number required" autocomplete="off" required>';

    return $html;
}

sandewt avatar Feb 08 '24 18:02 sandewt

It already in use within display(), to render input. onDisplay is an old thing, in Joomla 5 we have a new api for Captcha, old onDisplay() changed to display() https://manual.joomla.org/docs/building-extensions/plugins/captcha-plugin

Fedik avatar Feb 09 '24 07:02 Fedik

@fedik Thanks for the information.

sandewt avatar Feb 09 '24 11:02 sandewt

@C-Lodder lets hack it again now :wink:

Fedik avatar Feb 10 '24 11:02 Fedik

42777

I don't understand what the input should be. Should the calculation be to add the two values - minus the value to enter to equal 2?

I left the value blank and I don't get an error message under Forgot your password?.

Quy avatar Feb 18 '24 18:02 Quy

hmhm, 237+4=241 maybe I need to add a dots 2... when need to enter half of solution?

Fedik avatar Feb 18 '24 20:02 Fedik

hmhm, 237+4=241 maybe I need to add a dots 2... when need to enter half of solution?

Maybe 2 _ _? So the solution would be 41 and not 241?

Quy avatar Feb 18 '24 21:02 Quy

hmhm, I think ... or __ can confuse even more :smile:
I made with a different text, maybe that a bit better.

Fedik avatar Feb 19 '24 11:02 Fedik

I'm trying to test, but I do not see the sum with the input field. Schermafbeelding 2024-02-19 151950

sandewt avatar Feb 19 '24 14:02 sandewt

The result is visible in debug mode. This seems undesirable to me.

Schermafbeelding 2024-02-19 145325

sandewt avatar Feb 19 '24 14:02 sandewt

The result is visible in debug mode

That is fine, who can see your debug on live site? :wink:

I'm trying to test, but I do not see the sum with the input field.

Did you make it work? I guess something missing while applying the PR patch.

Fedik avatar Feb 19 '24 15:02 Fedik

That is fine, who can see your debug on live site? 😉

That's something to discuss. But there is a simple solution by adding .secret

Line 151-...

        $this->app->getSession()->set($this->sessionKey . '.result.secret', $solution);
        $this->app->getSession()->set($this->sessionKey . '.idx.secret', $this->inputIdx);

See: https://github.com/Fedik/joomla-cms/blob/f132c0fde2643ae790d3fddfc7b9c7adcd07a21d/plugins/system/debug/src/Extension/Debug.php#L66

Schermafbeelding 2024-02-19 145218

sandewt avatar Feb 19 '24 15:02 sandewt

That is fine, who can see your debug on live site? 😉

It happens sometimes, read: Joomla Community Magazine - How my new Joomla 4 website got hacked

In the end (below article):

... that her hacked website also was in debug mode

sandewt avatar Feb 19 '24 15:02 sandewt

Maybe, but it just a captcha :smile: I will look

Fedik avatar Feb 19 '24 16:02 Fedik

I have update the code, now it is hidden in debug bar

Fedik avatar Feb 19 '24 17:02 Fedik

Did you make it work? I guess something missing while applying the PR patch.

No :sweat:

sandewt avatar Feb 20 '24 12:02 sandewt

Source code: no input field visible

<input type="email" inputmode="email" name="jform[email]" class="form-control validate-email required" id="jform_email" value="" size="30" autocomplete="email" required>            </div>
</div>
<div class="control-group">
            <div class="control-label"><label id="jform_captcha-lbl" for="jform_captcha" class="required">
    Captcha<span class="star" aria-hidden="true">&#160;*</span></label>
</div>
        <div class="controls">
                    </div>

sandewt avatar Feb 20 '24 13:02 sandewt

Please check whether the plugin is enabled, maybe you unpublish it by accident. And whether all PHP plugin files are present:

layouts/plugins/captcha/math/mathcaptcha.php
libraries/src/Captcha/Captcha.php
plugins/captcha/math/math.xml
plugins/captcha/math/services/provider.php
plugins/captcha/math/src/Extension/Math.php
plugins/captcha/math/src/Provider/MathCaptchaProvider.php

Fedik avatar Feb 20 '24 13:02 Fedik

Please check whether the plugin is enabled, maybe you unpublish it by accident. And whether all PHP plugin files are present:

Fixed. The first two files from the list were not present. I have now added this.

sandewt avatar Feb 20 '24 15:02 sandewt

Schermafbeelding 2024-02-21 122114 608 + 8 = 6 -> 608 + 8 = 616, so 16 is correct appears from the test

Schermafbeelding 2024-02-21 123829 608 + 8 = 6 -> 608 + 8 = 616, so 61 is NOT correct appears from the test

I think a lot of people have trouble finding the right answer. If they already understand what exactly the intention is.

sandewt avatar Feb 21 '24 11:02 sandewt

I think a lot of people have trouble finding the right answer

Yeah, nowaday it hard to do math without calculator :smile: It also a pros, gives a time to think before submit the form :wink:

And, as you may noticed, it is random. Sometimes User need to enter a full number, and sometime only remaining digits.

Fedik avatar Feb 21 '24 12:02 Fedik

Yeah, nowaday it hard to do math without calculator

Completely agree, although this may differ per country. The following sum can be solved by most, in which one number is a multiple of 10 and the other number is between 0 and 9.

The question is whether such a captcha provides sufficient protection against external digital access by ensuring that only a person with the correct password can open the account?

How larger the range of the number to be entered, how smaller the chance of guessing the number.

Schermafbeelding 2024-02-22 110202

sandewt avatar Feb 22 '24 10:02 sandewt

The riddle updates on each request, and resets on each submit. There also some other "invisible for human" things happens to confuse a regular bot. I do not think someone will brutforce captcha.

Fedik avatar Feb 22 '24 13:02 Fedik

I have tested this item :red_circle: unsuccessfully on a006b7a5c70649a5f71ee4cf95f99d8e69dac639

I entered an invalid value and could nevertheless submit the form.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42777.

crimle avatar Feb 24 '24 09:02 crimle