northox/stupid-password

Can't open file: StupidPass.default.dict

Closed this issue · 1 comments

PHP version: 5.6
I got php fatal error when use default password list
Please recheck

root@localhost:/var/www/html/vendor# php -n -d display_errors user_detect_weak_password.php

Warning: fopen(StupidPass.default.dict): failed to open stream: No such file or directory in /var/www/html/vendor/vendor/northox/stupid-password/php/StupidPass.php on line 165

Fatal error: Uncaught exception 'Exception' with message 'Can't open file: StupidPass.default.dict' in /var/www/html/vendor/vendor/northox/stupid-password/php/StupidPass.php:166
Stack trace:
#0 /var/www/html/vendor/vendor/northox/stupid-password/php/StupidPass.php(91): StupidPass->common()
#1 /var/www/html/vendor/user_detect_weak_password.php(33): StupidPass->validate('men56789')
#2 {main}
  thrown in /var/www/html/vendor/vendor/northox/stupid-password/php/StupidPass.php on line 166

my code

<?php

require 'vendor/autoload.php';

$root = '/var/www/html/stupid/';
$d = scandir($root);

$weak = [];

$simplePass = new StupidPass();

foreach($d as $f) {
	if(!is_file($root . '/' . $f))
		continue;

	$j = file_get_contents($root . '/' . $f);
	
	if(empty($j))
		continue;
	
	$user = json_decode($j, 1);

	// Skip system/test user
	if($user['username'] == 'guest' || preg_match('/test/i', $user['username']))
		continue;

	// Detect default password
	if ($user['username'] == $user['password']) {
		$user['reason'] = 'Default password';
		$weak[] = $user;
	}
	elseif (!$simplePass->validate($user['password'])) {
		$user['reason'] = 'Common password';
		$weak[] = $user;
	}
}

foreach($weak as $user) {
	echo $user['id'] . ' ' . $user['username'] . ' ' . $user['lastname'] . ' ' . $user['firstname'] . ' => ' . $user['reason'] . PHP_EOL;
}

echo 'Total ' . count($weak) . PHP_EOL;

Hello @tienthanh2509. Well the error message is saying you haven't copied the "StupidPass.default.dict" file at the right place. You should look into this. I'll reopen the ticket if there's something else.