Coder Social home page Coder Social logo

bbusschots / hsxkpasswd Goto Github PK

View Code? Open in Web Editor NEW
276.0 276.0 47.0 35.56 MB

A Perl module and terminal command for generating secure memorable passwords inspired by the fabulous XKCD web comic and Steve Gibson's Password Hay Stacks. This is the library that powers www.xkpasswd.net

Home Page: http://www.bartb.ie/xkpasswd

License: BSD 2-Clause "Simplified" License

Perl 100.00%

hsxkpasswd's People

Contributors

bbusschots avatar clsn avatar jbreuer95 avatar mshulman avatar podfeet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hsxkpasswd's Issues

Use a bigger English default dictionary

The dictionary provided by default with this program is very small. For enhanced security, it would be better to replace or augment this dictionary with one that has at least ten to fifteen thousand words. There are many dictionary lists available from the page at http://wordlist.aspell.net/other-dicts/, and they'll even help you tune your dictionary list to just the right "size", using the tool at http://app.aspell.net/create

I was able to quickly create a dictionary with over 10,000 common English words based on their information sources.

Check out the list provided by the URL http://app.aspell.net/create?max_size=20&spelling=US&spelling=GBz&spelling=CA&max_variant=0&diacritic=strip&special=hacker&special=roman-numerals&download=wordlist&encoding=utf-8&format=inline and then strip out lines 1-44 (the header), and all lines that contain an apostrophe in them.

Allow fixed length password with variable word lengths

I wish there was a way to use potentially different length words to generate a fixed-length password. Say for example you request 16-characters worth of words that might be 3 words of length 5 + 4 + 7 or 3 words of length 6 + 6 + 4. The lazy way would just be to throw away generated passwords that are too long until enough of the required length are produced, but may take longer to get the results. I just installed hsxkpasswd from source and I'm working on a lazy implementation in shell right now.

Bonus would be potentially different number of words like 2 words or 4 words but adding up to the same number of characters from words. Programming wise, might be subtracted from a count until the required number of characters from words was satisfied. Bonus bonus: words must still be within minimum length, might have to generate then throw it out if the last word is going to be too short, or try a shorter 2nd to last word for example.

The rationale is that the position of separators would be less predictable, which would make using rules to crack the generated passwords less effective vs having a certain number of words all the same length.

I have tried using rules that make words of variable lengths but had to click "Generate" multiple times because the generated batch exceeds the length restriction of the site they will be used for, then end up counting characters to make sure.

xkpasswd.net dictionaries?

Why there is no support for using different languages in www.xkpasswd.net? It seems that this library already supports other languages.

I would love to be able to use the password generator for other languages too. Thanks!

password generation with named argument 'dictionary_file'

When installing from CPAN, I get:

Failed test 'password generation with named argument 'dictionary_file''

and

Failed test 'password generation with named arguments 'dictionary_file' & 'dictionary_file_encoding''

What could be the problem here? Is my installation incomplete somehow? (OS X)

"keys on reference is experimental"

keys on reference is experimental at /usr/local/share/perl/5.20.2/Crypt/HSXKPasswd.pm line 610.
keys on reference is experimental at /usr/local/share/perl/5.20.2/Crypt/HSXKPasswd.pm line 628.
keys on reference is experimental at /usr/local/share/perl/5.20.2/Crypt/HSXKPasswd.pm line 628.

perl -v

This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux-gnu-thread-multi
(with 42 registered patches, see perl -V for more detail)

Is it intended?

Intermittent Problem with Random Numbers

This doesn't happen often, but every now and then it does:

ERROR - Crypt::HSXKPasswd::password(): Failed to generate password with the following error: ERROR - Crypt::HSXKPasswd::_increment_random_cache(): random function returned and invalid value (6.1053317040205e-05) at /usr/local/bin/hsxkpasswd line 464. at /usr/local/bin/hsxkpasswd line 464.

Typos

In Build.PL and also in lib/Crypt/HSXKPasswd.pm you refer to "Steve Gibson's Passord[sic] Haystacks", instead of "Password". Is it less disruptive for you if I file this issue or a pull request?

Consider creating a Homebrew formula

I use Homebrew exclusively for installing any CLI applications, but aside from the few simple commands I know, getting under the hood and creating the formula myself seems a bit tricky to me.

Being the lead developer, it would be very convenient if you created a formula for HSXKPasswd yourself in order to avoid any errors a formula created by somebody else in the future would have, as well as to help expose HSXKPasswd to more people who may find it useful.

Thanks 😊

Insecure random number generator

Hi,

The function basic_random_generator that is used by default to generate random numbers is insecure. It uses Perl's built-in "rand" function and the Perl docs state:

        "rand()" is not cryptographically secure. You should not rely on
        it in security-sensitive situations. As of this writing, a number
        of third-party CPAN modules offer random number generators
        intended by their authors to be cryptographically secure,
        including: Data::Entropy, Crypt::Random, Math::Random::Secure, and
        Math::TrulyRandom.

Remove insecure random

Remove

  • Basic.pm
  • RandomDotOrg.pm

