危险函数
mixed eval (string $code) 把字符串做为PHP代码执行
bool assert (mixed $assertion [,string $description]) 替代eval函数。相同功能。
mixed preg_replace(mixed $pattern,mixed $replacement,mixed $subject[,int $limit=-1 [,int&$count]])
/e修正符使preg_replace()将replacement参数看成PHP代码
preg_replace("/test/e",$_GET["V"],"jutst test");
提交?h=phpinfo(),phpinfo()将会被执行
string create_function(string $args,string $code)
建立一个匿名函数,并返回独一无二的函数名
$newfunc = create_funciton('$v','return system($v);')
$newfunc('whoami');就至关于system('whoami')
call_user_func(callable $callback [,mixed $parameter [,mixed $....]])
第一个参数callback 是被调用的回调函数,其他参数是回调函数的参数
function test($var){echo "callable test $var";}
call_user_func('system','whoami')
call_user_func_array(callable $callback,array $param_arr)
把第一个参数做为回调函数(callback)调用,把参数数组做(param_arr)为回调函数的参数传入
复制代码
包含函数
include $file;
变量$file 可控的状况下咱们就能够包含任意文件。从而getshell目的
另外再不一样的配置环境,能够包含不一样的文件,所以分为远程文件包含和本地文件包含。
包含函数能够读取任意文件内容,这就须要用到【支持的协议和封装的协议】以及【过滤器】
include($_GET['file']);
?file=php://file/convert.base64-encode/resource=index.php
file是协议 convert.base64-encode 是过滤器
include_once
require
require_once
复制代码
命令执行函数
exec():执行一个外部程序
passthru():执行外部程序而且显示原始输出
proc_open() :执行一个命令,而且打开用来输入/输出的文件指针
shell_exec():经过shell环境,而且将完整的输出以字符串方式返回
system():执行外部程序,而且返回输出
popen():经过popen()参数传递一条命令,并对popen()所打开的文件进行执行。
复制代码
文件操做函数
copy : 拷贝文件
file_get_contents:将整个文件读入为一个字符串
file_put_contents:将字符串写入文件
file:把整个文件读入一个数组中
fopen:打开文件或者url
move_uploaded_file:将上传的文件移动到新位置
readfile:输出文件
rename:重命名一个文件或目录
rmdir:删除目录
unlink&delete :删除文件
复制代码
特殊函数
信息泄露
bool phpinfo([int $what = INFO_ALL]):输出php当前状态的大量信息包含启用的扩展php版本服务器信息
软连接-读取文件内容(liunx)
bool symlink(string $target ,string $link)
symlink()对于已有的target 创建一个名为link的符号连接
string readlink(string $path)
readlink()和同名的C函数作一样的事情,返回符号链接的内容
环境变量
string getenv(string $varname)
获取一个环境变量的值
bool putenv(string $setting)
添加setting 到服务器环境变量。环境变量仅存活与当前请求期间,再请求结束时恢复初始状态
加载扩展
bool dl(string $library)
载入指定参数library的php扩展
配置相关
string ini_get():成功时返回配置选项的值
string ini_set():设置指定配置选项的值,这个选项会在脚本运行时保持新的值,而且脚本结束恢复
string ini_alter:同上
string ini_restore:恢复指定配置选项到它的原始值
数字判断
bool is_numeric(mixed $var)
若是var时数字和数字字符串则返回TRUE,不然返回FALSE
*仅用is_numeric判断而不用intval转换有可能插入16进制字符串到数据库,进而可能致使sql二次注入
数组相关
bool in_array($needle,array $haystack[,bool $strict=FALSE]):该函数比较会自动进行类型转换
$a='1abc'
inarray($a,array(1,2,3))返回为真
复制代码