# Can I see what this code is doing? (suspicious code found on one of my servers)

**URL:** <https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496>\
**Category:** Factual Questions\
**Created:** [May 2, 2014, 11:30am UTC](https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496 "2014-05-02T11:30:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [May 2, 2014, 11:30am UTC](https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496/1 "2014-05-02T11:30:50Z")

</div>

The code starts with an echo, of an eval (evaluate php code?) of a base64\_decode( and then a bunch of str\_replaces… and then thousands upon thousands of characters.

```auto

echo eval(base64_decode(str_replace('*','a',str_replace('%','B',str_replace('~','F',str_replace('_','z',str_replace('$','x',str_replace('@','d',str_replace('^','3',....... 

```

If I want to ‘decode’ this code safely so that I can see what it would do, can I run the php file without the ‘eval’ bit? …

```auto

echo base64_decode(str_replace('*','a',str_replace('%','B',str_replace('~','F',str_replace('_','z',str_replace('$','x',str_replace('@','d',str_replace('^','3',....... 

```

---

<div class="post-metadata">

**Author:** ![SpaceDog](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/spacedog/32/9932_2.png) [@SpaceDog](https://boards.straightdope.com/u/SpaceDog)\
**Post date:** [May 2, 2014, 11:42am UTC](https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496/2 "2014-05-02T11:42:08Z")

</div>

Yes, you can, as long as it’s just base64\_decodes and str\_replaces.

If you want to be extra safe copy/paste the code (without eval) into [Teh Playground](http://www.tehplayground.com/) and run it there.

And yes, that does look suspicious, Google just ‘eval(base64\_decode(str\_replace’ and you’ll see what I mean, some links:

[Site hacked | WordPress.org](http://wordpress.org/support/topic/site-hacked-24)  
(which links to) [javascript - Got Hacked - Anyone know what this PHP Code Does? - Stack Overflow](http://stackoverflow.com/questions/8068871/got-hacked-anyone-know-what-this-php-code-does/8079131#8079131)

---

<div class="post-metadata">

**Author:** ![Isilder](https://avatars.discourse-cdn.com/v4/letter/i/cc9497/32.png) [@Isilder](https://boards.straightdope.com/u/Isilder)\
**Post date:** [May 2, 2014, 2:10pm UTC](https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496/3 "2014-05-02T14:10:45Z")

</div>

The reason for the encoding and string replacing is to bypass antivirus… This works as every transmit can have a new “key” and hence the payload is a new payload… the antivirus doesn’t have a signature to pick out !

So clearly … its a virus/worm thingy !

---

<div class="post-metadata">

**Author:** ![Learjeff](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Learjeff](https://boards.straightdope.com/u/Learjeff)\
**Post date:** [May 2, 2014, 3:28pm UTC](https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496/4 "2014-05-02T15:28:07Z")

</div>

Just in case anyone wants to see the code without scrolling:

> [@Lobsang](#):
>
> ```auto
> 
> echo eval(
> base64_decode(
> str_replace('*','a',
> str_replace('%','B',
> str_replace('~','F',
> str_replace('_','z',
> str_replace('$','x',
> str_replace('@','d',
> str_replace('^','3',....... 
> 
> ```

Unfortunately, it’s the bit at the right end we’d really want to see (after seeing a bit of the beginning).

---

<div class="post-metadata">

**Author:** ![Nanoda](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@Nanoda](https://boards.straightdope.com/u/Nanoda)\
**Post date:** [May 3, 2014, 5:58am UTC](https://boards.straightdope.com/t/can-i-see-what-this-code-is-doing-suspicious-code-found-on-one-of-my-servers/687496/5 "2014-05-03T05:58:24Z")

</div>

> [@Learjeff](#):
>
> Unfortunately, it’s the bit at the right end we’d really want to see (after seeing a bit of the beginning).

Looks like it’s [this thing](https://stackoverflow.com/questions/23265194/what-does-this-malicious-php-do). Seems pretty comprehensive - does pretty much everything. The last hack I had to clean up (from a client’s server previously “managed” by someone else) just slapped a fake Flash upgrade page in /var/www.
