Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php try { ini_set("\155\x61\170\137\145\x78\145\143\x75\x74\151\x6f\156\x5f\16..

Decoded Output download

<?php 
 
 
try { 
    ini_set("max_execution_time", 0); 
    $bs = explode("wp-content", $_SERVER["SCRIPT_FILENAME"]); 
    require_once $bs[0] . "wp-load.php"; 
    update_option("mo_ldap_user_sync_button_disabled", "true"); 
    error_log("STARTING LDAP USERS SYNC"); 
    $Kq = new Mo_Users_Sync_Config(); 
    $rw = $Kq->get_all_users(); 
    update_option("mo_ldap_user_sync_total_users", sizeof($rw) - 1); 
    remove_all_actions("profile_update"); 
    remove_all_actions("user_register"); 
    remove_all_actions("set_user_role"); 
    error_log("SIZE: " . sizeof($rw)); 
    $eS = 0; 
    hr: 
    if (!($eS < sizeof($rw))) { 
        goto Xf; 
    } 
    if (!$rw[$eS]) { 
        goto rM; 
    } 
    update_option("mo_dirsync_progress", "Sync in progress: " . $eS . "/" . sizeof($rw) . " users synced"); 
    error_log(print_r($rw[$eS], TRUE)); 
    $ZE = $rw[$eS]["samaccountname"][0]; 
    error_log("UNAME: " . $ZE); 
    $Z1 = $rw[$eS]["mail"][0]; 
    error_log("EMAIL: " . $Z1); 
    if (!username_exists($ZE)) { 
        goto Fo; 
    } 
    error_log("Updating user " . $ZE . " while syncing"); 
    $user = get_user_by("login", $ZE); 
    $bF = array("ID" => $user->ID); 
    if (!isset($rw[$eS]["mail"])) { 
        goto mb; 
    } 
    $bF["user_email"] = $rw[$eS]["mail"][0]; 
    mb: 
    if (!isset($rw[$eS]["givenname"])) { 
        goto Z2; 
    } 
    $bF["first_name"] = $rw[$eS]["givenname"][0]; 
    Z2: 
    if (!isset($rw[$eS]["sn"])) { 
        goto N6; 
    } 
    $bF["last_name"] = $rw[$eS]["sn"][0]; 
    N6: 
    $kN = wp_update_user($bF); 
    if (is_wp_error($kN)) { 
        goto QO; 
    } 
    error_log("Updated User with ID: " . $kN . ", username: " . $ZE); 
    if (!isset($rw[$eS]["memberof"])) { 
        goto lM; 
    } 
    error_log("Adding user to WP Role"); 
    update_role_mapping($kN, $rw[$eS]["memberof"]); 
    lM: 
    goto y0; 
    QO: 
    $PS = $kN->get_error_code(); 
    $V2 = $kN->get_error_message($PS); 
    error_log("Error updating user " . $ZE . ": Code: " . $PS . ": Reason: " . $V2); 
    y0: 
    goto Ek; 
    Fo: 
    error_log("no: " . $eS); 
    $bF = array(); 
    $bF["user_login"] = $ZE; 
    $bF["user_email"] = $rw[$eS]["mail"][0]; 
    if (!isset($rw[$eS]["givenname"])) { 
        goto nU; 
    } 
    $bF["first_name"] = $rw[$eS]["givenname"][0]; 
    nU: 
    if (!isset($rw[$eS]["sn"])) { 
        goto au; 
    } 
    $bF["last_name"] = $rw[$eS]["sn"][0]; 
    au: 
    $TK = wp_generate_password($UZ = 12, $iT = false); 
    $bF["user_pass"] = $TK; 
    $sm = wp_insert_user($bF); 
    if (is_wp_error($sm)) { 
        goto O8; 
    } 
    error_log("Created User with ID: " . $sm . ", email: " . $Z1); 
    if (!isset($rw[$eS]["memberof"])) { 
        goto lA; 
    } 
    error_log("Adding user to WP Role"); 
    update_role_mapping($sm, $rw[$eS]["memberof"]); 
    lA: 
    goto Xa; 
    O8: 
    $PS = $sm->get_error_code(); 
    $V2 = $sm->get_error_message($PS); 
    error_log("Error creating user " . $ZE . ": Code: " . $PS . ": Reason: " . $V2); 
    Xa: 
    Ek: 
    update_option("mo_ldap_user_sync_synced_users", $eS + 1); 
    sleep(5); 
    rM: 
    Mv: 
    $eS++; 
    goto hr; 
    Xf: 
    error_log("LDAP USERS SYNC COMPLETED"); 
} catch (Exception $TE) { 
    error_log($TE->getMessage()); 
} finally { 
    update_option("mo_ldap_user_sync_button_disabled", "false"); 
    update_option("mo_ldap_user_sync_total_users", ''); 
    update_option("mo_ldap_user_sync_synced_users", ''); 
} 
function update_role_mapping($A8, $Ym) 
{ 
    error_log("Updating Role for user " . $A8 . " with memberof " . print_r($Ym, TRUE)); 
    if (!($A8 == 1)) { 
        goto OT; 
    } 
    return; 
    OT: 
    $Md = 0; 
    $n3 = 0; 
    if (!is_numeric(get_option("mo_ldap_local_role_mapping_count"))) { 
        goto YA; 
    } 
    $n3 = intval(get_option("mo_ldap_local_role_mapping_count")); 
    YA: 
    error_log("Mapping Count: " . $n3); 
    $i3 = new WP_User($A8); 
    $Ss = 0; 
    pe: 
    if (!($Ss < $Ym["count"])) { 
        goto zg; 
    } 
    $eS = 1; 
    dD: 
    if (!($eS <= $n3)) { 
        goto zT; 
    } 
    $oR = get_option("mo_ldap_local_mapping_key_" . $eS); 
    $R8 = strcasecmp($oR, $Ym[$Ss]); 
    error_log("Testing match with memberOf as " . $Ym[$Ss] . " and group as " . $oR); 
    error_log("Match: " . $R8); 
    if ($R8 == 0) { 
        goto YN; 
    } 
    error_log("Could not match to " . "group: " . $oR); 
    goto JX; 
    YN: 
    $Tt = get_option("mo_ldap_local_mapping_value_" . $eS); 
    if (!$Tt) { 
        goto Gd; 
    } 
    error_log("Matched with group dn " . $oR . "Adding role-group mapping: " . $Tt); 
    if (!($Md == 0)) { 
        goto bn; 
    } 
    $i3->set_role(''); 
    bn: 
    $i3->add_role($Tt); 
    $Md++; 
    Gd: 
    JX: 
    Fv: 
    $eS++; 
    goto dD; 
    zT: 
    Pm: 
    $Ss++; 
    goto pe; 
    zg: 
    if (!($Md == 0)) { 
        goto J7; 
    } 
    if (!get_option("mo_ldap_local_mapping_value_default")) { 
        goto Cj; 
    } 
    $i3->set_role(get_option("mo_ldap_local_mapping_value_default")); 
    Cj: 
    J7: 
} ?>

Did this file decode correctly?

Original Code

<?php


try {
    ini_set("\155\x61\170\137\145\x78\145\143\x75\x74\151\x6f\156\x5f\164\x69\x6d\x65", 0);
    $bs = explode("\x77\x70\55\x63\x6f\x6e\x74\x65\156\x74", $_SERVER["\x53\x43\122\111\x50\124\137\x46\111\x4c\105\x4e\x41\x4d\x45"]);
    require_once $bs[0] . "\x77\x70\x2d\154\157\141\x64\x2e\160\x68\160";
    update_option("\155\157\137\x6c\144\x61\160\137\165\163\145\162\137\163\x79\156\143\x5f\x62\165\164\x74\x6f\156\137\x64\x69\163\141\x62\x6c\145\144", "\x74\x72\165\x65");
    error_log("\123\x54\x41\122\124\111\x4e\x47\40\114\x44\x41\120\40\x55\123\105\x52\123\40\x53\131\x4e\103");
    $Kq = new Mo_Users_Sync_Config();
    $rw = $Kq->get_all_users();
    update_option("\155\157\x5f\x6c\144\x61\x70\137\x75\x73\x65\x72\x5f\x73\171\156\143\x5f\x74\157\x74\x61\154\x5f\x75\163\x65\162\163", sizeof($rw) - 1);
    remove_all_actions("\x70\x72\x6f\x66\x69\154\x65\137\x75\160\x64\141\x74\x65");
    remove_all_actions("\165\x73\x65\162\x5f\x72\x65\147\151\x73\x74\145\x72");
    remove_all_actions("\x73\x65\164\x5f\165\163\x65\x72\x5f\x72\157\154\145");
    error_log("\123\x49\132\105\x3a\x20" . sizeof($rw));
    $eS = 0;
    hr:
    if (!($eS < sizeof($rw))) {
        goto Xf;
    }
    if (!$rw[$eS]) {
        goto rM;
    }
    update_option("\155\157\137\x64\x69\x72\x73\x79\156\x63\x5f\x70\162\x6f\x67\x72\x65\163\x73", "\123\171\156\x63\40\151\156\40\x70\162\157\x67\x72\x65\163\x73\72\40" . $eS . "\57" . sizeof($rw) . "\x20\165\x73\x65\162\x73\40\x73\171\156\143\145\x64");
    error_log(print_r($rw[$eS], TRUE));
    $ZE = $rw[$eS]["\163\x61\x6d\x61\143\143\x6f\x75\156\x74\x6e\141\x6d\145"][0];
    error_log("\x55\116\101\115\x45\x3a\x20" . $ZE);
    $Z1 = $rw[$eS]["\x6d\x61\x69\x6c"][0];
    error_log("\105\x4d\101\x49\114\x3a\x20" . $Z1);
    if (!username_exists($ZE)) {
        goto Fo;
    }
    error_log("\125\x70\144\x61\x74\151\156\x67\40\165\163\145\162\40" . $ZE . "\x20\167\150\151\154\x65\40\163\171\156\x63\x69\156\147");
    $user = get_user_by("\154\x6f\x67\151\156", $ZE);
    $bF = array("\x49\104" => $user->ID);
    if (!isset($rw[$eS]["\155\x61\x69\x6c"])) {
        goto mb;
    }
    $bF["\165\x73\x65\162\137\145\155\x61\151\x6c"] = $rw[$eS]["\x6d\x61\x69\154"][0];
    mb:
    if (!isset($rw[$eS]["\x67\151\166\145\x6e\156\141\155\145"])) {
        goto Z2;
    }
    $bF["\146\151\x72\x73\164\x5f\x6e\141\x6d\145"] = $rw[$eS]["\x67\151\x76\145\x6e\x6e\x61\x6d\145"][0];
    Z2:
    if (!isset($rw[$eS]["\x73\156"])) {
        goto N6;
    }
    $bF["\154\x61\x73\x74\137\x6e\x61\x6d\145"] = $rw[$eS]["\x73\x6e"][0];
    N6:
    $kN = wp_update_user($bF);
    if (is_wp_error($kN)) {
        goto QO;
    }
    error_log("\125\x70\144\141\164\x65\144\40\x55\163\x65\162\x20\167\x69\x74\150\40\x49\104\72\x20" . $kN . "\54\40\165\163\145\162\156\141\x6d\x65\72\40" . $ZE);
    if (!isset($rw[$eS]["\x6d\145\x6d\x62\x65\x72\157\x66"])) {
        goto lM;
    }
    error_log("\101\x64\144\151\x6e\147\40\165\x73\145\x72\x20\164\157\x20\127\x50\40\122\157\x6c\145");
    update_role_mapping($kN, $rw[$eS]["\155\145\x6d\142\x65\162\157\146"]);
    lM:
    goto y0;
    QO:
    $PS = $kN->get_error_code();
    $V2 = $kN->get_error_message($PS);
    error_log("\105\x72\162\157\162\40\x75\x70\x64\141\x74\x69\x6e\x67\x20\x75\163\x65\x72\x20" . $ZE . "\72\40\x43\x6f\144\145\x3a\x20" . $PS . "\x3a\x20\122\145\141\163\157\156\72\x20" . $V2);
    y0:
    goto Ek;
    Fo:
    error_log("\x6e\157\x3a\40" . $eS);
    $bF = array();
    $bF["\x75\163\145\162\137\x6c\157\147\x69\x6e"] = $ZE;
    $bF["\x75\163\x65\162\137\145\x6d\141\151\154"] = $rw[$eS]["\x6d\x61\x69\154"][0];
    if (!isset($rw[$eS]["\x67\151\x76\145\x6e\x6e\141\x6d\145"])) {
        goto nU;
    }
    $bF["\x66\151\162\163\x74\x5f\156\x61\x6d\145"] = $rw[$eS]["\x67\x69\x76\145\156\x6e\x61\155\145"][0];
    nU:
    if (!isset($rw[$eS]["\x73\156"])) {
        goto au;
    }
    $bF["\x6c\x61\163\164\x5f\156\x61\155\x65"] = $rw[$eS]["\163\x6e"][0];
    au:
    $TK = wp_generate_password($UZ = 12, $iT = false);
    $bF["\165\x73\145\162\x5f\160\141\x73\163"] = $TK;
    $sm = wp_insert_user($bF);
    if (is_wp_error($sm)) {
        goto O8;
    }
    error_log("\103\162\145\141\164\145\x64\x20\x55\163\145\162\x20\x77\151\x74\150\x20\x49\x44\72\x20" . $sm . "\54\x20\x65\155\x61\x69\x6c\72\40" . $Z1);
    if (!isset($rw[$eS]["\155\145\x6d\x62\x65\x72\157\146"])) {
        goto lA;
    }
    error_log("\101\x64\144\x69\x6e\x67\40\165\163\x65\162\40\x74\x6f\40\x57\x50\x20\122\157\x6c\x65");
    update_role_mapping($sm, $rw[$eS]["\x6d\x65\155\x62\x65\162\157\146"]);
    lA:
    goto Xa;
    O8:
    $PS = $sm->get_error_code();
    $V2 = $sm->get_error_message($PS);
    error_log("\105\162\x72\157\x72\x20\x63\x72\145\x61\164\151\x6e\x67\40\165\163\x65\x72\40" . $ZE . "\72\40\103\x6f\x64\145\72\40" . $PS . "\72\40\122\x65\x61\x73\x6f\x6e\x3a\40" . $V2);
    Xa:
    Ek:
    update_option("\x6d\x6f\x5f\154\x64\141\x70\x5f\x75\163\145\x72\137\x73\171\x6e\143\137\163\x79\x6e\x63\x65\x64\137\165\163\145\x72\x73", $eS + 1);
    sleep(5);
    rM:
    Mv:
    $eS++;
    goto hr;
    Xf:
    error_log("\114\x44\101\x50\x20\x55\123\x45\x52\123\40\x53\x59\x4e\103\40\103\117\115\120\x4c\x45\124\105\104");
} catch (Exception $TE) {
    error_log($TE->getMessage());
} finally {
    update_option("\155\x6f\x5f\154\144\x61\x70\x5f\165\163\x65\162\x5f\x73\x79\156\x63\137\x62\x75\164\x74\x6f\x6e\x5f\x64\x69\x73\x61\142\154\145\x64", "\146\x61\x6c\163\x65");
    update_option("\x6d\x6f\137\154\x64\141\160\137\x75\x73\145\x72\137\x73\x79\x6e\x63\x5f\164\157\x74\141\x6c\137\165\163\145\162\x73", '');
    update_option("\x6d\157\137\154\144\x61\x70\137\165\x73\145\162\x5f\x73\x79\x6e\x63\137\163\171\x6e\x63\x65\x64\137\165\x73\x65\x72\x73", '');
}
function update_role_mapping($A8, $Ym)
{
    error_log("\x55\x70\x64\141\x74\x69\156\147\x20\x52\157\154\145\x20\146\x6f\162\40\x75\163\145\162\40" . $A8 . "\40\x77\151\164\x68\x20\155\145\155\x62\145\x72\x6f\146\40" . print_r($Ym, TRUE));
    if (!($A8 == 1)) {
        goto OT;
    }
    return;
    OT:
    $Md = 0;
    $n3 = 0;
    if (!is_numeric(get_option("\x6d\x6f\137\x6c\144\141\160\x5f\154\157\x63\141\x6c\x5f\x72\157\x6c\x65\137\x6d\141\x70\x70\x69\x6e\147\x5f\x63\157\x75\156\164"))) {
        goto YA;
    }
    $n3 = intval(get_option("\155\157\137\154\x64\x61\160\x5f\x6c\157\143\x61\154\137\x72\x6f\154\x65\x5f\x6d\x61\160\x70\x69\156\x67\137\143\x6f\165\156\164"));
    YA:
    error_log("\115\x61\160\160\151\x6e\147\40\103\x6f\165\156\x74\72\40" . $n3);
    $i3 = new WP_User($A8);
    $Ss = 0;
    pe:
    if (!($Ss < $Ym["\143\157\x75\156\164"])) {
        goto zg;
    }
    $eS = 1;
    dD:
    if (!($eS <= $n3)) {
        goto zT;
    }
    $oR = get_option("\x6d\x6f\x5f\x6c\x64\141\160\x5f\154\x6f\143\x61\x6c\x5f\155\141\160\x70\x69\156\x67\x5f\x6b\x65\x79\x5f" . $eS);
    $R8 = strcasecmp($oR, $Ym[$Ss]);
    error_log("\124\x65\x73\x74\151\156\147\x20\x6d\141\164\x63\150\x20\167\x69\164\150\40\x6d\x65\x6d\x62\x65\162\117\146\40\x61\x73\40" . $Ym[$Ss] . "\x20\x61\x6e\x64\40\147\x72\157\x75\x70\40\x61\x73\40" . $oR);
    error_log("\x4d\x61\164\x63\150\x3a\40" . $R8);
    if ($R8 == 0) {
        goto YN;
    }
    error_log("\103\157\x75\154\144\x20\x6e\x6f\164\40\x6d\141\164\143\150\40\x74\x6f\x20" . "\x67\162\157\x75\160\72\40" . $oR);
    goto JX;
    YN:
    $Tt = get_option("\155\x6f\137\x6c\x64\x61\x70\x5f\154\x6f\143\x61\x6c\x5f\155\x61\160\160\x69\x6e\147\x5f\x76\x61\154\165\x65\x5f" . $eS);
    if (!$Tt) {
        goto Gd;
    }
    error_log("\x4d\x61\164\143\150\x65\144\40\167\151\164\150\x20\x67\162\157\165\160\40\144\156\x20" . $oR . "\x41\144\x64\x69\156\147\40\162\157\154\145\x2d\147\x72\x6f\x75\x70\40\x6d\141\x70\160\x69\156\x67\72\x20" . $Tt);
    if (!($Md == 0)) {
        goto bn;
    }
    $i3->set_role('');
    bn:
    $i3->add_role($Tt);
    $Md++;
    Gd:
    JX:
    Fv:
    $eS++;
    goto dD;
    zT:
    Pm:
    $Ss++;
    goto pe;
    zg:
    if (!($Md == 0)) {
        goto J7;
    }
    if (!get_option("\x6d\x6f\137\x6c\x64\141\x70\137\154\x6f\143\141\x6c\137\x6d\x61\x70\x70\151\156\147\x5f\166\x61\154\165\145\137\144\145\x66\141\x75\154\x74")) {
        goto Cj;
    }
    $i3->set_role(get_option("\x6d\x6f\x5f\x6c\144\141\x70\137\x6c\x6f\143\x61\x6c\x5f\x6d\x61\x70\x70\x69\156\x67\x5f\x76\x61\154\165\x65\137\x64\x65\146\141\165\154\x74"));
    Cj:
    J7:
}

Function Calls

None

Variables

None

Stats

MD5 60aa3b7c0a4d15df7a9eea5c0317dde5
Eval Count 0
Decode Time 99 ms