Last active
September 1, 2022 06:21
-
-
Save sdennler/8c8655fee8e60f4406f871231d5e404e to your computer and use it in GitHub Desktop.
Create a rainbow table with IPv4 addresses
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 | |
function allIPv4(): Generator | |
{ | |
for ($i=0; $i <= 4294967295; $i++) { | |
yield long2ip($i); | |
} | |
} | |
foreach (allIPv4() as $ip) { | |
echo hash('sha256', $ip).' '.$ip."\n"; | |
} | |
/* | |
* This did run in in 260.42 mins (4h 20min) | |
* and generated a 175849518952 byte (164 GB) gz file. | |
*/ | |
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 | |
function allIPv4(): Generator | |
{ | |
$ranges = [ | |
'1.0.0.0' => '9.255.255.255', | |
'11.0.0.0' => '100.63.255.255', | |
'100.128.0.0' => '126.255.255.255', | |
'128.0.0.0' => '169.253.255.255', | |
'169.255.0.0' => '172.15.255.255', | |
'172.32.0.0' => '191.255.255.255', | |
'192.0.1.0' => '192.0.1.255', | |
'192.0.3.0' => '192.31.195.255', | |
'192.31.197.0' => '192.52.192.255', | |
'192.52.194.0' => '192.88.98.255', | |
'192.88.100.0' => '192.167.255.255', | |
'192.169.0.0' => '192.175.47.255', | |
'192.175.49.0' => '198.17.255.255', | |
'198.20.0.0' => '198.51.99.255', | |
'198.51.101.0' => '203.0.112.255', | |
'203.0.114.0' => '223.255.255.255', | |
]; | |
foreach ($ranges as $start => $end) { | |
for ($i=ip2long($start); $i <= ip2long($end); $i++) { | |
yield long2ip($i); | |
} | |
} | |
} | |
foreach (allIPv4() as $ip) { | |
echo hash('sha256', $ip).' '.$ip."\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment