Subversion Repositories oidplus

Rev

Rev 211 | Rev 557 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
211 daniel-mar 1
#!/usr/bin/php
2
<?php
3
 
511 daniel-mar 4
/*
5
 * OIDplus 2.0
6
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
 
211 daniel-mar 21
define('TARGET_ID', '6175446'); // ViaThinkSoft RA
22
 
23
$config = array("digest_alg" => "sha1", // sha512
24
                "private_key_bits" => 384,
25
                "private_key_type" => OPENSSL_KEYTYPE_RSA,
26
               );
27
 
28
# ---
29
 
30
$cnt = 0;
31
 
32
echo date('Y-m-d H:i:s')." START\n";
33
 
34
while (true) {
35
	$cnt++;
36
 
37
	$res = openssl_pkey_new($config);
38
 
39
	$details = openssl_pkey_get_details($res);
40
	$pubKey = str_replace(array('BEGIN PUBLIC KEY','END PUBLIC KEY','-',"\n"), '', $details["key"]);
41
	unset($details);
42
 
43
	$system_id = smallhash(base64_decode($pubKey));
44
 
45
	if ($system_id == TARGET_ID) {
46
		openssl_pkey_export($res, $privKey);
47
		echo date('Y-m-d H:i:s')." COLLISSION WITH $system_id AFTER $cnt TRIES: ".$pubKey." / ".$privKey."\n";
48
		unset($privKey);
49
	}
50
 
51
	unset($res);
52
 
53
	if ($cnt%25 == 0) echo "PROCESSING: $cnt       \r";
54
}
55
 
56
function smallhash($data) { // get 31 bits from SHA1. Values 0..2147483647
57
	return (hexdec(substr(sha1($data),-4*2)) & 2147483647);
58
}
59