A suspicious PHP file might

耗尽温柔 提交于 2019-12-04 22:58:29

Let's start from the begining.

  • eregi is a deprecated function as of PHP 5.3.0.
  • eregi is a case insensitive regular expression.

So, what's it doing?

if (eregi("final",$_SERVER['HTTP_USER_AGENT'])) {

If final is in the HTTP_USER_AGENT, then....

Replace 'Mozilla/5.0 (3.1.final) ' with [blank] in the HTTP_USER_AGENT. And kill the script.

Conclusion

It's ineffective in terms of altering data on your site, but will render your site "dead" to anybody with the word final in their user agent - which, I think, will be all final version released of every major browser; although I cannot find any source on this.

Edit

The eval got me wondering. Since it's evident you didn't put it here, eval will evaluate code and execute it - which is a concern of an attack. The only way for somebody to get remote code to execute on your site is to "spoof" their user agent ensuring they have the phrase Mozilla/5.0 (3.1.final) in there followed by all the code they want executing. For example;

I spoof my user agent to become

Mozilla/5.0 (3.1.final)  echo 'Lol, you got hacked'

Because of the str_replace, the screen will just render the words Lol, you got hacked because eval will execute the echo. Of course, an attacker will put much more harmful commands to be evaluated. Remove this code immediately

Yes, it's a simple eval backdoor, installed so that someone can come back at any time later and use your server for anything nefarious that they want to.

It accepts a user agent string starting with Mozilla/5.0 (3.1.final) (which is not a real user agent string), and treats the rest of the string as PHP code, which is executed via the eval call.

(The strange part is that they used the user agent for this, since that field is routinely logged in standard web logs. Using a POST field or cookie would be much more covert.)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!