OpenLDAP Authentication - openldap

Is there any way to define your own encryption/decryption rather than having a plain text password store? Can you have your own algorithm and run that separately as part of the process? I am new and the documentation online although detailed does not specify any concrete ways of doing this. This is specific to OpenLDAP and the current method used for authentication.

To be able to have the server hash the password for you by default you have to add a password policy overlay and a directive.
If you are using the online cn=config method add an overlay sub entry to your olcDatabase object.
dn: olcOverlay={0}ppolicy,olcDatabase={2}hdb,cn=config
objectClass: olcPPolicyConfig
olcOverlay: {0}ppolicy
olcPPolicyHashCleartext: TRUE
Slapd.conf method:
database bdb
suffix "dc=example,dc=com"
...
# invokes password policies for this DIT only
overlay ppolicy
ppolicy_hash_cleartext
Then when you add a new user with the userpassword attribute in plain text it will store the password hashed. I believe the default is a salted sha1 which is pretty secure. You should also look into restricting access to the userpassword attribute.
olcAccess: to attrs=userPassword by self write by * auth

apache directory studio can accomplish this for you
This ldap browser detects the userpassword OID and provides an interface to hash the password.
suchas:
userPassword:: e01ENX1Lc25MZmNBclBBQ0Q2M0NKamxTYll3PT0=
(it just works, because it's built in)
Read the Openldap readme for more info:
This directory contains native slapd plugins for password mechanisms that
are not actively supported by the project. Currently this includes the
Kerberos, Netscape MTA-MD5 and RADIUS password mechanisms. The Apache
APR1 MD5 and BSD/Paul Henning Kamp MD5 mechanisms are also included.
To use the Kerberos plugin, add:
moduleload pw-kerberos.so
to your slapd configuration file.
yada yada yada

You should never, ever store passwords in reversible encryption if you use them for authentication!
You should store passwords with a one way hash function: MD5, SHA1, SHA256. If you do not absolutely require storing it in some old, specific format, you should always salt them. Salted SHA1 is the OpenLDAP good default.
The problem is, that you need to use LDAP Extended Operation to change the password, not the regular ldapmodify update, for it to work properly. Best to use ppolicy to actually enforce setting the password this way. You may want to do password quality checking and ageing if you're at it.

Related

How can i identify which type of encryption am i using?

my friend created his platform using laravel, and he encrypted the users password using laravel Hash. I never worked with laravel. I'm building a simple Android application to list all the users from his website, using PHP and Java, and i would like to decrypt the passwords for the login.
I usually use md5:
$password = md5($_GET['password']);
But he used a different hash. My password appears encrypted like this:
Q5joXS5QBA0xdV2Ed2c80e12ac10766d48ef5d8a916e445064091725156d7776958a3937b5cbe79
Thanks.
Some small research seems to show that they are hashed using Bcrypt. This is different to encrypting because it is one way. So to check if the two passwords match, you will need to encrypt the user input with Bcrypt and then check if the two match.
http://laravel.com/docs/4.2/security - Info on BCrypt.
You could use this to check if your passwords match up.
http://www.bcrypt-generator.com/
EDIT: I would advise against using md5 encryption as it is not very secure and it can "decrypted" by brute force.
Example: http://www.hashkiller.co.uk/md5-decrypter.aspx

Retrieve Password in ASP.NET Identity System

How to retrieve password back in original form in Asp.Net Identity System from PasswordHash column?
You don't.
The whole idea behind hashing algorithms is that they're one way processes. With some work you could swap out hashing for encryption of passwords, but A) if you've used the default (which is a hashing algorithm) and you've already got users in the database, you aren't getting those passwords back, and B) there are good security reasons passwords are hashed instead of encrypted.
If you just need to reset the password for the user and you have access to the source code, there's plenty of ways to do this. This SO Q&A is a good start.
Actually what i have to do is: In Admin module of my project i have to show existing users with their credentials ie username/email and their password......so reset password wont work.

Generate same password hash using PHPass

I am in the process of converting a site from Wordpress to a custom CMS developed in Codeigniter. I was told that Wordpress uses PHPass to hash their passwords, so I am using the PHPass library (as outlined at this site) in an attempt to seamlessly transition the users over without them having to reset or change their passwords.
I have it working fine in my application, but it's not generating the same password hashes as Wordpress uses. I'm assuming it's related to some kind of site key, but I'm not having any luck. How can I make PHPass generate the same password hash?
You won't be able to get PHPass to generate the same hash twice - it uses a random salt. That salt is stored inside the password hash.
You don't really need to generate the same hash, though - copy the old one, and use PHPass' CheckPassword($pass, $hash) to check the password. Give it the hash from the DB as $hash and the password entered as $pass, and it'll return true if they're a match.
The HashPassword() method is ONLY to be used to create a new password hash (for a new password), not to compare against an existing one.
There are a couple of possibilities. They're either using a different hashing algorithm or they're salting their hashes or some other method of obfuscation. If Wordpress salts their hashes, then you'd have to gain access to their salt table or single salt phrase to alter their hashes -- but I doubt you'll get that. I verified that PHPass does support salting as well as other hash obfuscating methods so one of those is probably the reason why your hashes aren't coming out identical.
http://www.openwall.com/articles/PHP-Users-Passwords

Wordpress,Drupal, Asp.net Membership Provider

I need to synchronize three of them but I have already 18k Asp.Net Members. (Offline synchronization)
So how can I convert default "Password Hashing" of Wordpress and Drupal to Asp.Net Membership's (SHA1 with Salt) ?
I don't know if you can. MD5 and SHA1 are uni-directional algorithms. This is why they are used. They provide security for the user passwords. So you will not be able to revert the hash back to the passwords. Nor can you convert from MD5 to SHA1 directly.
In this scenario I think you are stuck with resetting the Drupal and Wordpress user passwords when you merge. (See edits for alternate solution.)
EDIT: This post had a interesting idea / solution. Write some custom code to generate the SHA1 passwords upon your users first logging in. Collect the SHA1 hashes, and use those during merge. Any users you don't get, force them to do a password reset.

How to Login to a ASP.NET application by knowing only encrypted password?

I am very new to web application (ASP.NET). I have source code and database for a complete project.
ASP.NET (Authentication) control is used for login. I don't know the password right now but i can get the login name and password in encrypt format from the database table.
How could I login to the application with only this little information available.
As the control are dynamically created on the pages, it is very hard to debug and find them on runtime.
How could i proceed for login by encrypted password? or is there a way to login by overcoming Authentication control.
The password is probably SHA1 encrypted. Basically what you have to do is SHA1 encrypt the password the user gives you and compare that to the password in your database. Because SHA1 always results to the same thing if the input is the same, you will know that the users given password is correct if both hashes match.
SHA1 encryption is a form of hashing and cannot be reversed.
No, hashed passwords in the database are non-reversible intentionally. This keeps anyone (a hacker?) from reading your database and being able to log in.
As Sam152 said, the passwords are likely SHA1 hashed, so if the passwords are not stored with salt, you can build a rainbow table to find the original password. If they are salted, you need to know the salt to build the rainbow table as well.
You could try implementing custom MembershipProvider by derriving from this class. Then you just override method ValidateUser to meet your requirements. Also remember to modify Web.config.
The point of hashed passwords is that a they can't be used by folks not knowing the decrypted password.
There should be a way to reset the password for users. You could do this and log in based on the reset password.
If you are trying to log in to an active user's account, you may want to consider the implications in doing so without their knowledge (if that is the case). However, if it is just a test user, reseting the password is probably the least cumbersome way. That functionality or procedure should probably be part of web app anyway.
If it's the standard ASP.NET membership stuff, I think it uses a stored proc to check the DB. Just change that and have it return true or whatever.
Adding to the above answers SHA1 encryption output is 40 byte. You should check the length of the encrypted password to get an idea about the kind of encryption..since hash algorithm has predefined no of output bytes, this would help you map with the kind of algorithm and then you should look for possibile salt usage as #MattGWagner said...is the tables in database that stores user information seems like aspnet_users,aspnet_membership, etc? Then this should be the standard authentication provided by windows..Just google and see how it works

Resources