当前位置: 首页 > news >正文

审计dvwa高难度命令执行漏洞的代码,编写实例说明如下函数的用法

审计dvwa高难度命令执行漏洞的代码

,编写实例说明如下函数的用法

代码:

<?phpif( isset( $_POST[ 'Submit' ]  ) ) {// Get input$target = trim($_REQUEST[ 'ip' ]);// Set blacklist$substitutions = array('&'  => '',';'  => '','| ' => '','-'  => '','$'  => '','('  => '',')'  => '','`'  => '','||' => '',);// Remove any of the charactars in the array (blacklist).$target = str_replace( array_keys( $substitutions ), $substitutions, $target );// Determine OS and execute the ping command.if( stristr( php_uname( 's' ), 'Windows NT' ) ) {// Windows$cmd = shell_exec( 'ping  ' . $target );}else {// *nix$cmd = shell_exec( 'ping  -c 4 ' . $target );}// Feedback for the end userecho "<pre>{$cmd}</pre>";
}?> 

trim

此函数用于删除字符串两侧的空白字符或其他预定义字符。

<?php$username = $_GET['username'];$username = trim($username);echo($username)
?>

接受表单传递过来的用户名,并使用trim() 函数删除其两侧任意的空格。

str_replace

这个函数用于搜索一个字符串并替换与另一个字符串匹配的部分。

<?php$test = "hello world!";$test = str_replace("world", "zs", $test);echo $test;    // 输出为:"hello zs!"
?>

使用str_replace() 函数讲“world”替换为“zs”

array_keys

这个函数返回数组中所有键名的一个新数组。

<?php$test = array('a' => 'apple', 'b' => 'banana', 'c' => 'cherry');print_r(array_keys($test));     // 输出  Array ( [0] => a [1] => b [2] => c ) 
?>

使用array_keys()函数获取数组中的所有键名。

stristr 

这个函数查找字符串在另一字符串中的第一次出现。

<?php$string = "hello world!";$findme = "world";$pos = strpos($string,$findme);if ($pos === false) {echo "The string '$findme' was not found in the string '$string'";} else {echo "The string '$findme' was found in the string '$string'";}
?>

使用strpos()函数查找"World"是否存在于字符串"Hello, World!"中。

php_uname

这个函数返回关于服务器的信息,如主机名、操作系统名称和版本号等。

<?phpecho php_uname();// 输出 Windows NT WIN-37QPUN7NO81 6.2 build 9200 (Windows Server 2012 Standard Edition) i586
?>

使用php_uname()函数获取服务器信息。

http://www.lryc.cn/news/238121.html

相关文章:

  • 国科大数据挖掘期末复习——聚类分析
  • 【经验之谈·高频PCB电路设计常见的66个问题】
  • 科大讯飞 vue.js 语音听写流式实现 全网首发
  • 局域网文件共享神器:Landrop
  • 如何使用Docker部署Apache+Superset数据平台并远程访问?
  • 【阿里云】图像识别 摄像模块 语音模块
  • 一文读懂 Linux 网络 IO 模型
  • Arduino库之U8g2lib
  • fiddler 手机抓包
  • 基于知识问答的上下文学习中的代码风格11.20
  • opencv-形态学处理
  • 手把手设计C语言版循环队列(力扣622:设计循环队列)
  • 数据仓库及ETL的理论基础
  • 5-4计算一串字符的空格数字字符其他
  • leetcode面试经典150题——30 长度最小的子数组
  • 学习计划计划执行记录
  • 【紫光同创PCIE教程】——使用WinDriver驱动紫光PCIE
  • MT8735/MTK8735安卓核心板规格参数介绍
  • NSSCTF web刷题记录6
  • 米哈游大数据云原生实践
  • 移动端适配-(postcss-pxtorem)
  • 【PostgreSQL】解决PostgreSQL时区(TimeZone)问题
  • Vue Router的使用
  • 海外IP代理科普——API代理
  • 详解Python安装requests库的实例代码
  • Flutter 使用 device_info_plus 遇到的问题
  • 论文阅读:“基于特征检测与深度特征描述的点云粗对齐算法”
  • [python]python筛选excel表格信息并保存到另一个excel
  • 使用kafka_exporter监控Kafka
  • 基于Bagging集成学习方法的情绪分类预测模型研究(文末送书)