Remove Joomla 4 generator Topic is solved

This forum is for general questions about extensions for Joomla! 4.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
sylwekb
Joomla! Explorer
Joomla! Explorer
Posts: 384
Joined: Mon Mar 14, 2011 5:08 pm

Remove Joomla 4 generator

Post by sylwekb » Fri Aug 20, 2021 2:15 pm

Hello
Thank you for the tremendous work done in the Joomla 4 release. Is it possible to remove the generator tag in Joomla 4. Where is it located? It is not where it was in Joomla 3. Is it possible to delete it?
Last edited by toivo on Sat Nov 19, 2022 12:53 am, edited 1 time in total.
Reason: mod note: unlocked on request

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24985
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Remove Joomla 4 generator

Post by pe7er » Sat Aug 21, 2021 9:56 am

You could try adding a few lines to your template's index.php [edit: this J3 method seems to not work anymore in J4] :

Code: Select all

use Joomla\CMS\Factory;

Factory::getDocument()->setGenerator('');
Note that this can be overwritten when you update your template.
So you could code a system plugin to add the code,
or use a 3rd party system plugin to do it.
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Sat Aug 21, 2021 10:31 am

There was a plugin written several years ago by Michael Richey called ByeByeGenerator for J! 3.x. This plugin doesn't work in J! 4 and it probably doesn't work for J! 3.9 or J! 3.10 but, with a couple of small changes, it could probably be made to work.

If you replace line 52 of the file byebyegenerator.php with this

Code: Select all

            if($app->isClient('administrator')) return true;
it will probably work. I haven't tried it. :)

sylwekb
Joomla! Explorer
Joomla! Explorer
Posts: 384
Joined: Mon Mar 14, 2011 5:08 pm

Re: Remove Joomla 4 generator

Post by sylwekb » Mon Aug 23, 2021 11:32 am

Unfortunately, but it doesn't work for me, I added the Cassiopeia template in the index.php file on the stable version of Joomla 4. As far as I remember, this is a code for Joomla 3.

Code: Select all

use Joomla\CMS\Factory;

Factory::getDocument()->setGenerator('');

sylwekb
Joomla! Explorer
Joomla! Explorer
Posts: 384
Joined: Mon Mar 14, 2011 5:08 pm

Re: Remove Joomla 4 generator

Post by sylwekb » Mon Aug 23, 2021 11:42 am

I changed 52 in the indicated line byebyegenerator.php file, but unfortunately I get an error

Code: Select all

if($app->isClient('administrator')) return true;

0 Call to undefined method Joomla\CMS\Application\AdministratorApplication::isAdmin()

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44093
Joined: Sat Apr 05, 2008 9:58 pm

Re: Remove Joomla 4 generator

Post by Webdongle » Mon Aug 23, 2021 11:56 am

Why bother? There are many other ways a hacker can identify the site as Joomla. Besides which the 'script kiddies' just blindly attack any site they can find rather than look for the generator tag first. Your time might be better spent making the site as bullet proof as possible instead of trying to hide it is Joomla.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

sylwekb
Joomla! Explorer
Joomla! Explorer
Posts: 384
Joined: Mon Mar 14, 2011 5:08 pm

Re: Remove Joomla 4 generator

Post by sylwekb » Mon Aug 23, 2021 12:26 pm

In joomla 3.x, the generator was located in the file

libraries/src/Document/Renderer/Html/HeadRenderer.php

In Joomla 4, there is no longer a generator in this file. Where has he been transferred? I can't find this in Joomal 4.

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Mon Aug 23, 2021 7:05 pm

Sorry, sylwekb, there are two places "isAdmin()" in the file byebyegenerator.php that need to be replaced. The one at line 52 of the file byebyegenerator.php should be replaced with

Code: Select all

            if($app->isClient('administrator')) return true;
and the second one is at line 76 which should be replaced with

Code: Select all

                    if (JFactory::getApplication()->isClient('administrator')) return true
Again I haven't tried it but these two changes should make it work. I hope it helps. :)

The method $app->isAdmin() is deprecated in J! 3.x since J! 3.7 and it generates an error in J! 4.x if you try to use it there. It's explained in https://docs.joomla.org/Potential_backw ... pplication

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12787
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Remove Joomla 4 generator

Post by brian » Mon Aug 23, 2021 8:15 pm

This is super simple. Just add one line of code to your template

if its inside a php block already

Code: Select all

$this->setGenerator('');
otherwisse

Code: Select all

<?php $this->setGenerator(''); ?>
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Mon Aug 23, 2021 9:39 pm

Thanks, @brian. Will this be need to be re-done after updating J! ???

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12787
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Remove Joomla 4 generator

