4 ms·
This is my password manager. password = b64encode(hashlib.pbkdf2_hmac( 'sha256', (master_password + '/' + domain).encode(), b'',
by dheera 9y ago
This is my password manager.
password = b64encode(hashlib.pbkdf2_hmac(
'sha256',
(master_password + '/' + domain).encode(),
b'',
100000 + n
)).decode()[0:16] + 'Aa$1'
master_password = some master password that you never write or store anywhere
domain = domain name for the service in question, e.g. 'facebook.com'
n = the nth password being generated for the domain (typically 0)
The 'Aa$1' is to ensure satisfaction of stupid password rules on various websites.
Advantages:
- Open source. You don't have to use some random person's password manager software that you have no clue how or where the passwords are being stored or the trustability of the people who wrote the software.
- Portability. You can run this on any OS including a phone with a Python implementation, and it's pretty easy to port the above to any other language with a hash library.
- No files to lose. You don't need to worry about losing a password manager's database, you don't need to worry about syncing the database across machines, and you can compute the above on any machine that you own and trust. Kernel panics while you're on vacation? No worries! Reformat your PC with a fresh Ubuntu install and compute the above to get access to your bank account, plane tickets, and e-mail again.
- danieldk 9y agoDisadvantages: - You have to keep track of n for every site. - If the master password is compromised, you have to change each password manually. - Not well-integrated with browsers. - Far less convenience on a phone.
- Leftium 9y agoI use https://pwdhash.com https://pwdhash.com with _n_ suffixed to the master password. - If last few recent n's don't work, I just reset the password to the most recent n. - There are browser extensions - There are apps, and my web UI (https://ph.leftium.com https://ph.leftium.com) works OK (and a bookmarklet adds more convenience)
- dheera 9y ago> - You have to keep track of n for every site. I consider this far better than having to keep a password manager's database. n = 0 for the vast majority of sites without sensitive personal data. For the small handful that need to change, I usually sync them all to the same value of n about once or twice a year. > - Not well-integrated with browsers. I use Chrome's password-saving feature for websites that don't store sensitive personal data. For websites that I consider sensitive, I actually like that it isn't integrated with the browser. > - Far less convenience on a phone. This is true. If my laptop can act as a bluetooth keyboard to my phone it might make life easier.
- deleted 9y ago[deleted]
- weinzierl 9y agoThe problem with this solution is that it is only as strong as your master password. Because you suggest to 'never write or store [it] anywhere' it can't be strong enough. To say it in Bruce Schneier's words: "Pretty much anything that can be remembered can be cracked."[1] [1] https://boingboing.net/2014/02/25/choosing-a-secure-password.html https://boingboing.net/2014/02/25/choosing-a-secure-password...
- tluyben2 9y agoMaybe you have something that calculates what is strong enough? Is there some online calculator?
- dheera 9y agoI memorized 1024 digits of pi in high school. I can deal with a strong password. Keep in mind that most password managers also encrypt your password database with your master password, so my solution isn't any worse than those. Memorizing a even a 16-character (upper/lower + symbols) random string as your master password would be 16*6 = 96 bits of entropy which is more than enough. Dealing with memorizing ONE good 16-character random string is within the abilities of most people. Dealing with multiple ones is what is hard.
- Exuma 9y agoAnd I thought my memorizing 100 digits was an achievement
- 9y ago
- dagenix 9y agoDisadvantage: If any website you use has it's password database leaked, an attacker can then do an offline brute force attack to recover your master password. Then, the attacker can then generate your password to every other site you use, such as banks and email, just by trying a couple values of n.
- dheera 9y agoThat's the point of using PBKDF-HMAC-SHA256. As long as your master password is strong it's not going to be brute forceable for the forseeable future.
- dagenix 9y agoMy point is that this is dangerous. The security of this method is equal to the strength of you master password + the least secure website you use. If that website has a password breach, the only thing standing between an attacker and a compromise of every website you use is the strength of you master key. (And GPUs are pretty good at brute forcing PBKDF2 - so it has to be really strong.) This is unlike a stateful password manager. There the security of the system is related to the strength of your password + the strength of the security of the place you store your password db. If you pick a place that is serious about security, your almost certainly better off. Critically, a compromise of some random forum you signed up for doesn't impact the security of your bank account in any way.
- dheera 9y ago> The security of this method is equal to the strength of you master password + the least secure website you use. Not exactly. It's equal to the strength of your master password only. Even if one of your passwords leaked, this function does not compute fast enough in the forseeable future to brute force your master password, as long as your master password is strong. > And GPUs are pretty good at brute forcing PBKDF2 - so it has to be really strong. Interesting, thanks for telling me this. But how much better? I mean, a GPU with 1024 CUDA cores surely cannot surpass 1024 CPUs. So all we need to do is bump up 100000 to a slightly higher number to make it GPU-proof if that's the case, no? > There the security of the system is related to the strength of your password + the strength of the security of the place you store your password db. If you pick a place that is serious about security, your almost certainly better off. The problem is that it's difficult to find some places that is serious, and that you trust to be serious. Most people will end up putting it on Dropbox or Google Drive because there isn't anything else that is accessible to them and easy to use on a phone. Also, what if you're on vacation, PC rendered in an unbootable state, and you need to reinstall your OS? This has happened to me at least 3 times.
- afshin 9y agoOne problem I had when using a similar technique is how to change passwords. Some services require regular password changes, security breaches require it, etc. So I needed some additional piece of information, namely how many times I've had to change passwords, so a new function argument. Eventually I gave up and started using a password manager.
- dheera 9y agoThat's what 'n' is for in the code above. There are only a small handful of sensitive websites I use that require frequent password changes and I usually sync them all to the same incremented value of n every few months.
- afshin 9y agoGotcha. I think that the manual effort of that was what put me off managing passwords myself.
- 6ak74rfy 9y agoThis is exactly what http://masterpasswordapp.com/ http://masterpasswordapp.com/ provides. One of the biggest drawbacks of this approach is that you are stuck with your master-password. You can't change it without modifying those for all the websites.
- linsomniac 9y agoI used to do something very similar to this, for around 5 years. It works fairly well, but I've moved away from it largely because: There are always exceptions that won't work (you can't have one scheme that both satisfies "you must have one special character" and "you cannot have any special characters"), and it also doesn't let you change your password for a site. I was able to come up with something that worked in 95% of the cases, it was the 5% that got me to stop using it.
- z1mm32m4n 9y agoThat's what the incrementing variable is for. Of course, you have to then remember how many times you've changed your password for any given site.
- rosser 9y agoHow does incrementing a counter address some sites requiring special characters while others reject them?
- dheera 9y agoThe counter only addresses requirements to change password periodically. The special character requirement is addressed by tacking on 'Aa$1' to all passwords (they asked for it; it's what I tacked to all the (good) passwords I memorized even before I had this method).
- wodenokoto 9y agoAll your passwords have special characters. Some places do not accept special characters in passwords. This is what your scheme doesn't address.
- amorphid 9y agoThat works until you visit the website for my insurance company... "You must use one of these special characters: %^&*()"
- G3E9 9y agoWouldn't combining the "master_password", "domain" and your username/email save you from worrying about the "n" variable? You are using "n" to differentiate from multiple accounts on "domain", right?.. or am I misunderstanding?
- dheera 9y agoNo, I'm using 'n' to deal with websites that periodically require you to change password and enforce that you use a new password I suppose I could also do it as master_password + '/' + domain + str(n) or something like that.
- G3E9 9y agoAhh, ok then how about using the DateTime at runtime? That would then save you from having to keep "n" stored elsewhere for future uses. Edit: nevermind, this would prevent you from retrieving the password - I had in mind a password generator, sorry.
- dheera 9y agoBy the way it's generally not a good idea to use dates in password generation or for random seeds. An attacker who has any information about the approximate time you generated the password (e.g. minutes before registering for a site) would be able to iterate over those several thousand seconds. For consumer use cases, you should use sources of noise for this, such as microphone noise, mouse movements, fluctuating voltages, etc. If you wanted to be super-secure you would use a quantum random number generator, which is truly random, but unnecessary for the threat models of most consumer uses. Just use anything but date/time. The random number generators of most modern languages and operating systems already have such measures in place.
- dheera 9y agoBy the way, for those wondering about convenience, this will wait 3 seconds (during which you switch to your web browser and click the password field) and then it will "type" the password. (You do NOT want to cut-and-paste your password from a terminal as the clipboard can be read by anything.) # requires: sudo apt-get install xautomation for 'xte' import time from subprocess import Popen, PIPE macro = "" for char in password: if char == '$': macro += "keydown Shift_L\nkey 4\nkeyup Shift_L\n" elif char == '+': macro += "keydown Shift_L\nkey equal\nkeyup Shift_L\n" elif char == '/': macro += "key slash\n" elif char.isupper(): macro += "keydown Shift_L\nkey %s\nkeyup Shift_L\n" % char elif char.islower() or char.isdigit(): macro += "key %s\n" % char print("Entering password in 3 seconds ... [^C to abort]") time.sleep(3) Popen(['xte'], stdin=PIPE).communicate(macro.encode())
- shocks 9y agoI cleaned it up a bit and added the missing keys: https://github.com/wridgers/pwtools/blob/master/bin/pwtype https://github.com/wridgers/pwtools/blob/master/bin/pwtype
- nextInt 9y agoThis is a long blog post that talks about some drawbacks of this approach: https://tonyarcieri.com/4-fatal-flaws-in-deterministic-password-managers https://tonyarcieri.com/4-fatal-flaws-in-deterministic-passw... Before reading this I was convinced that stateless deterministic approaches like these was the ideal. But some arguments in that post changed my mind.
- ecesena 9y agoHe's uses _n_ for state, so it's not really state-less (in fact, issues 1 and 2 don't apply).
- dheera 9y ago> Deterministic password generators cannot accommodate varying password policies without keeping state 16 characters + 'Aa$1' has universally satisfied every website I have used to date except Baidu (which imposes a maximum of 16 characters total on passwords). The number of exceptions to this is probably miniscule. > Deterministic password generators cannot handle revocation of exposed passwords without keeping state That's what 'n' is for. Either you can keep 'n' as a state variable which is much easier to manage (and if you lose the file, you can try a few values of n and get yourself back into those websites without much hassle), OR sync the values of n every several months on the sites that use it. > Deterministic password managers can’t store existing secrets This is orthogonal to the password problem. I store sensitive files that aren't passwords in a GPG-encrypted tarball on Dropbox. > Exposure of the master password alone exposes all of your site passwords This is true of stateful password managers as well, if you backup your database on anywhere insecure or any device (e.g. laptop) that could potentially be mugged at gunpoint, confiscated by border control, leaked by buggy software, etc.
- chilicuil 9y agoYou shouldn't use hash functions designed for integrity, they're fast, fast is bad for password hashing, a single AMD graphics card can compute 200M guesses per second for single sha-512 iterations, instead use bcrypt, scrypr or any other hash function specifically designed for key stretching. https://hashcat.net/hashcat/ https://hashcat.net/hashcat/ https://en.m.wikipedia.org/wiki/Key_stretching https://en.m.wikipedia.org/wiki/Key_stretching
- dheera 9y agoYep, I'm using pbkdf2-hmac-sha256 which is not just sha-256. The 2nd link you posted mentions pbkdf2.
- qixxiq 9y agoI do something similar, but the solution instead of `Aa$1` is to use the output to produce a shorter password with those properties [1]. Makes it a little easier to type in. I also keep a list of the "domains" along with plaintext comments for each of them (username, email I used, etc) that are not strictly required (so still portable) but just make it a little more useful when it's synced. The big downside I've found is lack of apps. Sure it would run on any phone, but I haven't managed to get it to run on the phones conveniently. So if I'm without a laptop right now for the most part I'm locked out. [1] https://github.com/passwordly/passwordly-python/blob/master/passwordly/password.py#L50-L69 https://github.com/passwordly/passwordly-python/blob/master/...
- Havoc 9y ago>The 'Aa$1' is to ensure satisfaction of stupid password rules on various websites. "Your password is too long"
- gkya 9y agoYeah, in an ideal world... In the real world I'm coerced to use some apps and websites with shit security, and have to store stuff like PINs &c which impose a certain structure on the secret, and if I'm not misunderstanding, this can't help with that sort of secrets.