当前位置:网站首页>Command execution (RCE) vulnerability
Command execution (RCE) vulnerability
2022-06-29 19:58:00 【The way to remedy】
RCE brief introduction
RCE(remote command/code execute): Remote command / Code execution .
Command Execution Vulnerability : Call operating system commands directly .
Code Execution Vulnerability : Call operating system commands by executing script code .
reason : stay Web In application, sometimes programmers consider flexibility 、 Conciseness , It will call the code or command execution function in the code to deal with . For example, when an application is invoking something that can character string When converting functions into code , It doesn't consider whether the user can control this string , Will cause Code Execution Vulnerability . Also call the system command processing , Will create a command execution vulnerability .
principle
The attacker is in a position where he can execute system commands , Enter malicious system commands , The server does not strictly filter the execution functions , Cause the server to execute the malicious system command , Thus, it poses a security threat to the server .
The difference between command execution and code execution : Command execution vulnerability is the direct invocation of operating system commands , The Code Execution Vulnerability relies on executing script code to call operating system commands .
Command execution
System commands execute functions
System():system Function can be used to execute an external application and output the corresponding execution result , The function prototype is as follows : system(command,return_var) among ,command It's an order to execute ,return_var Store the status value of the executed command .
Exec():exec Functions can be used to execute an external application exec (command, output, return_var) among ,command It's an order to execute ,output Is to get the execution command output of each line of string ,return_var Store the status value after executing the command .
Passthru():passthru Function can be used to execute a UNIX The system commands and displays the original output , When UNIX The output of the system command is binary data , And need to return the value directly to the browser , Need to use passthru Function to replace system And exec function .Passthru The function prototype is as follows :passthru (command, return_var)
among ,command It's an order to execute ,return_var Store the status value after executing the command .
Shell_exec(): perform shell Command and return the output string , The function prototype is as follows : shell_exec (command) among ,command It's an order to execute .popen() proc_open() pcntl_exec()
Pipe,
Window series
" | ": Execute the following statements directly . for example :ping 127.0.0.1 | whoami.
“ || ”: If the previously executed statement fails to execute , Then execute the following statement , The preceding statement can only be false . for example :ping 127.0.0.1 || whoami
" & " : If the previous statement is false, execute the following statement directly , The preceding sentence is true or false . for example : ping 127.0.0.1 &whoami.
“ && ”: If the previous statement is false, an error will occur , Do not execute the following statements , The previous statement can only be true . for example :ping 127.0.0.1 && whoami.
Linux System
“;” After executing the previous statement, execute the following . for example : ping 127.0.0.1;whoami
“ | ”: Display the execution results of the following statements . for example : ping 127.0.0.1 | whoami.
“ || ”: When the previous statement fails to execute , Execute the following statement . for example : ping 1|| whoami.
“ & ”: If the previous statement is false, the following statement will be executed directly . The preceding sentence is true or false . for example :ping 127.0.0.1 & whoami.
“ && ”: If the previous statement is false, an error will occur , And don't do the following , The previous statement can only be true . for example : ping 127.0.0.1 && whoami.
Code execution
Script code execution function
eval(): Follow the string as PHP Code to execute . If it is not invoked in the code string return sentence , Then return to NULL. If there are parsing errors in the code , be eval() The function returns false.
assert(): Normal call
preg_replace() : Regularize a string
call_user_func() array_map()
defense
Try to use quotation marks for parameter values
Use as few functions as possible to execute commands or disable them directly
Before using dynamic functions , Make sure that the function used is one of the specified functions
Entering the function to execute the command / Before method , Filter the parameters , Escape sensitive characters
Work that can be solved with scripts , Don't call other programs to handle . Use as few functions as possible to execute commands , And in disable_functions disable .
边栏推荐
- As the "only" privacy computing provider, insight technology is the "first" to settle in the Yangtze River Delta data element circulation service platform
- 自动获取本地连接及网络地址修改
- 一个mysql里有3306端口下,一个mysql有20多个数据库,怎么一键备份20多个数据库,做系统备份,防止数据误删除?
- 剑指 Offer 59 - II. 队列的最大值
- 剑指 Offer 59 - I. 滑动窗口的最大值
- Several policies of Shenzhen Futian District to support investment attraction in 2022
- Sophomore majoring in software engineering, the previous learning situation is not very good. How to plan the follow-up development route
- A keepalived high availability accident made me learn it again!
- There are more than 20 databases in a MySQL with 3306 ports. How can I backup more than 20 databases with one click and do system backup to prevent data from being deleted by mistake?
- Zotero journal automatic matching update influence factor
猜你喜欢

如何设置 Pod 到指定节点运行

Flume theory

4-1 port scanning technology

A keepalived high availability accident made me learn it again!

Connaissance générale des paramètres de sécurité du serveur Cloud

ETCD数据库源码分析——服务端PUT流程

lock4j--分布式锁中间件--自定义获取锁失败的逻辑

Koa source code analysis

【Try to Hack】vulnhub narak
![[boutique] detailed explanation of Pinia](/img/94/d332e32dba54be3c2d3f6ff08a85fa.png)
[boutique] detailed explanation of Pinia
随机推荐
雪花id,分布式唯一id
通过MeterSphere和DataEase实现项目Bug处理进展实时跟进
Etcd database source code analysis - put process of server
Dynamics crm: among locally deployed servers, sandbox, unzip, VSS, asynchronous and monitor services
【Try to Hack】vulnhub narak
freemarker模板框架生成图片
童年经典蓝精灵之百变蓝爸爸数字藏品中奖名单公布
XSS漏洞
Go: how to write a correct UDP server
Kdd 2022 | prise en compte de l'alignement et de l'uniformité des représentations dans le Filtrage collaboratif
1404萬!四川省人社廳關系型數據庫及中間件軟件系統昇級采購招標!
CorelDRAW最新24.1.0.360版本更新介绍讲解
PHP implementation extracts non repeated integers (programming topics can be the fastest familiar functions)
一个超赞的开源的图片去水印解决方案
[fishing artifact] code tool for lowering the seconds of UI Library -- form part (I) design
关于印发宝安区重点产业项目和总部项目遴选及用地保障实施细则(2022修订版)的通知
2022年深圳市福田区支持先进制造业发展若干措施
Introduction to the latest version 24.1.0.360 update of CorelDRAW
Flume配置4——自定义Source+Sink
Startservice() procedure