Skip to main content

Posts

Showing posts with the label php

Protect your Blog from malicious URL requests in WordPress

Due to popularity of WordPress, it's often the target of hackers. Today we are going to build a plugin that will check for malicious URL requests and use it to protect our Blog. Paste the following code into a text file, and save it as blockbadqueries.php. Once done, upload it to your up-content/plugins directory and activate it like any other plugins. That's all! <?php /* Plugin Name: Block Bad Queries Description: Protect WordPress Against Malicious URL Requests */ global $user_ID; if($user_ID) { if(!current_user_can('level_10')) { if (strlen($_SERVER['REQUEST_URI']) > 255 || strpos($_SERVER['REQUEST_URI'], "eval(") || strpos($_SERVER['REQUEST_URI'], "CONCAT") || strpos($_SERVER['REQUEST_URI'], "UNION+SELECT") || strpos($_SERVER['REQUEST_URI'], "base64")) { @header("HTTP/1.1 414 Request-URI Too Long"); @header("Status: 414 Reques...