If for some reason you want to keep RandomDotOrg.pm you should fix

my $dec = $line/$RDO_MAX_INT;
unless($dec >= 0 && $dec <=1){

        my $dec = $line/($RDO_MAX_INT+1);
        unless($dec >= 0 && $dec <1){

Also consider fixing the slight bias in doing itemIndex = floor(rand * numberOfItems). You can do something like https://github.com/Sc00bz/ModRandom/blob/4fc203bc18bd32254c33369205557f720145abb6/random.c#L137

Edit: Changed link

Increase the minimum required entropy before we warn

Okay, so I've done a bit more digging, and I think we need to update the math that is being referenced.

Currently, oclHashCat (see http://hashcat.net/oclhashcat/) can do about 42408 Mh/s when cracking SHA-1 password hashes, on a single computer with multiple GPU cards. Note that Mh/s is Million Hashes per Second.

So, if we have only 52 bits of entropy (which is the current default before we warn), that would take 4503599627370496 / 42408000000 = 106196.935 seconds to brute-force the entire space. That's less than 30 minutes. And cracked on a single machine, assuming a hashing algorithm that isn't too excessively old.

We could reduce that by an order of magnitude, if we could make the assumption that everyone was forced to use SHA-3 instead of SHA-1, because we would be reducing the speed to 5240 Mh/s.

But this still wouldn't be taking into account speed improvements through parallelization (e.g., running on EC2's GPGPU cluster).

Maybe we should tell people how many bits of seen entropy that are being generated, and how fast those passwords could be cracked, using a few different assumptions for speed?

command line tool does not distil configs before validation when using -c

When using the command line to test function (-t flag), the config is distilled, then validated, allowing keys that should not be present to be ignored.

When trying to use a config file with the -c flag, the behavior is not the same - configs are not distilled before being validated, so a config can pass -t, but fail when used with -c.

The -c flag needs to be updated to behave the same as the -t flag.

Improve documentation and provide a sample configuration file

So, I want to provide my own dictionary. And I want my own version of a password preset. In fact, I want to be able to create multiple presets of my own.

But I have no idea what a configuration file should look like, or how I would put it somewhere that it would get used by default.

The Perl POD documentation is pretty extensive, but I'd like to see more of that brought into the man page and into the README.md file for this repo. But even the Perl POD documentation doesn't show me how to create a configuration file or where I could put it so that it would get used by default.

Regularize the dictionary sizes for each language

So, I cloned the repo and checked out the code.

787853 lines for PT.pm? Seriously? Your program fails to do its job if the dictionary you're choosing from is too large for the humans to be able to immediately recognize and understand most of the words. Most people have a working vocabulary of about five to ten thousand words, so having a dictionary that is much more than ten thousand words is already stretching it a bit, but not too excessively much.

But three quarters of a million words?!? Even "huge" dictionaries only have on the order of ninety to a hundred thousand words. I can't imagine a dictionary that would have 750,000 words.

Entropy calculation on website doesn't match tool

The following config says 61 bits with full-knowledge on https://xkpasswd.net/ but when I run locally I get WARNING - Crypt::HSXKPasswd::_update_entropystats_cache(): for attacks assuming full knowledge, the combination of the loaded config and dictionary produces an entropy of 33bits, below the minimum recommended 52bits at /usr/local/bin/hsxkpasswd line 448

{
"num_words": 3,
"word_length_min": 4,
"word_length_max": 8,
"case_transform": "RANDOM",
"separator_character": "-",
"padding_digits_before": 0,
"padding_digits_after": 0,
"padding_type": "NONE"
}

Blind Entropy calculation

Not entirely my area, but this seems a bit off based on the walkthrough you posted in the documentation.

# calculate the blind permutations - (based purely on length and alphabet)
my $alphabet_count = 12; # all passwords have at least one case of letters
if($self->{_CONFIG}->{case_transform} =~ m/^(ALTERNATE)|(CAPITALISE)|(INVERT)|(RANDOM)$/sx){
    $alphabet_count += 12; # these configs guarantee a mix of cases
}

Shouldn't $alphabet_count = 26 for one case and 52 for mixed case?

I've fixed it locally but will probably fiddle with a few more things before submitting another pull request. Let me know your thoughts.

Using the same example script from before, I get a seen entropy of 44 and I think that should be higher so I am trying to work them out using your guide and verify the code is doing the same.

https://xkpasswd.net/ appears to be outdated?

Expected:

This option on the website:
"case_transform": "ALTERNATE"

...should randomize first word and then alternate word case thereafter.
According to this change:
https://github.com/bbusschots/hsxkpasswd/releases/tag/v3.3.1
"The ALTERNATE case transform now randomises the case of the first word, and then alternates from there. This adds a little more entropy, and makes more sense than having it always be the same IMO."

Observed:

Instead, the first word is always lower case, second always UPPER case, third always lower case

Other observations:

  1. Website indicates it is powered by old version.
    Website: "This site is powered by the XKPasswd.pm Perl Module"
    Github indicates latest version should be
    Crypt-HSXKPasswd-v3.5 released ]on Aug 10, 2015
    Crypt-HSXKPasswd-v3.6 released ]on Aug 11, 2015

  2. Issue #32 "Entropy calculation on website doesn't match tool"
    Probably resolved with 2015 BETA3 release:
    "There was a subtle error in how the entropy was calculated for the worst-case scenario (where attackers know both the configuration and word source used). Unfortunately the bug caused the module to overestimate the entropy. Because if this, some presets had to be altered after the bug was fixed to keep them below the entropy warning thresholds. This proved impossible for the WEB16 preset, so it has now issues a warning in the same way the NTLM preset does."

