Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite wordlist random word selection to fix issues with multibyte characters in wordlists #87

Closed
wants to merge 1 commit into from

Conversation

Connum
Copy link

@Connum Connum commented Feb 25, 2019

I had issues with multibyte characters when using a wordlist, e.g. European umlauts and special chars (äöüßñø). The end value of the substring in the old code would sometimes be smaller than the start value, resulting in a long string containing multiple words. This code fixes these issues and should also be a bit faster.

@dapphp dapphp closed this in 915df38 May 30, 2020
@dapphp
Copy link
Owner

dapphp commented May 30, 2020

Sorry it took forever. I have pushed a fix that should resolve your issues that is still fast and memory efficient.

Yours works fine but I would avoid the use of the file function because that will read the entire file into memory as a PHP array which could get fairly large depending on the size of the wordlist. And on a busy site invoking this over and over could be an unnecessary drain on resources.

Thank you and I hope my change works if you are still using it.

@dapphp
Copy link
Owner

dapphp commented May 30, 2020

Also note, depending on the character set of your wordlist, it is very important to specify the wordlist_file_encoding option.

e.g.

<?php

$options = [
 'use_wordlist' => true,
 'wordlist_file' => '/path/to/list.txt',
 'wordlist_file_encoding' => 'WINDOWS-1251', // GB2312, UTF-8, etc...
 // ...other options
];

$img = new Securimage($options);

The options can also go in config.inc.php located in the securimage directory, or located elsewhere and passed in to the constructor using the config_file option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants