bWAPP----OS Command Injection
OS Command Injection
界面:

给一个域名,它帮你返回DNS
代码:
1 <div id="main">
2
3 <h1>OS Command Injection</h1>
4
5 <form action="<?php echo($_SERVER["SCRIPT_NAME"]);?>" method="POST">
6
7 <p>
8
9 <label for="target">DNS lookup:</label>
10 <input type="text" id="target" name="target" value="www.nsa.gov">
11
12 <button type="submit" name="form" value="submit">Lookup</button>
13
14 </p>
15
16 </form>
17 <?php
18
19 if(isset($_POST["target"])) //获取域名,如果存在输入
20 {
21
22 $target = $_POST["target"];
23
24 if($target == "") //如果域名为空
25 {
26
27 echo "<font color=\"red\">Enter a domain name...</font>"; //请输入域名
28
29 }
30
31 else
32 {
33
34 echo "<p align=\"left\">" . shell_exec("nslookup " . commandi($target)) . "</p>";
35
36 }
37
38 }
39
40 ?>
41
42 </div>
shell_exec — 通过 shell 环境执行命令,并且将完整的输出以字符串的方式返回。
防御部分
1 function commandi($data)
2 {
3
4 switch($_COOKIE["security_level"])
5 {
6
7 case "0" :
8
9 $data = no_check($data);
10 break;
11
12 case "1" :
13
14 $data = commandi_check_1($data);
15 break;
16
17 case "2" :
18
19 $data = commandi_check_2($data);
20 break;
21
22 default :
23
24 $data = no_check($data);
25 break;
26
27 }
28
29 return $data;
30
31 }
32
33 ?>
1.low
low级别没有过滤
加一个;就能实现恶意


2.medium
1 function commandi_check_1($data)
2 {
3
4 $input = str_replace("&", "", $data);
5 $input = str_replace(";", "", $input);
6
7 return $input;
8
9 }
过滤了&和;将他们替换为空
用 | 可以绕过

3.high
1 function commandi_check_2($data)
2 {
3
4 return escapeshellcmd($data);
5
6 }
escapeshellcmd函数功能:
反斜线(\)会在以下字符之前插入: &#;`|*?~<>^()[]{}$\, \x0A 和 \xFF。 ' 和 " 仅在不配对儿的时候被转义。 在 Windows 平台上,所有这些字符以及 % 和 ! 字符都会被空格代替。
bWAPP----OS Command Injection的更多相关文章
- bWAPP----HTML OS Command Injection - Blind
OS Command Injection - Blind 先上代码,他判断了win还是linux然后进行了ping但是结果并没有返回. 1 <div id="main"> ...
- Portswigger web security academy:OS command injection
Portswigger web security academy:OS command injection 目录 Portswigger web security academy:OS command ...
- DVWA之命令注入(command injection)
Command injection就是指通过提交恶意构造的参数破坏命令语句结构,从而达到执行恶意命令的目的 LOW 无论是Windows还是Linux,都可以使用&&连接多个命令 执行 ...
- DVWA Command Injection 通关教程
Command Injection 介绍 命令注入(Command Injection),对一些函数的参数没有做过滤或过滤不严导致的,可以执行系统或者应用指令(CMD命令或者bash命令)的一种注入攻 ...
- DVWA Command Injection 解析
命令注入,即 Command Injection.是指通过提交恶意构造的参数破坏命令语句结构,从而达到执行恶意命令的目的. 在Web应用中,有时候会用到一些命令执行的函数,如php中system.ex ...
- DWVA-命令注入漏洞闯关(Command Injection)
前言 Vulnerability: Command Injection LOW级别 代码: <?php if( isset( $_POST[ 'Submit' ] ) ) { // 几首一个变量 ...
- DVWA之Command Injection
Command Injection Command Injection,即命令注入,是指通过提交恶意构造的参数破坏命令语句结构,从而达到执行恶意命令的目的.PHP命令注入攻击漏洞是PHP应用程序中常见 ...
- DVWA(四):Command Injection 全等级命令注入
Command Injection : 命令注入(Command Injection),对一些函数的参数没有做好过滤而导致用户可以控制输入的参数,使其恶意执行系统命令或这cmd.bash指令的一种注入 ...
- DVWA靶场之Command Injection(命令行注入)通关
Command Injection Low: <?php if( isset( $_POST[ 'Submit' ] ) ) { // Get input $target = $_REQUES ...
随机推荐
- 第三十二章 Linux常规练习题(一)
一.练习题一 1.超级用户(管理员用户)提示符是____,普通用户提示符是____.2.linux关机重启的命令有哪些 ?3.bash是什么?4.bash特性, 常见的bash特性有哪些?5.网卡的配 ...
- Linux运维学习第二周记
1 梨花淡白柳深青, 2 柳絮飞时花满城. 3 惆怅东栏一株雪, 4 人生看得几清明. 老牛望春满地绿! 第二周直接要起飞了! 仍然是最基础最基础的东西,但也是特别多,的别重要! 第二周学记 1.Li ...
- Fur 是 .NET 5 平台下企业应用开发最佳实践框架。
Fur 是 .NET 5 平台下企业应用开发最佳实践框架. 立即尝鲜 Fur 是基于最新的 .NET 5 RC2 构建,目的是为了尽早体验新功能,对即将到来的 .NET 5 正式版做出最快的响应. 所 ...
- Linux 打开core dump功能
系统打开core dump功能 在终端中输入命令 ulimit -c ,输出的结果为 0,说明默认是关闭 core dump 的,即当程序异常终止时,也不会生成 core dump 文件: 使用命令 ...
- vue自定义指令长按事件
Vue.directive('longpress', { bind: function (el, binding, vNode) { // Make sure expressi ...
- Kubernetes Scheduler浅析
概述 Kubernetes 调度器(Scheduler)是Kubernetes的核心组件:用户或者控制器创建Pod之后,调度器通过 kubernetes 的 watch 机制来发现集群中新创建且尚未被 ...
- POI Excel 导入导出重点
HSSF是指2007年以前的,XSSF是指2007年版本以上的 这个还是比较好用的,这些总结来自Apache的官方向导的点点滴滴 详细的请参考http://poi.apache.org/spreads ...
- Spring源码知识概览
目录 Spring知识总览 1.1 IOC 1.2 Spring中重要接口概览 Spring知识总览 1.1 IOC IOC是控制反转,是一种思想 DI是依赖注入,是控制翻转的一种实现 Spring的 ...
- LORA串口无线数据透明传输终端ZSL311
ZSL311是由成都众山科技生产销售的一款LORA串口无线数据透明传输终端,采用的是LoRa扩频技术来进行无线数据传输,同时提供RS485和RS232串口,为用户提供全透明数据传输模式.支持星形.Me ...
- Java学习的第五十五天
1.例11.1继承学生类 import java.util.Scanner; import java.util.*; public class Cjava { public static void m ...