Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
Add API generator for browser or direct use
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyrob committed Feb 26, 2021
1 parent 794daf4 commit b0a8b3c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api-hashes-generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
API Hash file generator for WordPress Exploit Scanner
Author: mattyrob
Author URI: http://subscribe2.wordpress.com/
*/

$version_url = 'https://api.wordpress.org/core/version-check/1.7/';
$checksum_url = 'https://api.wordpress.org/core/checksums/1.0/?version=';
$locale = '&locale=en_US';

$versions = file_get_contents( $version_url );
$versions = json_decode( $versions );

foreach( $versions->offers as $wp_version ) {
$filename = dirname( __FILE__ ) . '/' . 'hashes-' . $wp_version->version . '.php';
if ( ! file_exists( $filename ) ) {
$checksums = file_get_contents( $checksum_url . $wp_version->version . $locale );
$checksums = json_decode( $checksums, true );
$hashes = "<?php\n" . '$filehashes = array(' . "\n";
foreach ( $checksums['checksums'] as $file => $checksum ) {
if ( ! strstr( $file, 'wp-content' ) ) {
$hashes .= "\t'" . $file . "' => '" . $checksum . "',\n";
}
}
$hashes .= ");\n";
file_put_contents( $filename, $hashes );
echo 'Hash file created for ' . $wp_version->version . "\n";
}
}

0 comments on commit b0a8b3c

Please sign in to comment.