栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

可利用的PHP函数

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

可利用的PHP函数

为了建立此列表,我使用了2个来源。猩红与RATS研究。我还添加了一些我自己的东西,这个线程上的人也提供了帮助。

编辑: 发布此列表后,我联系了RIPS的创建者,到目前为止,此工具会搜索PHP代码以使用此列表中的每个函数。

这些函数调用大多数都归为接收器。将受污染的变量(如$_REQUEST)传递给接收器函数时,您将遇到漏洞。像RATS和RIPS这样的程序使用类似grep的功能来识别应用程序中的所有接收器。这意味着程序员在使用这些功能时应格外小心,但是如果所有功能都被禁止,那么您将无法完成很多工作。

强大的力量带来巨大的责任。

-斯坦·李

命令执行

exec- Returns last line of commands outputpassthru       - Passes commands output directly to the browsersystem         - Passes commands output directly to the browser and returns last lineshell_exec     - Returns commands output`` (backticks) - Same as shell_exec()popen          - Opens read or write pipe to process of a commandproc_open      - Similar to popen() but greater degree of controlpcntl_exec     - Executes a program

PHP代码执行

除了

eval
还有其他执行PHP代码的方法:
include
/
require
可以以本地文件包含和远程文件包含漏洞的形式用于远程代码执行。

eval()assert()  - identical to eval()preg_replace('/.*/e',...) - /e does an eval() on the matchcreate_function()include()include_once()require()require_once()$_GET['func_name']($_GET['argument']);$func = new ReflectionFunction($_GET['func_name']); $func->invoke(); or $func->invokeArgs(array());

接受回调的函数列表

这些函数接受一个字符串参数,该参数可用于调用攻击者选择的函数。根据功能的不同,攻击者可能会或可能不会传递参数。在那种情况下,可以使用

InformationDisclosure
类似的功能
phpinfo()

Function          => Position of callback arguments'ob_start'        =>  0,'array_diff_uassoc'          => -1,'array_diff_ukey' => -1,'array_filter'    =>  1,'array_intersect_uassoc'     => -1,'array_intersect_ukey'       => -1,'array_map'       =>  0,'array_reduce'    =>  1,'array_udiff_assoc'          => -1,'array_udiff_uassoc'         => array(-1, -2),'array_udiff'     => -1,'array_uintersect_assoc'     => -1,'array_uintersect_uassoc'    => array(-1, -2),'array_uintersect'=> -1,'array_walk_recursive'       =>  1,'array_walk'      =>  1,'assert_options'  =>  1,'uasort'          =>  1,'uksort'          =>  1,'usort'=>  1,'preg_replace_callback'      =>  1,'spl_autoload_register'      =>  0,'iterator_apply'  =>  1,'call_user_func'  =>  0,'call_user_func_array'       =>  0,'register_shutdown_function' =>  0,'register_tick_function'     =>  0,'set_error_handler'          =>  0,'set_exception_handler'      =>  0,'session_set_save_handler'   => array(0, 1, 2, 3, 4, 5),'sqlite_create_aggregate'    => array(2, 3),'sqlite_create_function'     =>  2,

信息披露

这些函数调用大多数都不是接收器。但是,如果攻击者可以查看返回的任何数据,则可能是一个漏洞。如果攻击者可以看到

phpinfo()
,则绝对是漏洞。

phpinfoposix_mkfifoposix_getloginposix_ttynamegetenvget_current_userproc_get_statusget_cfg_vardisk_free_spacedisk_total_spacediskfreespacegetcwdgetlastmogetmygidgetmyinodegetmypidgetmyuid

其他

extract - Opens the door for register_globals attacks (see study in scarlet).parse_str -  works like extract if only one argument is given.  putenvini_setmail - has CRLF injection in the 3rd parameter, opens the door for spam. header - on old systems CRLF injection could be used for xss or other purposes, now it is still a problem if they do a header("location: ..."); and they do not die();. The script keeps executing after a call to header(), and will still print output normally. This is nasty if you are trying to protect an administrative area. proc_niceproc_terminateproc_closepfsockopenfsockopenapache_child_terminateposix_killposix_mkfifoposix_setpgidposix_setsidposix_setuid

文件系统功能

根据RATS,php中的所有文件系统功能都很讨厌。其中一些对于攻击者似乎不太有用。其他的则比您想象的有用。例如,如果

allow_url_fopen=On
将URL用作文件路径,
copy($_GET['s'],$_GET['d']);
则可以使用对的调用将PHP脚本上载到系统中的任何位置。同样,如果站点容易受到通过GET发送的请求的影响,那么这些文件系统功能中的每个功能都可能被滥用来通过服务器引导和攻击另一台主机。

// open filesystem handlerfopentmpfilebzopengzopenSplFileObject->__construct// write to filesystem (partially in combination with reading)chgrpchmodchowncopyfile_put_contentslchgrplchownlinkmkdirmove_uploaded_filerenamermdirsymlinktempnamtouchunlinkimagepng   - 2nd parameter is a path.imagewbmp  - 2nd parameter is a path. image2wbmp - 2nd parameter is a path. imagejpeg  - 2nd parameter is a path.imagexbm   - 2nd parameter is a path.imagegif   - 2nd parameter is a path.imagegd    - 2nd parameter is a path.imagegd2   - 2nd parameter is a path.iptcembedftp_getftp_nb_get// read from filesystemfile_existsfile_get_contentsfilefileatimefilectimefilegroupfileinodefilemtimefileownerfilepermsfilesizefiletypeglobis_diris_executableis_fileis_linkis_readableis_uploaded_fileis_writableis_writeablelinkinfolstatparse_ini_filepathinforeadfilereadlinkrealpathstatgzfilereadgzfilegetimagesizeimagecreatefromgifimagecreatefromjpegimagecreatefrompngimagecreatefromwbmpimagecreatefromxbmimagecreatefromxpmftp_putftp_nb_putexif_read_dataread_exif_dataexif_thumbnailexif_imagetypehash_filehash_hmac_filehash_update_filemd5_filesha1_filehighlight_fileshow_sourcephp_strip_whitespaceget_meta_tags


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/405429.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号