Use of uninitialized value $word

I'm testing the module and have been using substitution characters. My test script is included in the Gist below.

The module throws this error when processing:

Use of uninitialized value $word in substitution (s///) at /Users/chorton/KomodoProjects/xkpasswd.pm/xkpasswd.pm//XKPasswd.pm line 2329.
Use of uninitialized value $words[4] in join or string at /Users/chorton/KomodoProjects/xkpasswd.pm/xkpasswd.pm//XKPasswd.pm line 1260.

https://gist.github.com/hortocam/d182ed5f5ee0b4d06a31#file-test_xkpasswd-pm-pl

dict-file unable to be used

When using the command with no flags, the code works as intended. When using a config file, it also works as intended. When using -d (--dict-file) I receive the following:

ERROR - failed to initialise HSXKPasswd with error:
* Alternative signatures must be CODE, HASH, or ARRAY refs at /usr/local/share/perl/5.34.0/Type/Params/Signature.pm line 28.

After installing MacOS Big Sur I get the error: Can't locate File/HomeDir.pm

I updated my Mac with Big Sur. Now the hsxkpasswd script won't run anymore. I get the following error:

Can't locate File/HomeDir.pm in @INC (you may need to install the File::HomeDir module) (@INC contains: /Library/Perl/5.28/darwin-thread-multi-2level /Library/Perl/5.28 /Network/Library/Perl/5.28/darwin-thread-multi-2level /Network/Library/Perl/5.28 /Library/Perl/Updates/5.28.2/darwin-thread-multi-2level /Library/Perl/Updates/5.28.2 /System/Library/Perl/5.28/darwin-thread-multi-2level /System/Library/Perl/5.28 /System/Library/Perl/Extras/5.28/darwin-thread-multi-2level /System/Library/Perl/Extras/5.28) at /usr/local/bin/hsxkpasswd line 14. BEGIN failed--compilation aborted at /usr/local/bin/hsxkpasswd line 14.

I googled and found I maybe needed to install the himedir (again) using sudo cpan -i File::HomeDir . But no luck with that.

When I install hsxkpasswd from scratch I see this error passing by in the logging:
HASCOMPILER8_2A/TEST4bx0.c:2:10: fatal error: 'EXTERN.h' file not found #include "EXTERN.h" ^~~~~~~~~~ 1 error generated. Couldn't execute cc -g -pipe -fno-strict-aliasing -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -Os "-I/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE" -c HASCOMPILER8_2A/TEST4bx0.c -o HASCOMPILER8_2A/TEST4bx0.o: Inappropriate ioctl for device at Makefile.PL line 14.

(I updated Xcode btw).

What can I do to make this work again?

Packaging

Please consider CPAN as a distribution point.

Support for Γ†Γ˜Γ… characters in dictionary

It seems like there is no support for international characters like the norwegian æøΓ₯ in the dictionary, because I get no passwords who contains those characters even though I have words with them in the dictionary file.

Can this be fixed?

t/02-generate-passwords.t fails with Type-Tiny-2.000001

After upgrading Type-Tiny from 1.016010 to 2.000001 t/02-generate-passwords.t fails like this:

t/01-defined-constants.t ... ok
#   Failed test 'password generation with named argument 'dictionary_list''
#   at t/02-generate-passwords.t line 28.
#   Failed test 'password generation with named argument 'dictionary_file''
#   at t/02-generate-passwords.t line 35.
#   Failed test 'password generation with named arguments 'dictionary_file' & 'dictionary_file_encoding''
#   at t/02-generate-passwords.t line 41.
# Looks like you failed 3 tests of 10.
t/02-generate-passwords.t .. 
Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/10 subtests 

This is triggered by this change in Type-Tiny tobyink/p5-type-tiny@4baba12:

commit 4baba12312f45d2e657468e26b64c643687651d1 (HEAD)
Author: Toby Inkster <[email protected]>
Date:   Sun Sep 11 19:16:15 2022 +0100

    Bring multisig functionality into the v2 API

I can reduce the reproducer to:

perl -T -I/tmp/p5-type-tiny/lib -Ilib -e 'use Crypt::HSXKPasswd; Crypt::HSXKPasswd->new(dictionary_list => [qw(seme tes words)])'
Alternative signatures must be CODE, HASH, or ARRAY refs at /tmp/p5-type-tiny/lib/Type/Params/Signature.pm line 26.

This exception was added in the linked commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.