-
Notifications
You must be signed in to change notification settings - Fork 11
OfHash Implement (Issue 7 Fix) #26
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
backups/* | ||
npp.bat | ||
.svn | ||
.svn | ||
.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,10 @@ | |
$ignoresrestrictions=$_POST['ignoresrestrictions']=="on"?"1":"0"; | ||
$ip=$_POST['ip']; | ||
$group=explode(":",$_POST['groups']); | ||
$password=sha1($_POST['pass']); | ||
include_once('hash/OfHash.php'); | ||
$hash = new OfHash(); | ||
$inputstring=$_POST['pass']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll want to check if the strlen of $_POST['pass'] is greater than 0 here BEFORE running the hasher -- no reason to run the hasher if there's no input here, since it's just editing a user (and not login, where it does actually matter). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It takes the POST, hashes it, then I use $password in the edit, since you can edit a password. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but hash it /after/ checking the string length. It is more efficient this way, as you don't hash if the user didn't even provide a password to hash. |
||
$password = $hash->hash($inputstring); | ||
if (strlen($_POST['pass']) > 0) | ||
{ | ||
$db->set("users",Array( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?php | ||
session_start(); | ||
require_once('config.php'); | ||
require_once('hash/OfHash.php'); | ||
$hash = new OfHash(); | ||
|
||
|
||
if($useflatfile){ | ||
require("flatfile.class.php"); | ||
|
@@ -16,10 +19,10 @@ | |
echo "MySQL Configuration Incorrect."; | ||
exit(); | ||
} | ||
$result=$db->fetch_by("users",Array("password"=>sha1($_POST['pass']),"name"=>$_POST['user']),""); | ||
if($result['password'] == sha1($_POST['pass'])) { | ||
$_SESSION['user']=$result["name"]; | ||
echo "1"; | ||
$result=$db->fetch_by("users",Array("password"=>$_POST['pass'],"name"=>$_POST['user']),""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you're still fetching with the hash as a WHERE condition in the select. Not gonna work. |
||
if($hash->check($_POST['pass'], $result['password'])){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be sure you're also running OfHash if the user doesn't exist, and that you're handling the "user does not exist" cases properly still. I can't tell by the diff context, it's up to you to make sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you say "running OfHash" what do you mean exactly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either generating a hash initially or checking a password; basically something that will "execute" the hash generation code for OfHash. Useful article if you're not aware of the growing precision OF timing attacks: http://blog.astrumfutura.com/2010/10/nanosecond-scale-remote-timing-attacks-on-php-applications-time-to-take-them-seriously/ |
||
$_SESSION['user']=$result["name"]; | ||
echo "1"; | ||
}else{ | ||
echo "0"; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#wrapper{display:table;overflow:hidden;margin:0px auto;} | ||
#container{display:table-cell;} | ||
html,body{height:100%;} | ||
body {background: #d3d3d3 url('images/bg.png') no-repeat top center; font-family: sans-serif; font-size: 16px;} | ||
a {text-decoration: none;color:#144564;} | ||
ul,li {} | ||
#footer {color: #b2b2b2;text-shadow:#fff 0px 1px 0, #999 0 -1px 0;} | ||
#footer a {color: #144564;text-decoration: none;} | ||
#wrapper{height:100%;width:800px;} | ||
#content {margin-top: 75px;text-align: left;} | ||
#footer {position: absolute;bottom: 15px;width:800px;text-align: center;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, you might as well just include OfHash in here and run it. That way, it's harder to detect if the default password is in use, just by looking at the hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default pass is supposed to be changed, its just inserted for placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless, having a policy of assuming people not being idiots is a poor one at best. Unless you're asking for an admin password in an installation script, you're doing it in a way that leaves the application vulnerable to a stupid administrator.
Remember, you don't just have to protect applications from attackers, but also from stupid users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would involve asking the user to make a password during installation, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ayup. Note that this is not necessarily a bad thing, actually, since it also means that there is a non-static "admin" account that's created as well preventing an attacker from knowing a "guaranteed" or "highly likely" account name.