nur-sery/nur_tbin/passwd/dump-passwords.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2024-04-04 16:47:29 +04:00
#!/usr/bin/php
<?php
2024-04-04 22:21:20 +04:00
require __DIR__.'/../../vendor/autoload.php';
2024-04-04 16:47:29 +04:00
use nur\A;
use nur\cli\Application;
use nur\passwd\EtuPasswordGenerator;
Application::run(new class extends Application {
const ARGS = [
["-2", "name" => "version", "value" => 2],
["-3", "name" => "version", "value" => 3],
["-4", "name" => "version", "value" => 4],
];
protected $version;
protected $args;
function main() {
$version = $this->version;
if ($version === null) $version = 4;
$pg = new class($version) extends EtuPasswordGenerator {
function gen3seed(int $codEtu): int {
return parent::gen3seed($codEtu);
}
function gen4seed(int $codEtu): int {
return parent::gen4seed($codEtu);
}
};
$year = intval(date("y"));
$prefix = intval(A::get($this->args, 0, $year + 20)) % 100;
$codetu = $prefix * 1000000 + 1;
$max = ($prefix + 1) * 1000000;
$prev = 0;
echo "codetu,seed,delta,password\n";
while ($codetu < $max) {
switch ($version) {
case 3: $seed = $pg->gen3seed($codetu); break;
case 4: $seed = $pg->gen4seed($codetu); break;
default: $seed = null; break;
}
$delta = $seed - $prev;
$password = $pg->generate($codetu);
echo "$codetu,$seed,$delta,\"$password\"\n";
$prev = $seed;
$codetu++;
}
}
});