Skip to content

Instantly share code, notes, and snippets.

@crazywhalecc
Created July 9, 2023 10:01
Show Gist options
  • Save crazywhalecc/3efc215d56cfbfc5d7b01e522bdea580 to your computer and use it in GitHub Desktop.
Save crazywhalecc/3efc215d56cfbfc5d7b01e522bdea580 to your computer and use it in GitHub Desktop.
PHP 写的手机号 MD5 爆破脚本
<?php
$phone = '13345454545';
$a = md5($phone, true);
$bss = md5($phone);
use Swoole\Process;
$starttime = microtime(true);
echo "Cracking $bss\n";
// 将数据按照核心数平分
$begin = 1000000000;
$origin_begin = $begin;
$end = 9999999999;
$cut = swoole_cpu_num();
$nut = intval(floor(($end - $begin) / $cut));
$pid = [];
for ($i = 1; $i <= $cut; ++$i) {
$nend = $begin + $nut;
if ($nend > $end) {
$nend = $end;
}
$task = [
"begin" => $begin,
"end" => $nend,
];
$proc = new Process(function() use (&$proc, $i, $task, $a) {
$n1 = $task['begin'];
$n2 = $task['end'];
echo "[{$i}] [{$n1} - {$n2}]\n";
for ($j = $n1; $j <= $n2; ++$j) {
if (md5('1' . $j, true) === $a) {
echo "FOUND: 1" . $j . PHP_EOL;
exit(0);
}
}
exit(1);
});
$begin = $nend + 1;
$pid[$i - 1] = $proc->start();
}
$found = false;
$status = Process::wait(true);
if ($status['code'] === 0) {
foreach ($pid as $p) {
if ($status['pid'] !== $p) {
Process::kill($p, SIGKILL);
}
}
}
$found = true;
echo "Used " . (microtime(true) - $starttime) . " s\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment