If this is your first visit, check our documentation. To post, register or login.

What identifies the admin directory?

Started by d0ugparker on 15 Jul 2017, 7:06 PM · Views: 81

Results 1 to 5 of 5
15 Jul 2017, 7:06 PM
#1
d0ugparker avatar

d0ugparker

Zen Follower

Join Date:
May 2008
Location:
Near the water, somewhere...
Posts:
129
Plugin Contributions:
0

What identifies the admin directory?

I'm not a coder, but I'm curious about one feature of Zencart: if admins installing the package change their admin directory name to any, random name, how is it that that change of the directory's name doesn't have to be recorded in a configure.php file somewhere and with all the random directory name changes across the globe, Zencart continues to function without locking up or throwing up a white screen?

What's the black magic that's going on, and in what part of the code is that happening?

Don't get me wrong, *I like it, *but it seems like such an understated, subtle, and elegant coding feature that someone needs a pretty good pat on the back for coding that into the software.

Very nice.

15 Jul 2017, 7:21 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: What identifies the admin directory?

For Zen Cart versions prior to 1.5.5, that "detection" was present in /YOUR_ADMIN/includes/configure.php. For ZC 1.5.5 and later, that processing was moved to /YOUR_ADMIN/includes/application_top.php.

In either case, the code essentially detects the current-working-directory and sets the DIR_FS_ADMIN definition appropriately.

16 Jul 2017, 1:07 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: What identifies the admin directory?

There are 2 places where this happens.

The first is as lat9 addressed. When you visit your Admin URL, Apache uses the directory you put in the URL to serve up the page, and then we use PHP's internal functions to tell us which path/file is currently executing, and use that to reverse-engineer what the working directory is for your Admin area.
The down-side to this is that nothing in your system "knows" what the Admin URL actually is, so there are a few things that can't be done behind an admin login, so alternate workarounds are necessary.

The second is in zc_install, which is also one of the caveats mentioned above. It needs to know your Admin foldername in order to not only offer a rename of the directory, but also to do an automatic upgrade of the configure.php file structure when it changes (as it did in v1.5.5: got leaner and easier to manage). For this, zc_install scans all your directories and looks for patterns which identify it as containing folders related to your Admin and not related to your storefront/catalog. That bit of code is indeed kinda cool, despite being relatively simple in the end. Credits to wilt for that. And then, once your zc_install is done, we ask you to delete that folder for safety reasons (you don't want someone to re-install your site overtop of a live store, right?!!), so all that admin-related logic is also removed (by you) so the site is left safe.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jul 2017, 2:20 AM
#4
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: What identifies the admin directory?

DrByte:

.......so the site is left safe.

And to keep the site safe and sound it is important that the operator does not rename the admin folder to something silly/stupid/simple like 'myadmin' which is easily guessed by wannabe or professional hackers. Instead use some combination of UPPER CASE,symbols, lower case and numbers which only makes sense to the operator themselves, such as the nick name of your grandma combined with her birth year, eg 'NAN&na+nineteen_23'.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

16 Jul 2017, 2:59 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: What identifies the admin directory?

There are various schools of thought on the ideal name for the admin directory.

But one must remember: the admin already requires a username and password to login. Using secure usernames and passwords is the FIRST and most important line of defense.

Choosing an "obscure" name for the admin directory is way less crucial. Admittedly, "security by obscurity" really isn't security at all.
But if a wannabe hacker does some quick probing and can't find a director that displays a login prompt, then they'll usually go away and look for other low-hanging fruit elsewhere. This has two benefits: no malicious attempts to login to your admin, and no wasted server-CPU resources while they're throwing a million passwords at your login form if they did find it.

The "obscurity" is just a deflection/decoy. It's NOT security.

So, zc_install picks 3-5 random words, and mixes the upper/lower case of letters randomly, and offers that as its suggestion for a directory name. In many schools this is considered more than adequate. Adding a digit or symbol further limits its being guessed.

Thus, in my opinion, while Frank's suggestion above is reasonable, I recommend that advice for your passwords and usernames, more than the directory name. But of course you could apply the same rules to both levels too.

I agree though: don't just rename it to "myadmin" ... BAH! or any other word that "means" "admin". That totally defeats the point, because hackers have already got lists of those words and will set automated probes to test whether they exist (if they choose to target you for some unfortunate reason).

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.