PDA

View Full Version : Administrative and Maintenance Tools - admincp: Extra Security (htaccess)


Marv
01-04-2010, 10:00 PM
First of all: this isn?t my mod. I?have this one on my forums now for 4 or 5 years and was looking around here at vb.org for it but it seems it?s gone (or may be it never was released here). Yet, I haven?t found it so I tested this in vb4 and it works. Guess it?s quite useful for some of you so I share this with you.

This mod adds some extra security to your admincp. And your admincp only. The modcp remains untouched, so mods can access the modcp without a secondary login.

Files to edit: 1
Install time: 1 minute

Open admincp/index.php on your server.

Above:
// ######################## SET PHP ENVIRONMENT ###########################add this:

$index['public'] = $index['public'];
$phpkd['username'] = "Username"; // Here Is the User Name
$phpkd['password'] = "Password"; // Here Is The htaccess Password

if(!$index['public']){
if($_SERVER['PHP_AUTH_USER'] != $phpkd['username'] || $_SERVER['PHP_AUTH_PW'] != $phpkd['password']){
Header("WWW-Authenticate: Basic realm=\"Security Check\"");
Header("HTTP/1.0 401 Unauthorized");echo "<head><title>Unauthorized Login attempt</title></head><body bgcolor='#FFFFFF'><center><br>
<a href=\"../index.php\" style=\"text-decoration: none\" target=\"_self\">
<font face=\"MS Sans Serif\" color=\"#000000\" size=\"4\"><b><br>Unauthorized Login</b></a></body></html>";exit;}}
Change "Username" and "Password" to whatever you want, save and upload the file to your admincp (overwrite the old index.php or rename it first to index.php.old) and you?re done. Fast and simple.

If the original author is still around hit me back so you can release this one under your name.

Marv
01-05-2010, 02:18 PM
Weird but funny... :) I?ve found the original mod in the "Similiar Mod" section at the moment my post was published. It?s in the graveyard, huh? Guess thats the reason I hadn?t found it through the search engine before? So, all credits to SolidSnake@GTI (https://vborg.vbsupport.ru/member.php?u=74086). His original mod can be found here: https://vborg.vbsupport.ru/showthread.php?t=105179 .

SCSCSC
01-05-2010, 02:30 PM
toooo goood man thanks so much

garretbyrne
01-05-2010, 03:03 PM
Savage man, cheers for that

akee
01-05-2010, 03:16 PM
If I have more then 1 administrator?
I have 3 admin.

Marv
01-05-2010, 03:20 PM
If I have more then 1 administrator?
I have 3 admin.

This mod can?t handle mutiple logins with different logins/passwords so you are forced to share this login with your mods.

we_are_borg
01-05-2010, 05:03 PM
Well this is not true .htaccess because it's being used in the php file. If you want multiple logins look at http://www.javascriptkit.com/howto/htaccess3.shtml that should give you a idea for security. There even scripts that can make the login and password on the fly and add it in the .htaccess file.

Marv
01-05-2010, 05:22 PM
True. Therefor I said this Mod can?t handle mutliple logins ;)

Alecsmith
01-05-2010, 05:47 PM
Thanks u so much marv :)

Marv can u give code for mod cp also it will be really great :)

Marv
01-05-2010, 06:02 PM
Thanks u so much marv :)

Marv can u give code for mod cp also it will be really great :)

There is no special code for the modcp. You only have to put the code into root/modcp/index.php and you?re done.

Alecsmith
01-05-2010, 06:32 PM
Working thanks :)

Eric
01-05-2010, 08:11 PM
No need for a file edit for the admincp

There is a hook that could be used ;)


($hook = vBulletinHook::fetch_hook('admin_global')) ? eval($hook) : false;

HolyKiller
01-05-2010, 10:59 PM
If I have more then 1 administrator?
I have 3 admin.

HERE (https://vborg.vbsupport.ru/showthread.php?t=232303) ya go ;)

Marv
01-06-2010, 12:06 PM
Cool :) Good addition; HolyKiller !

steve1966
01-06-2010, 01:29 PM
No need for a file edit for the admincp

