Rev 1116 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/env php
<?php
/*
* OIDplus 2.0
* Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const TARGET_ID = '6175446'; // ViaThinkSoft RA
$config = array("digest_alg" => "sha512",
"private_key_bits" => 2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
"config" => __DIR__."/../vendor/phpseclib/phpseclib/phpseclib/openssl.cnf",
);
# ---
$cnt = 0;
echo date('Y-m-d H:i:s')." START\n";
while (true) {
$cnt++;
$res = openssl_pkey_new($config);
if (!$res) die("openssl_pkey_new failed\n"); // can happen if private_key_bits is too small
$details = openssl_pkey_get_details($res);
$pubKey = str_replace(array('BEGIN PUBLIC KEY','END PUBLIC KEY','-',"\n"), '', $details["key"]);
unset($details);
$system_id = smallhash(base64_decode($pubKey));
if ($system_id == TARGET_ID) {
openssl_pkey_export($res, $privKey, null, $config);
echo date('Y-m-d H:i:s')." COLLISSION WITH $system_id AFTER $cnt TRIES: ".$pubKey." / ".$privKey."\n";
unset($privKey);
}
unset($res);
if ($cnt%25 == 0) echo "PROCESSING: $cnt \r";
}
/**
* @param string $data
* @return int
*/
function smallhash(string $data): int { // get 31 bits from SHA1. Values 0..2147483647
return (hexdec(substr(sha1($data),-4*2)) & 0x7FFFFFFF);
}