Created
July 9, 2023 10:01
-
-
Save crazywhalecc/3efc215d56cfbfc5d7b01e522bdea580 to your computer and use it in GitHub Desktop.
PHP 写的手机号 MD5 爆破脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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