There is a hook that could be used ;)


($hook = vBulletinHook::fetch_hook('admin_global')) ? eval($hook) : false;


sorry for my bad but how do we use the hook?

also will this mod work if i have changed my admincp name?

thanks

cnutter
01-06-2010, 04:39 PM
Another easy way to do this is just create two files one called .htaccess one called .htpasswd

In .htaccess put the following:

AuthName "Password Required"
AuthType Basic
AuthUserFile /home/forums/.htpasswd <-- path to passwd file
AuthGroupFile /dev/null

require user JohnDoe <-- this is the user that will have access (case sensitive)
require user JohnDoe2 <-- Add as many as users as you need using this format.

in the .htpasswd file put the user name and the encrypted paswd in this format:
JohnDoe:XPHPiphsU8rkM <--- examples only
JohnDoe2:PRrJjeFUT5ZWg

Use .htaccess / .htpasswd will give you a two step login that offers server side protect.

Here is a link to a great how to on this plus it offers a tool for creating the encrypted passwords.

http://www.javascriptkit.com/howto/htaccess.shtml

HolyKiller
01-07-2010, 10:18 AM
Another easy way to do this is just create two files one called .htaccess one called .htpasswd

...



Yep, like i did :)

HERE (https://vborg.vbsupport.ru/showthread.php?t=232303)

cnutter
01-07-2010, 12:02 PM
Yep, like i did :)

HERE (https://vborg.vbsupport.ru/showthread.php?t=232303)

Yep like you did there. Didn't see that one thanx for the link. It should be pointed out in this thread at least that .htaccess/.htpasswd can and should be used to protect both the admincp and the modcp. You should also change the names of these area for added security though security though Obscurity isn't really security. Man can you say that one three times really fast? I can't. :)

darkdevilz
02-08-2010, 08:22 PM
Another methos is;

find first and foremost
<?php

and add this to under

$ourLogin = "username";
$ourPassword = "password";


session_start();

if ($_SESSION['login']!=$ourLogin && $_SESSION['password']!=$ourPassword) {


if ($_POST['login']==$ourLogin && $_POST['password']==$ourPassword) {


$_SESSION['login'] = $_POST['login'];
$_SESSION['password'] = $_POST['password'];
header("Location: index.php");


}
else {


echo "
<form action=index.php method=post>

<center><b>Are you sure to login ?</b></center>
<br>
<br>


Giris Ismi:<br>
<input type=text name=login value=********><br>

Giris Kodu:<br>
<input type=password name=password value=********><br>

<input type=submit value=' Login '>


</form>
";

exit;

}

}

synseal
02-19-2011, 04:12 AM
Very hand to have, thanks.

synseal
02-19-2011, 04:13 AM
Very handy to have, thanks.

synseal
02-19-2011, 04:14 AM
I only posted once? please Mods delete the other posts.

Delphiprogrammi
02-25-2011, 08:01 PM
Another methos is;

find first and foremost
<?php

and add this to under

$ourLogin = "username";
$ourPassword = "password";


session_start();

if ($_SESSION['login']!=$ourLogin && $_SESSION['password']!=$ourPassword) {


if ($_POST['login']==$ourLogin && $_POST['password']==$ourPassword) {


$_SESSION['login'] = $_POST['login'];
$_SESSION['password'] = $_POST['password'];
header("Location: index.php");


}
else {


echo "
<form action=index.php method=post>

<center><b>Are you sure to login ?</b></center>
<br>
<br>


Giris Ismi:<br>
<input type=text name=login value=********><br>

Giris Kodu:<br>
<input type=password name=password value=********><br>

<input type=submit value=' Login '>


</form>
";

exit;

}

}


two possible security issues here:

1) depending on PHP's session.save_path value(php.ini) if this is set to a world readable/writable directory like "/tmp" for example it might be possible for unauthorized users to get something which doesn't belong to them.session.save_path should be set to a non world readable/writable directory outside off your webroot then and only then your sessions are secure

2) usage of $_POST values directly without any form of sanitazation this could open the door to XSS(Cross Site Scripting) holes you should use


$vbulletin->GPC['variable'];