PHP代码执行漏洞参考资料总结
一 代码执行函数
PHP中可以执行代码的函数。如eval()、assert()、``、system()、exec()、shell_exec()、passthru()、 escapeshellcmd()、pcntl_exec() 等
demo code 1.1:
二 文件包含代码注射
文件包含函数在特定条件下的代码注射,如include()、include_once()、 require()、require_once()。
当allow_url_include=On ,PHP Version>=5.2.0 时,导致代码注射。
demo code 2.1:
访问http://127.0.0.1/include.php?a=data:text/plain,%3C?php%20phpinfo%28%29;?%3E 即
执行phpinfo()。
三 正则匹配代码注射
众所周知的preg_replace()函数导致的代码注射。当pattern中存在/e模式修饰符,即允许执行代码。这里我们分三种情况讨论下
3.1 preg_replace() pattern 参数注射
pattern即第一个参数的代码注射。
当magic_quotes_gpc=Off时,导致代码执行。
demo code 3.1:
访问http://127.0.0.1/preg_replace1.php?reg=%3C\/php%3E/e 即
执行phpinfo()。
3.2 preg_replace() replacement参数注射
replacement即第二个参数的代码注射,导致代码执行。
demo code 3.2:
当我们提交 http://127.0.0.1/preg_replace2.php?h=phpinfo() 即
执行phpinfo()。
3.3 preg_replace()第三个参数注射
我们通过构造subject参数执行代码。提交:http://127.0.0.1/preg_replace3.php?h=
phpinfo()
或者 http://127.0.0.1/preg_replace3.php?h=
${phpinfo%28%29}
导致代码执行
demo code 3.3:
四 动态代码执行
4.1 动态变量代码执行
demo code 4.1:
我们提交 http://127.0.0.1/dyn_func.php?dyn_func=system&argument=ipconfig 执行ipconfig命令
4.2 动态函数代码执行
demo code 4.2:
我们提交 http://127.0.0.1/create_function.php?foobar=system%28dir%29 执行dir命令
五 其他
5.1 ob_start()函数的代码执行
demo code 5.1:
5.2 array_map()函数的代码执行
demo code 5.2:
我们提交 http://127.0.0.1/array_map.php?callback=phpinfo 即执行phpinfo()。
5.3 unserialize()与eval()
unserialize()是PHP中使用率非常高的函数。不正当使用unserialize()容易导致安全隐患。
我们提交 http://127.0.0.1/unserialize.php?saved_code=O:7:%22Example%22:1:{s:3:%22var%22;s:10:%22phpinfo%28%29;%22;} 即执行phpinfo()。
5.4 容易导致安全问题的函数
同类型函数还有很多
array_map()
usort(), uasort(), uksort()
array_filter()
array_reduce()
array_diff_uassoc(), array_diff_ukey()
array_udiff(), array_udiff_assoc(), array_udiff_uassoc()
array_intersect_assoc(), array_intersect_uassoc()
array_uintersect(), array_uintersect_assoc(), array_uintersect_uassoc()
array_walk(), array_walk_recursive()
xml_set_character_data_handler()
xml_set_default_handler()
xml_set_element_handler()
xml_set_end_namespace_decl_handler()
xml_set_external_entity_ref_handler()
xml_set_notation_decl_handler()
xml_set_processing_instruction_handler()
xml_set_start_namespace_decl_handler()
xml_set_unparsed_entity_decl_handler()
stream_filter_register()
set_error_handler()
register_shutdown_function()
register_tick_function()

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제









이번 장에서는 CakePHP의 환경 변수, 일반 구성, 데이터베이스 구성, 이메일 구성에 대해 알아봅니다.

PHP 8.4는 상당한 양의 기능 중단 및 제거를 통해 몇 가지 새로운 기능, 보안 개선 및 성능 개선을 제공합니다. 이 가이드에서는 Ubuntu, Debian 또는 해당 파생 제품에서 PHP 8.4를 설치하거나 PHP 8.4로 업그레이드하는 방법을 설명합니다.

CakePHP에서 데이터베이스 작업은 매우 쉽습니다. 이번 장에서는 CRUD(생성, 읽기, 업데이트, 삭제) 작업을 이해하겠습니다.

CakePHP는 PHP용 오픈 소스 프레임워크입니다. 이는 애플리케이션을 훨씬 쉽게 개발, 배포 및 유지 관리할 수 있도록 하기 위한 것입니다. CakePHP는 강력하고 이해하기 쉬운 MVC와 유사한 아키텍처를 기반으로 합니다. 모델, 뷰 및 컨트롤러 gu
