slabbi / uddeIM

udde Instant Messages (uddeIM) - Instant Messages System for Mambo and Joomla
12 stars 9 forks source link

Captcha Service ->Internal #75

Closed jojo12 closed 4 months ago

jojo12 commented 4 months ago

Es gibt die Möglichkeit ein Internes Captcha System zu wählen, es wird dann auch ein Sicherheitscode abgefragt. Aber wie komme ich zu diesem?

Es fehlen hier auch deutsche Übersetzungen!

"Which captcha service do you want to use: The build-in service or reCaptcha (see reCaptcha for more information)?"
"When you want to use reCaptcha, enter your public key here."
"When you want to use reCaptcha, enter your private key here."

joomod commented 4 months ago

da ist noch der alte link zu recaptcha.net, das ja mittlerweile von google übernommen wurde https://www.google.com/recaptcha/about/

aber ehrlich gesagt habe ich es in uddeim noch nicht wirklich getestet

jojo12 commented 4 months ago

recaptcha 2.0 geht!

joomod commented 4 months ago

edit new links and german in main

joomod commented 4 months ago

hast Du auch mal die interne Funktion getestet?

jojo12 commented 4 months ago

wenn du mich fragst. Ich sprach am Anfang mit der "internen Funktion" die nicht funktioniert. Es stellt sich auch die Frage, was ist die "interne Funktion": a) ein uddeIM internes/eigenes Captcha? b) das in Joomla Settings gewählte Captcha?

jojo12 commented 4 months ago

grafik

joomod commented 4 months ago

da ist eine eigene catcha library, die mit hochgeladen wird. Ich habe sie noch für die v5.3 mit der aktuellen version upgedated (so wie auf desse github veröffentlicht)

ah, sehe gerade in dem Bild den Code den Du meinst (ich dachte Du meinst die reCaptcha keys)

muß ich doch wohl mal aktivieren und testen

joomod commented 4 months ago

sodele, ein bisschen schlauer. da sollte eigentlich ein Bild erscheinen was von der Datei captcha15.php erzeugt wird, aber die funktioniert wohl nicht (habe ich mir scheinbar auch nie näher angeschaut, noch kein J5 code)

jojo12 commented 4 months ago

Ja, mensch staunt, was es da noch alles hat :-)

slabbi commented 4 months ago

Da ist nicht viel Joomla Code drin Vermutlich eher ein PHP 8.x Problem

slabbi commented 4 months ago

Evtl. hat sich aber etwas bei $session = Factory::getApplication()->getSession(); geändert

das ist der aktuelle Joomla5 code

slabbi commented 4 months ago

Gerade nachgeguckt: Hat sich geändert: nein, siehe oben Probiere: (das ist alter Joomla code) $session = JFactory::getSession(); $session->set('security_code', $code);

Es geht darum, dass das Captcha in der Browser Session gespeichert wird. Es sollte auch möglich sein hierzu "$_SESSION" zu verwenden. Ist aber dann halt an dem sich ständig ändernden Framework vorbei programmiert.

joomod commented 4 months ago

Bild hab ich schon, jetzt muß ich schauen/prüfen ob der code richtig gespeichert wird

joomod commented 4 months ago

so, interes captcha sollte jetzt auch gehen (main breits updated)

(in der zip ist meine includes.php vom testen, bin mir aber nicht sicher ob die vorher auf dem aktuellsten Stand war, also besser die version aus der main laden) captcha.zip

slabbi commented 4 months ago

Nicht ernsthaft: $captchalen = $_GET['clen']; So kann ein Spammer einfach einen kürzeren Captcha Code mitliefern. Evtl. würde auch "0" funktionieren. Bitte die Config-Class weiterhin laden. Das ist ist kein Problem hier.

slabbi commented 4 months ago

Ich habe die eingecheckten Dateien bzgl. Captcha aufgrund einer möglichen Schwachstelle zurückgesetzt. Ich hoffe, ich habe alle Dateien erwischt.

Bitte noch einmal genau ansehen, gerade wenn das Framework manuell geladen wird.

Die Config-Datei sollte auch wieder geladen werden und nicht auf übergebene Parameter im HTTP Header achten.

joomod commented 4 months ago

jetzt klär mich mal auf: wie soll denn ein Spammer an den internen Aufruf der captcha.php kommen?

joomod commented 4 months ago

ok, habs gerade ausprobiert, geht mit dem config Aufruf genauso (hatte da beim testen öfters Probleme)

könntest Du die updates wieder einpflegen ? (die zwei config Zeilen sind ja in der captcha.php nur auskommentiert, lediglich die variable müßte wieder $config->captchalen heißen)

slabbi commented 4 months ago

Nein, leider nicht. Bitte korrigiert wieder einchecken.

joomod commented 4 months ago

ok, done

joomod commented 4 months ago

nur zur Info (und nachlesen :): Hauptproblem war der geänderte Aufruf des Joomla framework: aktuell (5) sieht es so aus:

define("_JEXEC", 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));
if (!(defined('_JEXEC'))) { die( 'Direct Access to this location is not allowed.' ); }
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
$container = \Joomla\CMS\Factory::getContainer();
$container->alias(\Joomla\Session\SessionInterface::class, 'session.web.site');
$app = $container->get(\Joomla\CMS\Application\SiteApplication::class);
\Joomla\CMS\Factory::$application = $app;
$app->createExtensionNamespaceMap();

und dann: $session = Joomla\CMS\Factory::getApplication()->getSession();

joomod commented 4 months ago

@slabbi kennst Du eine Möglichkeit den img link (src=".../captcha.php") irgendwie mit javascript erneut aufzurufen um ein anderes (neues) Bild zu laden ?

(jquery.load könnte gehen, ist ja aber offiziell nicht geladen)

slabbi commented 4 months ago

Mit der derzeitigen Implementierung nicht möglich. Ich würde dann eher empfehlen, das Joomla Captcha zu unterstützen (unterstützt es Neuladen)? Als ich das Captcha implementiert habe, gab es das in Mambo bzw. Joomla 1.0 noch nicht.

btw:

Bei define("_JEXEC", 1 ); define( 'JPATH_BASE', realpath(dirname(FILE).'/../..' )); if (!(defined('_JEXEC'))) { die( 'Direct Access to this location is not allowed.' ); } ... kann die if-Abfrage entfallen.

joomod commented 4 months ago

schon logisch, ich hab sie nur eingebaut weil JED checker immer danach schreit :)

mit jquery wäre ich ja fast soweit, aber gibt es irgendeine Möglichkeit die als String zurückgegebenen Daten von imagejpeg wieder in ein Bild zu konvertieren?

joomod commented 4 months ago

dasa Joomla captcha schau ich mir mal an, vielleicht kann man damit das veraltete Recaptcha 1 ersetzen edit: in Joomla 5 ist kein Captcha mehr integriert

joomod commented 4 months ago

bis dahin komme ich :) src="�����JFIF�������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ���C�    $.' ",#(7),01444'9=82<.342���C usw.

slabbi commented 4 months ago

Willst du ein Bild inline verwenden? https://www.w3docs.com/snippets/html/how-to-display-base64-images-in-html.html

joomod commented 4 months ago

genau darüber denke ich gerade nach

jojo12 commented 4 months ago

I don't get any security images, only the question "security code"

joomod commented 4 months ago

have you installed the very actual versions? captcha.php (not captcha15) includes.php

should look like this

capimg

you may try to load captcha.php direct for testing.

https://yoursite.ch/components/com_uddeim/captcha.php should display an image

jojo12 commented 4 months ago

I always downloaded the whole main and made then a zipfile from com_uddeIM_J5, installed, cleaned caches and tried. Will do it again. (Now I know how it should be!)

i will check the main to see if there are errors

joomod commented 4 months ago

I'm still working on a reload function. using jquery it would be ready, but now try to get this in simple js

jojo12 commented 4 months ago

grafik grafik

jojo12 commented 4 months ago

with https://yoursite.ch/components/com_uddeim/captcha.php (I set the name of my site!) I get a white page (no error lines) only white!

jojo12 commented 4 months ago

I tried with public, I then get this: and it looks for captcha15 grafik

joomod commented 4 months ago

oh, thanks for that, havn't realized tha pubfrontend uses his own script.

have you looked in the inspector what this line looks like on regular use?

jojo12 commented 4 months ago

when I try with registered, it looks for captcha.php which can not be loaded grafik

joomod commented 4 months ago

there is an error in captcha.php (my fault) - forget comment slashes

can you edit (line 77 +/-) $session->set('security_code', strtolower($code)); just save lower case just add // $session->set('security_code', strtolower($code)); // just save lower case

and the try again please

jojo12 commented 4 months ago

yes, that's it in regular I have now an image with security code!

joomod commented 4 months ago

fine, in the meanwhile I have edit the pfrontend.php too.

but not finished yet (adding reload - a bit tricky)

jojo12 commented 4 months ago

I tried pfrontend.php, it continues to search for captcha15.php

joomod commented 4 months ago

its the newest in main branch

and please check if the code is set in session (means entering the correct code should do send)

jojo12 commented 4 months ago

I downloaded it there (one file) and uploaded, but no result

joomod commented 4 months ago

may be only a cache problem. I'm in pfrontend live and it calls captcha.php (reset cache in backed)

jojo12 commented 4 months ago

no I cached and cached again, I can't cache as cache can :-)

joomod commented 4 months ago

captcha

actaul github pfrontend

jojo12 commented 4 months ago

yes, I see, but it continues to look for captcha.15.php

joomod commented 4 months ago

just wait, could only be cache in your actual it than should also have: vertical-align:middle, the new has bottom

jojo12 commented 4 months ago

I purged the session the problem persists it has vertical-align:middle

jojo12 commented 4 months ago

sorry, my fault: I was on my other site oooh! it works in public too!