Пример #1
0
function GOTMLS_init()
{
    global $GOTMLS_onLoad, $wp_version, $wpdb, $GOTMLS_threats_found, $GOTMLS_file_contents;
    if (GOTMLS_user_can()) {
        if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"])) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_what"] = 2;
        }
        if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"])) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_depth"] = -1;
        }
        if (isset($_REQUEST["scan_type"]) && $_REQUEST["scan_type"] == "Quick Scan") {
            if (!isset($_REQUEST["scan_what"])) {
                $_REQUEST["scan_what"] = 2;
            }
            if (!isset($_REQUEST["scan_depth"])) {
                $_REQUEST["scan_depth"] = 2;
            }
            if (!(isset($_POST["scan_only"]) && is_array($_POST["scan_only"]))) {
                $_POST["scan_only"] = array("", "wp-content/plugins", "wp-content/themes");
            }
        }
        //$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"] = stripslashes($_POST["check_custom"]);
        if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"])) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check_custom"] = "";
        }
        if (isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"]) && is_numeric($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"])) {
            $scan_level = intval($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"]);
        } else {
            $scan_level = count(explode('/', trailingslashit(get_option("siteurl")))) - 1;
        }
        if (isset($_REQUEST["dont_check"]) && is_array($_REQUEST["dont_check"]) && count($_REQUEST["dont_check"])) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"] = $_REQUEST["dont_check"];
        } elseif (isset($_POST["scan_type"]) || !(isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]))) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"] = array();
        }
        if ($array = get_option('GOTMLS_definitions_array')) {
            if (is_array($array)) {
                $GLOBALS["GOTMLS"]["tmp"]["definitions_array"] = $array;
            }
        } else {
            $wpdb->query("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE 'GOTMLS_known_%' OR `option_name` LIKE 'GOTMLS_definitions_array_%'");
            array_walk($GLOBALS["GOTMLS"]["tmp"]["settings_array"], "GOTMLS_reset_settings");
        }
        $GOTMLS_definitions_versions = array();
        foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"] as $threat_level => $definition_names) {
            foreach ($definition_names as $definition_name => $definition_version) {
                if (is_array($definition_version) && isset($definition_version[0]) && strlen($definition_version[0]) == 5) {
                    if (!isset($GOTMLS_definitions_versions[$threat_level]) || $definition_version[0] > $GOTMLS_definitions_versions[$threat_level]) {
                        $GOTMLS_definitions_versions[$threat_level] = $definition_version[0];
                    }
                }
            }
        }
        if (isset($_POST["UPDATE_definitions_array"]) && strlen($_POST["UPDATE_definitions_array"])) {
            if (strlen($_POST["UPDATE_definitions_array"]) > 1) {
                $GOTnew_definitions = maybe_unserialize(GOTMLS_decode($_POST["UPDATE_definitions_array"]));
                if (is_array($GOTnew_definitions)) {
                    $GOTMLS_onLoad .= "updates_complete('Downloaded Definitions');";
                }
            } elseif (($DEF = GOTMLS_get_URL(GOTMLS_update_home . 'definitions.php?ver=' . GOTMLS_Version . '&wp=' . $wp_version . '&ts=' . date("YmdHis") . '&d=' . ur1encode(GOTMLS_siteurl))) && ($GOT_definitions = GOTMLS_decode($DEF)) != serialize($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]) && is_array($GOTnew_definitions = maybe_unserialize($GOT_definitions)) && count($GOTnew_definitions)) {
                if (!(isset($_REQUEST["check"]) && is_array($_REQUEST["check"]))) {
                    $_REQUEST["check"] = array();
                }
                foreach ($GOTnew_definitions as $threat_level => $definition_names) {
                    if (!isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["{$threat_level}"]) && !(is_array($GLOBALS["GOTMLS"]["tmp"]["settings"]["check"]) && in_array("{$threat_level}", $GLOBALS["GOTMLS"]["tmp"]["settings"]["check"])) && !in_array("{$threat_level}", $_REQUEST["check"])) {
                        $_REQUEST["check"][] = "{$threat_level}";
                    }
                }
                $GLOBALS["GOTMLS"]["tmp"]["definitions_array"] = $GOTnew_definitions;
                $GOTnew_definitions = array();
                $GOTMLS_onLoad .= "updates_complete('New Definitions Automatically Installed :-)');";
            } else {
                $GOTnew_definitions = "";
            }
        }
        //elseif (file_exists(GOTMLS_plugin_path.'definitions_update.txt'))	$GOTnew_definitions = maybe_unserialize(GOTMLS_decode(file_get_contents(GOTMLS_plugin_path.'definitions_update.txt')));
        if (isset($GOTnew_definitions) && is_array($GOTnew_definitions)) {
            $GLOBALS["GOTMLS"]["tmp"]["definitions_array"] = GOTMLS_array_replace_recursive($GLOBALS["GOTMLS"]["tmp"]["definitions_array"], $GOTnew_definitions);
            if (file_exists(GOTMLS_plugin_path . 'definitions_update.txt')) {
                @unlink(GOTMLS_plugin_path . 'definitions_update.txt');
            }
            if (isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"])) {
                unset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"]);
            }
            update_option('GOTMLS_definitions_array', $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]);
            foreach ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"] as $threat_level => $definition_names) {
                foreach ($definition_names as $definition_name => $definition_version) {
                    if (is_array($definition_version) && isset($definition_version[0]) && strlen($definition_version[0]) == 5) {
                        if (!isset($GOTMLS_definitions_versions[$threat_level]) || $definition_version[0] > $GOTMLS_definitions_versions[$threat_level]) {
                            $GOTMLS_definitions_versions[$threat_level] = $definition_version[0];
                        }
                    }
                }
            }
        }
        asort($GOTMLS_definitions_versions);
        $GLOBALS["GOTMLS"]["tmp"]["Definition"]["Updates"] = '?div=Definition_Updates';
        foreach ($GOTMLS_definitions_versions as $definition_name => $GLOBALS["GOTMLS"]["tmp"]["Definition"]["Latest"]) {
            $GLOBALS["GOTMLS"]["tmp"]["Definition"]["Updates"] .= "&ver[{$definition_name}]=" . $GLOBALS["GOTMLS"]["tmp"]["Definition"]["Latest"];
        }
        if (isset($_REQUEST["check"]) && is_array($_REQUEST["check"])) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = $_REQUEST["check"];
        }
        /*	$threat_names = array_keys($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"]);
        		foreach ($threat_names as $threat_name) {
        			if (isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]) && is_array($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]) && count($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]) > 1) {
        				if ($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name][0] > $GOTMLS_definitions_version)
        					$GOTMLS_definitions_version = $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name][0];
        				if (!(count($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]) && in_array($threat_name, $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["dont_check"]))) {
        					$GLOBALS["GOTMLS"]["tmp"]["threat_levels"][$threat_name] = count($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["known"][$threat_name]);
        					if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"]) && $GLOBALS["GOTMLS"]["tmp"]["threat_levels"][$threat_name] > 2)
        						$GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = "known";
        				}
        			}
        		}*/
        if (!isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"])) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["check"] = $GLOBALS["GOTMLS"]["tmp"]["threat_levels"];
            update_option("GOTMLS_settings_array", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
        }
        if (isset($_POST["GOTMLS_fix"]) && !is_array($_POST["GOTMLS_fix"])) {
            $_POST["GOTMLS_fix"] = array($_POST["GOTMLS_fix"]);
        }
        GOTMLS_update_scan_log(array("settings" => $GLOBALS["GOTMLS"]["tmp"]["settings_array"]));
        if (isset($_POST['GOTMLS_whitelist']) && isset($_POST['GOTMLS_chksum'])) {
            $file = GOTMLS_decode($_POST['GOTMLS_whitelist']);
            $chksum = explode("O", $_POST['GOTMLS_chksum'] . "O");
            if (strlen($chksum[0]) == 32 && strlen($chksum[1]) == 32 && is_file($file) && md5(@file_get_contents($file)) == $chksum[0]) {
                $filesize = @filesize($file);
                if (true) {
                    if (!isset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file][0])) {
                        $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file][0] = "A0002";
                    }
                    $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file][$chksum[0] . 'O' . $filesize] = "A0002";
                } else {
                    unset($GLOBALS["GOTMLS"]["tmp"]["definitions_array"]["whitelist"][$file]);
                }
                update_option("GOTMLS_definitions_array", $GLOBALS["GOTMLS"]["tmp"]["definitions_array"]);
                die(GOTMLS_html_tags(array("html" => array("body" => "Added {$file} to Whitelist!<br />\n<iframe style='width: 90%; height: 350px;' src='" . GOTMLS_plugin_home . "whitelist.html?whitelist=" . $_POST['GOTMLS_whitelist'] . "&hash={$chksum['0']}&size={$filesize}&key={$chksum['1']}'></iframe>"))));
            } else {
                echo "<li>Invalid Data!</li>";
            }
        } elseif (isset($_GET["GOTMLS_scan"])) {
            $file = GOTMLS_decode($_GET["GOTMLS_scan"]);
            if (is_dir($file)) {
                @error_reporting(0);
                @header("Content-type: text/javascript");
                if (isset($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"]) && is_array($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"])) {
                    $GLOBALS["GOTMLS"]["tmp"]["skip_ext"] = $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["exclude_ext"];
                }
                @ob_start();
                echo GOTMLS_scandir($file);
                if (@ob_get_level()) {
                    GOTMLS_flush();
                    @ob_end_flush();
                }
                die('//END OF JavaScript');
            } else {
                if (!file_exists($file)) {
                    die(sprintf(__("The file %s does not exist.", 'gotmls'), $file) . "<br />\n" . (file_exists(GOTMLS_quarantine($file)) ? sprintf(__("You could <a %s>try viewing the quarantined backup file</a>.", 'gotmls'), 'target="GOTMLS_iFrame" href="' . GOTMLS_script_URI . '&GOTMLS_scan=' . GOTMLS_encode(GOTMLS_quarantine($file)) . '"') : __("The file must have already been delete.", 'gotmls')) . "<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\n</script>");
                } else {
                    $clean_file = $file;
                    if (GOTMLS_get_ext($file) == 'gotmls' && dirname($file) == dirname(GOTMLS_quarantine($file))) {
                        $clean_file = 'Quarantined: ' . GOTMLS_decode(array_pop(explode(".", '.' . substr($file, strlen(dirname($file)) + 1, -7))));
                        $_GET["eli"] = "quarantine";
                    }
                    GOTMLS_scanfile($file);
                    $fa = "";
                    $function = 'GOTMLS_decode';
                    $decode_list = array("Base64" => '/base64_decode\\([\'"]([0-9\\+\\/\\=a-z]+)[\'"]\\)/', "Hex" => '/(\\\\x[0-9a-f]{2})/');
                    if (isset($_GET[$function]) && is_array($_GET[$function])) {
                        foreach ($_GET[$function] as $decode) {
                            if (isset($decode_list[$decode])) {
                                $GOTMLS_file_contents = preg_replace($decode_list[$decode] . substr($GLOBALS["GOTMLS"]["tmp"]["default_ext"], 0, 2), $function . $decode . '("\\1")', $GOTMLS_file_contents);
                                $fa .= " {$decode} decoded";
                            } else {
                                $fa .= " NO-{$decode}";
                            }
                        }
                    } elseif (isset($GOTMLS_threats_found) && is_array($GOTMLS_threats_found) && count($GOTMLS_threats_found)) {
                        $f = 1;
                        foreach ($GOTMLS_threats_found as $threats_found => $threats_name) {
                            $fpos = 0;
                            $flen = 0;
                            $potential_threat = str_replace("\r", "", $threats_found);
                            while (($fpos = strpos(str_replace("\r", "", $GOTMLS_file_contents), $potential_threat, $flen + $fpos)) !== false) {
                                $flen = strlen($potential_threat);
                                $fa .= ' <a title="' . htmlspecialchars($threats_name) . '" href="javascript:select_text_range(\'ta_file\', ' . $fpos . ', ' . ($fpos + $flen) . ');">[' . $f++ . ']</a>';
                            }
                            if (0 == $flen) {
                                $fa = 'ERROR[' . $f++ . ']: Threat_size{' . strlen($potential_threat) . '} } Content_size{' . strlen(str_replace("\r", "", $GOTMLS_file_contents)) . '}';
                            }
                        }
                    } else {
                        $fa = " No Threats Found";
                    }
                    foreach ($decode_list as $decode => $regex) {
                        if (preg_match($regex . substr($GLOBALS["GOTMLS"]["tmp"]["default_ext"], 0, 1), $GOTMLS_file_contents)) {
                            $fa .= ' <a href="' . GOTMLS_script_URI . '&' . $function . '[]=' . $decode . '">decode[' . $decode . ']</a>';
                        }
                    }
                    die("\n" . '<script type="text/javascript">
	function select_text_range(ta_id, start, end) {
		ta_element = document.getElementById(ta_id);
		ta_element.focus();
		if(ta_element.setSelectionRange)
		   ta_element.setSelectionRange(start, end);
		else {
		   var r = ta_element.createTextRange();
		   r.collapse(true);
		   r.moveEnd(\'character\', end);
		   r.moveStart(\'character\', start);
		   r.select();   
		}
	}
	window.parent.showhide("GOTMLS_iFrame", true);
	</script><table style="top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;"><tr><td style="width: 100%"><form style="margin: 0;" method="post"' . (is_file($clean_file) ? ' onsubmit="return confirm(\'' . __("Are you sure this file is not infected and you want to ignore it in future scans?", 'gotmls') . '\');"><input type="hidden" name="GOTMLS_whitelist" value="' . GOTMLS_encode($clean_file) . '"><input type="hidden" name="GOTMLS_chksum" value="' . md5($GOTMLS_file_contents) . 'O' . GOTMLS_installation_key . '"><input type="submit" value="Whitelist this file" style="float: right;">' : (is_file(GOTMLS_quarantine($clean_file)) ? ' >' : '>')) . '</form><div id="fileperms" class="shadowed-box rounded-corners" style="display: none; position: absolute; left: 8px; top: 29px; background-color: #ccc; border: medium solid #C00; box-shadow: -3px 3px 3px #666; border-radius: 10px; padding: 10px;"><b>File Details</b><br />encoding: ' . mb_detect_encoding($GOTMLS_file_contents) . '<br />size: ' . strlen($GOTMLS_file_contents) . ' (' . filesize($file) . 'bytes)<br />permissions: ' . GOTMLS_fileperms($file) . '<br />modified:' . date(" Y-m-d H:i:s ", filemtime($file)) . '<br />changed:' . date(" Y-m-d H:i:s ", filectime($file)) . '</div><div style="overflow: auto;"><span onmouseover="document.getElementById(\'fileperms\').style.display=\'block\';" onmouseout="document.getElementById(\'fileperms\').style.display=\'none\';">' . __("Potential threats in file:", 'gotmls') . '</span> (' . $fa . ' )</div></td></tr><tr><td style="height: 100%"><textarea id="ta_file" style="width: 100%; height: 100%">' . htmlentities(str_replace("\r", "", $GOTMLS_file_contents)) . '</textarea></td></tr></table>');
                }
            }
        } elseif (isset($_REQUEST["GOTMLS_fix"]) && is_array($_REQUEST["GOTMLS_fix"]) && isset($_REQUEST["GOTMLS_fixing"]) && $_REQUEST["GOTMLS_fixing"]) {
            $callAlert = "clearTimeout(callAlert);\ncallAlert=setTimeout('alert_repaired(1)', 30000);";
            $li_js = "\n<script type=\"text/javascript\">\nvar callAlert;\nfunction alert_repaired(failed) {\nclearTimeout(callAlert);\nif (failed)\nfilesFailed='the rest, try again to change more.';\nwindow.parent.check_for_donation('Changed '+filesFixed+' files, failed to change '+filesFailed);\n}\n{$callAlert}\nwindow.parent.showhide('GOTMLS_iFrame', true);\nfilesFixed=0;\nfilesFailed=0;\nfunction fixedFile(file) {\n filesFixed++;\nwindow.parent.document.getElementById('list_'+file).className='GOTMLS_plugin';\nwindow.parent.document.getElementById('check_'+file).checked=false;\n }\nfunction DeletedFile(file) {\n filesFixed++;\nwindow.parent.document.getElementById('list_'+file).style.display='none';\nwindow.parent.document.getElementById('check_'+file).checked=false;\n }\nfunction failedFile(file) {\n filesFailed++;\nwindow.parent.document.getElementById('check_'+file).checked=false; \n}\n</script>\n<script type=\"text/javascript\">\n/*<!--*" . "/";
            @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time'] * 2);
            foreach ($_REQUEST["GOTMLS_fix"] as $clean_file) {
                $path = realpath(GOTMLS_decode($clean_file));
                if (is_file($path)) {
                    if ($_REQUEST["GOTMLS_fixing"] > 1) {
                        echo "<li>Deleting {$path} ... ";
                        if (GOTMLS_trailingslashit($GLOBALS["GOTMLS"]["tmp"]["quarantine_dir"]) == substr($path, 0, strlen(GOTMLS_trailingslashit($GLOBALS["GOTMLS"]["tmp"]["quarantine_dir"]))) && @unlink($path)) {
                            echo __("Deleted!", 'gotmls');
                            $li_js .= "/*-->*" . "/\nDeletedFile('{$clean_file}');\n/*<!--*" . "/";
                        } elseif (GOTMLS_trailingslashit($GLOBALS["GOTMLS"]["tmp"]["quarantine_dir"]) == substr($path, 0, strlen(GOTMLS_trailingslashit($GLOBALS["GOTMLS"]["tmp"]["quarantine_dir"]))) && is_file(dirname($path) . "/index.php") && ($GOTMLS_file_contents = @file_get_contents(dirname($path) . "/index.php")) && strlen($GOTMLS_file_contents) > 0 && GOTMLS_file_put_contents($path, $GOTMLS_file_contents) && (@rename($path, dirname($path) . "/index.php") || GOTMLS_file_put_contents($path, "") !== false)) {
                            echo __("Removed file contents!", 'gotmls');
                            $li_js .= "/*-->*" . "/\nfixedFile('{$clean_file}');\n/*<!--*" . "/";
                        } else {
                            echo __("Failed to delete!", 'gotmls');
                            $li_js .= "/*-->*" . "/\nfailedFile('{$clean_file}');\n/*<!--*" . "/";
                        }
                    } else {
                        echo "<li>Fixing {$path} ... ";
                        $li_js .= GOTMLS_scanfile($path);
                    }
                    echo "</li>\n{$li_js}/*-->*" . "/\n{$callAlert}\n</script>\n";
                    $li_js = "<script type=\"text/javascript\">\n/*<!--*" . "/";
                } else {
                    echo "<li>" . __("File " . htmlentities($path) . " not found!", 'gotmls') . "</li>";
                }
            }
            die('<div id="check_site_warning" style="background-color: #F00;">' . sprintf(__("Because some threats were automatically fixed we need to check to make sure the removal did not break your site. If this stays Red and the frame below does not load please <a %s>revert the changes</a> made during the automated fix process.", 'gotmls'), 'target="test_frame" href="admin.php?page=GOTMLS-View-Quarantine"') . ' <span style="color: #F00;">' . __("Never mind, it worked!", 'gotmls') . '</span></div><br /><iframe id="test_frame" name="test_frame" src="' . GOTMLS_script_URI . '&check_site=1" style="width: 100%; height: 200px"></iframe>' . $li_js . "/*-->*" . "/\nalert_repaired(0);\n</script>\n");
        } elseif (isset($_REQUEST["GOTMLS_fixing"])) {
            die("<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\nalert('" . __("Nothing Selected to be Changed!", 'gotmls') . "');\n</script>" . __("Done!", 'gotmls'));
        }
        if (isset($_POST["scan_level"]) && is_numeric($_POST["scan_level"])) {
            $scan_level = intval($_POST["scan_level"]);
        }
        if (isset($scan_level) && is_numeric($scan_level)) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"] = intval($scan_level);
        } else {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["scan_level"] = count(explode('/', trailingslashit(get_option("siteurl")))) - 1;
        }
        $GLOBALS["GOTMLS_msg"] = __("Default position", 'gotmls');
        $properties = array("body" => 'style="margin: 0; padding: 0;"');
        if (isset($_GET["GOTMLS_msg"]) && $_GET["GOTMLS_msg"] == $GLOBALS["GOTMLS_msg"]) {
            $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"] = $GLOBALS["GOTMLS"]["tmp"]["default"]["msg_position"];
            $gl = '><';
            $properties["html"] = $gl . 'head' . $gl . 'script type="text/javascript">
	if (curDiv = window.parent.document.getElementById("div_file")) {
		curDiv.style.left = "' . $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0] . '";
		curDiv.style.top = "' . $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1] . '";
		curDiv.style.height = "' . $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2] . '";
		curDiv.style.width = "' . $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3] . '";
	}
	</script' . $gl . '/head';
        } elseif (isset($_GET["GOTMLS_x"]) || isset($_GET["GOTMLS_y"]) || isset($_GET["GOTMLS_h"]) || isset($_GET["GOTMLS_w"])) {
            if (isset($_GET["GOTMLS_x"])) {
                $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][0] = $_GET["GOTMLS_x"];
            }
            if (isset($_GET["GOTMLS_y"])) {
                $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][1] = $_GET["GOTMLS_y"];
            }
            if (isset($_GET["GOTMLS_h"])) {
                $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][2] = $_GET["GOTMLS_h"];
            }
            if (isset($_GET["GOTMLS_w"])) {
                $GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"][3] = $_GET["GOTMLS_w"];
            }
            $_GET["GOTMLS_msg"] = __("New position", 'gotmls');
        }
        update_option("GOTMLS_settings_array", $GLOBALS["GOTMLS"]["tmp"]["settings_array"]);
        if (isset($_GET["GOTMLS_msg"])) {
            die(GOTMLS_html_tags(array("html" => array("body" => htmlentities($_GET["GOTMLS_msg"]) . ' ' . __("saved.", 'gotmls') . (implode($GLOBALS["GOTMLS"]["tmp"]["settings_array"]["msg_position"]) == implode($GLOBALS["GOTMLS"]["tmp"]["default"]["msg_position"]) ? "" : ' <a href="' . GOTMLS_script_URI . '&GOTMLS_msg=' . urlencode($GLOBALS["GOTMLS_msg"]) . '">[' . $GLOBALS["GOTMLS_msg"] . ']</a>'))), $properties));
        }
    }
}
Пример #2
0
function GOTMLS_readdir($dir, $current_depth = 1)
{
    global $GOTMLS_scanfiles, $GOTMLS_skip_dirs, $GOTMLS_dirs_at_depth, $GOTMLS_dir_at_depth, $GOTMLS_total_percent;
    if ($dir != $GLOBALS["GOTMLS"]["tmp"]["quarantine_dir"] || $current_depth == 1) {
        @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time']);
        $entries = GOTMLS_getfiles($dir);
        if (is_array($entries)) {
            echo GOTMLS_return_threat("dirs", "wait", $dir) . GOTMLS_update_status(sprintf(__("Preparing %s", 'gotmls'), str_replace(dirname($GLOBALS["GOTMLS"]["log"]["scan"]["dir"]), "...", $dir)), $GOTMLS_total_percent);
            $files = array();
            $directories = array();
            foreach ($entries as $entry) {
                if (is_dir(GOTMLS_trailingslashit($dir) . $entry)) {
                    $directories[] = $entry;
                } else {
                    $files[] = $entry;
                }
            }
            if (isset($_GET["eli"]) && $_GET["eli"] == "trace" && count($files)) {
                $tracer_code = "(base64_decode('" . base64_encode('if(isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] == "' . $_SERVER["REMOTE_ADDR"] . '" && is_file("' . GOTMLS_local_images_path . '../safe-load/trace.php")) {include_once("' . GOTMLS_local_images_path . '../safe-load/trace.php");GOTMLS_debug_trace(__FILE__);}') . "'));";
                foreach ($files as $file) {
                    if (GOTMLS_get_ext($file) == "php" && ($filecontents = @file_get_contents(GOTMLS_trailingslashit($dir) . $file))) {
                        GOTMLS_file_put_contents(GOTMLS_trailingslashit($dir) . $file, preg_replace('/^<\\?php(?! eval)/is', '<?php eval' . $tracer_code, $filecontents));
                    }
                }
            }
            if ($_REQUEST["scan_type"] == "Quick Scan") {
                $GOTMLS_dirs_at_depth[$current_depth] = count($directories);
                $GOTMLS_dir_at_depth[$current_depth] = 0;
            } else {
                $GOTMLS_scanfiles[GOTMLS_encode($dir)] = GOTMLS_strip4java(str_replace(dirname($GLOBALS["GOTMLS"]["log"]["scan"]["dir"]), "...", $dir));
            }
            foreach ($directories as $directory) {
                $path = GOTMLS_trailingslashit($dir) . $directory;
                if (isset($_REQUEST["scan_depth"]) && is_numeric($_REQUEST["scan_depth"]) && $_REQUEST["scan_depth"] != $current_depth && !in_array($directory, $GOTMLS_skip_dirs)) {
                    $current_depth++;
                    $current_depth = GOTMLS_readdir($path, $current_depth);
                } else {
                    echo GOTMLS_return_threat("skipdirs", "blocked", $path);
                    $GOTMLS_dir_at_depth[$current_depth]++;
                }
            }
            if ($_REQUEST["scan_type"] == "Quick Scan") {
                $echo = "";
                echo GOTMLS_update_status(sprintf(__("Scanning %s", 'gotmls'), str_replace(dirname($GLOBALS["GOTMLS"]["log"]["scan"]["dir"]), "...", $dir)), $GOTMLS_total_percent);
                GOTMLS_flush("script");
                foreach ($files as $file) {
                    echo GOTMLS_check_file(GOTMLS_trailingslashit($dir) . $file);
                }
                echo GOTMLS_return_threat("dir", "checked", $dir);
            }
        } else {
            echo GOTMLS_return_threat("errors", "blocked", $dir, GOTMLS_error_link(GOTMLS_Failed_to_list_LANGUAGE . ' readdir:' . ($entries === false ? '(' . GOTMLS_fileperms($dir) . ')' : $entries)));
        }
        @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time']);
        if ($current_depth-- && $_REQUEST["scan_type"] == "Quick Scan") {
            $GOTMLS_dir_at_depth[$current_depth]++;
            for ($GOTMLS_total_percent = 0, $depth = $current_depth; $depth >= 0; $depth--) {
                echo "\n//(({$GOTMLS_total_percent} / {$GOTMLS_dirs_at_depth[$depth]}) + ({$GOTMLS_dir_at_depth[$depth]} / {$GOTMLS_dirs_at_depth[$depth]})) = ";
                $GOTMLS_total_percent = ($GOTMLS_dirs_at_depth[$depth] ? $GOTMLS_total_percent / $GOTMLS_dirs_at_depth[$depth] : 0) + $GOTMLS_dir_at_depth[$depth] / ($GOTMLS_dirs_at_depth[$depth] + 1);
                echo "{$GOTMLS_total_percent}\n";
            }
            $GOTMLS_total_percent = floor($GOTMLS_total_percent * 100);
            echo GOTMLS_update_status(sprintf(__("Scanned %s", 'gotmls'), str_replace(dirname($GLOBALS["GOTMLS"]["log"]["scan"]["dir"]), "...", $dir)), $GOTMLS_total_percent);
        }
        GOTMLS_flush("script");
    }
    return $current_depth;
}
Пример #3
0
function GOTMLS_ajax_fix()
{
    if (GOTMLS_get_nonce()) {
        if (isset($_POST["GOTMLS_fix"]) && !is_array($_POST["GOTMLS_fix"])) {
            $_POST["GOTMLS_fix"] = array($_POST["GOTMLS_fix"]);
        }
        if (isset($_REQUEST["GOTMLS_fix"]) && is_array($_REQUEST["GOTMLS_fix"]) && isset($_REQUEST["GOTMLS_fixing"]) && $_REQUEST["GOTMLS_fixing"]) {
            GOTMLS_update_scan_log(array("settings" => $GLOBALS["GOTMLS"]["tmp"]["settings_array"]));
            $callAlert = "clearTimeout(callAlert);\ncallAlert=setTimeout('alert_repaired(1)', 30000);";
            $li_js = "\n<script type=\"text/javascript\">\nvar callAlert;\nfunction alert_repaired(failed) {\nclearTimeout(callAlert);\nif (failed)\nfilesFailed='the rest, try again to change more.';\nwindow.parent.check_for_donation('Changed '+filesFixed+' files, failed to change '+filesFailed);\n}\n{$callAlert}\nwindow.parent.showhide('GOTMLS_iFrame', true);\nfilesFixed=0;\nfilesFailed=0;\nfunction fixedFile(file) {\n filesFixed++;\nif (li_file = window.parent.document.getElementById('check_'+file))\n\tli_file.checked=false;\nif (li_file = window.parent.document.getElementById('list_'+file))\n\tli_file.className='GOTMLS_plugin';\nif (li_file = window.parent.document.getElementById('GOTMLS_quarantine_'+file)) {\n\tli_file.style.display='none';\n\tli_file.innerHTML='';\n\t}\n}\nfunction DeletedFile(file) {\n filesFixed++;\nif (li_file = window.parent.document.getElementById('check_'+file))\n\tli_file.checked=false;\nif (li_file = window.parent.document.getElementById('GOTMLS_quarantine_'+file)) {\n\tli_file.style.display='none';\n\tli_file.innerHTML='';\n\t}}\nfunction failedFile(file) {\n filesFailed++;\nwindow.parent.document.getElementById('check_'+file).checked=false; \n}\n</script>\n<script type=\"text/javascript\">\n/*<!--*" . "/";
            @set_time_limit($GLOBALS["GOTMLS"]["tmp"]['execution_time'] * 2);
            $HTML = explode("split-here-for-content", GOTMLS_html_tags(array("html" => array("body" => "split-here-for-content"))));
            echo $HTML[0];
            GOTMLS_update_scan_log(array("scan" => array("dir" => count($_REQUEST["GOTMLS_fix"]) . " Files", "start" => time())));
            foreach ($_REQUEST["GOTMLS_fix"] as $clean_file) {
                if (is_numeric($clean_file)) {
                    if (($Q_post = GOTMLS_get_quarantine($clean_file)) && isset($Q_post["post_type"]) && strtolower($Q_post["post_type"]) == "gotmls_quarantine" && isset($Q_post["post_status"]) && strtolower($Q_post["post_status"]) == "private") {
                        $path = $Q_post["post_title"];
                        if ($_REQUEST["GOTMLS_fixing"] > 1) {
                            echo "<li>Removing {$path} ... ";
                            $Q_post["post_status"] = "trash";
                            if (wp_update_post($Q_post)) {
                                echo __("Done!", 'gotmls');
                                $li_js .= "/*-->*" . "/\nDeletedFile('{$clean_file}');\n/*<!--*" . "/";
                            } else {
                                echo __("Failed to delete!", 'gotmls');
                                $li_js .= "/*-->*" . "/\nfailedFile('{$clean_file}');\n/*<!--*" . "/";
                            }
                            GOTMLS_update_scan_log(array("scan" => array("finish" => time(), "type" => "Removal from Quarantine")));
                        } else {
                            echo "<li>Restoring {$path} ... ";
                            $Q_post["post_status"] = "pending";
                            if (GOTMLS_file_put_contents($path, GOTMLS_decode($Q_post["post_content"])) && wp_update_post($Q_post)) {
                                echo __("Complete!", 'gotmls');
                                $li_js .= "/*-->*" . "/\nfixedFile('{$clean_file}');\n/*<!--*" . "/";
                            } else {
                                echo __("Restore Failed!", 'gotmls');
                                $li_js .= "/*-->*" . "/\nfailedFile('{$clean_file}');\n/*<!--*" . "/";
                            }
                            GOTMLS_update_scan_log(array("scan" => array("finish" => time(), "type" => "Restoration from Quarantine")));
                        }
                        echo "</li>\n{$li_js}/*-->*" . "/\n{$callAlert}\n</script>\n";
                        $li_js = "<script type=\"text/javascript\">\n/*<!--*" . "/";
                    }
                    //else print_r(array("i:$clean_file"=>$Q_post));
                } else {
                    $path = realpath(GOTMLS_decode($clean_file));
                    if (is_file($path)) {
                        echo "<li>Fixing {$path} ... ";
                        $li_js .= GOTMLS_scanfile($path);
                        echo "</li>\n{$li_js}/*-->*" . "/\n{$callAlert}\n</script>\n";
                        $li_js = "<script type=\"text/javascript\">\n/*<!--*" . "/";
                    } else {
                        echo "<li>" . __("File " . htmlentities($path) . " not found!", 'gotmls') . "</li>";
                    }
                    GOTMLS_update_scan_log(array("scan" => array("finish" => time(), "type" => "Automatic Fix")));
                }
            }
            die('<div id="check_site_warning" style="background-color: #F00;">' . sprintf(__("Because some changes were made we need to check to make sure it did not break your site. If this stays Red and the frame below does not load please <a %s>revert the changes</a> made during this automated fix process.", 'gotmls'), 'target="_top" href="admin.php?page=GOTMLS-View-Quarantine"') . ' <span style="color: #F00;">' . __("Never mind, it worked!", 'gotmls') . '</span></div><br /><iframe id="test_frame" name="test_frame" src="' . admin_url('admin.php?page=GOTMLS-settings&check_site=1&' . GOTMLS_set_nonce(__FUNCTION__ . "1451")) . '" style="width: 100%; height: 200px"></iframe>' . $li_js . "/*-->*" . "/\nalert_repaired(0);\n</script>\n{$HTML['1']}");
        } else {
            die(GOTMLS_html_tags(array("html" => array("body" => "<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\nalert('" . __("Nothing Selected to be Changed!", 'gotmls') . "');\n</script>" . __("Done!", 'gotmls')))));
        }
    } else {
        die(GOTMLS_html_tags(array("html" => array("body" => "<script type=\"text/javascript\">\nwindow.parent.showhide('GOTMLS_iFrame', true);\nalert('" . GOTMLS_Invalid_Nonce("") . "');\n</script>" . __("Done!", 'gotmls')))));
    }
}