Post by brian » Mon Aug 23, 2021 10:48 pm

if you are adding this to cassiopeia and that gets updated then yes.
personally i would work on a copy of cassiopeia and then you are safe.
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Mon Aug 23, 2021 11:50 pm

Thanks, @brian.

This gives the OP a couple of options. You can modify the template's index.php file—best if you make a copy of the template first—or use a system plugin. I don't have any personal preference either way. 8)

sylwekb
Joomla! Explorer
Joomla! Explorer
Posts: 384
Joined: Mon Mar 14, 2011 5:08 pm

Re: Remove Joomla 4 generator

Post by sylwekb » Tue Aug 24, 2021 7:22 am

Sozzled still error another frontend mistake this time

0 Class 'JResponse' not found

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Tue Aug 24, 2021 8:26 am

@sylwekb: As I wrote a couple of times before, it shouldn't be too difficult to work your way through the deprecated J! 3 classes and methods and rewrite them; I just looked at obvious booby traps—for example isAdmin()—but I didn't examine every line of code in the file byebyegenerator.php. I didn't test it myself; it's not high on my list of priorities.

Right now I just want to build a very basic website with J! 4.0—a few articles, a menu, and a login/logout) and I don't really care too much about the "icing on the cake" (e.g. concealing the fact that the website is built in J! 4).

You're right: JResponse is deprecated. A lot of software written before J! 4.0 was first conceived (in 2017) will break; a lot of software written before J! 3.9 already breaks when people update from versions older than J! 3.9. For some of us, who have the patience to debug someone else's software, many of these defects can be fixed. I don't have a strong motivation to fix other people's broken software; I have enough fun trying to fix my own software when it breaks, thank you very much. :p

I believe that it's possible to develop a system plugin that works like ByeByeGenerator worked. It all depends on one's motivation; it doesn't require skill: it's a "management problem". If you want something done and you don't have the skill to do it, you can always pay someone else to do the job for you.

For example, we had a broken air-conditioning unit in our main bedroom; it's been that way for the past 10 months (and Canberra's climate goes from extreme cold to extreme heat) but we survived summer by buying a ceiling fan (for $400) ... and paying an electrician ($600) to install it. I can't fix broken air-conditioning systems; I don't have the know-how and I don't have the right tools. Yesterday we paid an A/C company to repair the broken system and it works beautifully now. $550 is all it cost. Like I say, it's a "management problem": just about anything can be solved if you know the right people to do something for you and you pay them for their service.

The solution is—nine times out of ten—a matter of what motivation one has to seek it.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2906
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Remove Joomla 4 generator

Post by SharkyKZ » Thu Sep 02, 2021 7:29 am

Made a simple plugin for J4, in case anyone needs. Download here https://github.com/SharkyKZ/plg_system_ ... r/releases.

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Thu Sep 02, 2021 7:32 am

Thanks @SharkyKZ. :) I'll have a look at what you wrote in a few days.

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Remove Joomla 4 generator

Post by sozzled » Sat Nov 19, 2022 1:59 am

I asked the moderators to unlock this topic so that I could thank @SharkyKZ for his idea. I’m sorry it took me so long.

The plugin developed by @SharkyKZ works wonderfully well.

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1389
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

Re: Remove Joomla 4 generator

Post by stutteringp0et » Tue Feb 14, 2023 10:37 pm

ByeByeGenerator author here.

I ran into the same issue as you gents, and I have a solution that doesn't require a plugin and doesn't modify any core files (or template files) which may be overwritten in an update.

I'm trying to eliminate many of my own extensions, so I don't believe ByeByeGenerator is going to survive the upcoming purge of my own work.

Still, it's an important feature to secure your site - reduce fingerprinting.

Anyway, you can do it with a template override.

I copied:
/layouts/joomla/system/message.php
into
/templates/mytemplate/html/layouts/joomla/system/message.php

I deleted everything after the "use Joomla\..." lines, and inserted the following:

Code: Select all

Factory::getDocument()->setGenerator('');
include JPATH_ROOT.'/layouts/joomla/system/message.php';
What this does is set the generator to an empty value (causing Joomla to omit it), and then includes the original file used to create this override.

Voila - no more generator, no core modifications, upgrade-safe.

Enjoy!
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

weredigi
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri May 19, 2017 1:30 pm

Re: Remove Joomla 4 generator

Post by weredigi » Wed Apr 19, 2023 6:15 pm

SharkyKZ wrote:
Thu Sep 02, 2021 7:29 am
Made a simple plugin for J4, in case anyone needs. Download here https://github.com/SharkyKZ/plg_system_ ... r/releases.

Works fine for me removal not modifying is what I was looking for


Locked

Return to “Extensions for Joomla! 4.x”