Skip to content

Instantly share code, notes, and snippets.

@Tedezed
Last active September 27, 2019 07:18
Show Gist options
  • Save Tedezed/d0821d805efafb05a3d4037251e94ad1 to your computer and use it in GitHub Desktop.
Save Tedezed/d0821d805efafb05a3d4037251e94ad1 to your computer and use it in GitHub Desktop.

Revisions

  1. Tedezed revised this gist Sep 27, 2019. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions check_password_admin_wordpress.php
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,20 @@
    <?php

    // php check_password_admin_wordpress.php USER_PASSWORD WORDPRESS_DATABASE_USER WORDPRESS_DATABASE_PASSWORD MARIADB_HOST MARIADB_PORT_NUMBER WORDPRESS_DATABASE_NAME
    // php check_password_admin_wordpress.php USER_PASSWORD WORDPRESS_DATABASE_USER WORDPRESS_DATABASE_PASSWORD MARIADB_HOST MARIADB_PORT_NUMBER WORDPRESS_DATABASE_NAME PATH_WP_INCLUDES

    // Arguments
    var_dump($argv);

    // include_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "wp-includes" . DIRECTORY_SEPARATOR . "class-phpass.php");
    include_once("/opt/bitnami/wordpress/wp-includes/class-phpass.php");

    $password = $argv[1];
    $db_user = getenv($argv[2]);
    $db_pass = getenv($argv[3]);
    $db_host = getenv($argv[4]);
    $db_port = getenv($argv[5]);
    $db_database = getenv($argv[6]);
    $path_wp_includes = getenv($argv[7]);

    // include_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "wp-includes" . DIRECTORY_SEPARATOR . "class-phpass.php");
    include_once($path_wp_includes . "class-phpass.php");

    $conn = new mysqli($db_host,$db_user,$db_pass,$db_database,$db_port);

    @@ -29,4 +30,4 @@
    echo "password is incorrect \n";
    }

    ?>
    ?>
  2. Tedezed created this gist Sep 24, 2019.
    32 changes: 32 additions & 0 deletions check_password_admin_wordpress.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <?php

    // php check_password_admin_wordpress.php USER_PASSWORD WORDPRESS_DATABASE_USER WORDPRESS_DATABASE_PASSWORD MARIADB_HOST MARIADB_PORT_NUMBER WORDPRESS_DATABASE_NAME

    // Arguments
    var_dump($argv);

    // include_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "wp-includes" . DIRECTORY_SEPARATOR . "class-phpass.php");
    include_once("/opt/bitnami/wordpress/wp-includes/class-phpass.php");

    $password = $argv[1];
    $db_user = getenv($argv[2]);
    $db_pass = getenv($argv[3]);
    $db_host = getenv($argv[4]);
    $db_port = getenv($argv[5]);
    $db_database = getenv($argv[6]);

    $conn = new mysqli($db_host,$db_user,$db_pass,$db_database,$db_port);

    //$result_query = mysqli_query($conn, "SELECT user_pass FROM wp_users WHERE id=1;");
    $result_query = $conn->query("SELECT user_pass FROM wp_users WHERE id=1;");
    $row = mysqli_fetch_assoc($result_query);

    $wp_hasher = new PasswordHash(8, true);
    $check = $wp_hasher->CheckPassword($password, $row['user_pass']);
    if($check) {
    echo "password is correct \n";
    } else {
    echo "password is incorrect \n";
    }

    ?>