<?php
/**
- * Create serialized/commonpasswords.cdb
+ * Generate includes/password/commonpasswords.cdb
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* For example:
* https://github.com/danielmiessler/SecLists/blob/fe2b40dd84/Passwords/rockyou.txt?raw=true
*
- * @see serialized/commonpasswords.cdb and PasswordPolicyChecks::checkPopularPasswordBlacklist
+ * @see PasswordPolicyChecks::checkPopularPasswordBlacklist
* @since 1.27
* @ingroup Maintenance
*/
-class GenerateCommonPassword extends Maintenance {
+class CreateCommonPasswordCdb extends Maintenance {
public function __construct() {
global $IP;
parent::__construct();
$this->addArg( 'inputfile', 'List of passwords (one per line) to use or - for stdin', true );
$this->addArg(
'output',
- "Location to write CDB file to (Try $IP/serialized/commonpasswords.cdb)",
+ "Location to write CDB file to (Try $IP/includes/password/commonpasswords.cdb)",
true
);
}
$outfile = $this->getArg( 1 );
if ( !is_readable( $infile ) && $infile !== 'php://stdin' ) {
- $this->error( "Cannot open input file $infile for reading", 1 );
+ $this->fatalError( "Cannot open input file $infile for reading" );
}
$file = fopen( $infile, 'r' );
if ( $file === false ) {
- $this->error( "Cannot read input file $infile", 1 );
+ $this->fatalError( "Cannot read input file $infile" );
}
try {
continue;
}
if ( isset( $alreadyWritten[$line] ) ) {
- $this->output( "Password '$line' already written (line " . ( $i + 1 ) .")\n" );
+ $this->output( "Password '$line' already written (line " . ( $i + 1 ) . ")\n" );
$skipped++;
continue;
}
" (out of $i) passwords to $outfile\n"
);
} catch ( \Cdb\Exception $e ) {
- $this->error( "Error writing cdb file: " . $e->getMessage(), 2 );
+ $this->fatalError( "Error writing cdb file: " . $e->getMessage(), 2 );
}
}
}
-$maintClass = "GenerateCommonPassword";
+$maintClass = CreateCommonPasswordCdb::class;
require_once RUN_MAINTENANCE_IF_MAIN;