pwd 查看当前工作目录的完整路径
cd / 切换到根目录
ls /  查看根目录下的所有目录和文件
cat /[filename] 显示文件(非文件夹)[filename]中的内容

 

 

 

 

 

echo(string $command [, array &$output [, int &$return_var ]]);
用于执行一个外部程序,该函数基本是在linux中使用
$command 表示要执行的命令
$output 会用命令$command)执行的输出填充此数组
$return_var 若函数同时提供 output 和 return_var 参数, 命令执行后的返回状态会被写入到本变量

 

 

 

 

 

 

输出
print() 只能打印出简单类型变量的值(如int,string)
printf_r() 可以打印出复杂类型变量的值(如数组,对象)
echo() 输出一个或者多个字符串

 

 

 

 

 

 

  1. 1 <?php
  2. 2 $shell = "pwd";
  3. 3 exec($shell, $result, $status);
  4. 4 $shell = "<font color='red'>$shell</font>";
  5. 5 echo "<pre>";
  6. 6 if( $status ){
  7. 7 echo "shell命令{$shell}执行失败";
  8. 8 } else {
  9. 9 echo "shell命令{$shell}成功执行, 结果如下<hr>";
  10. 10 print_r( $result );
  11. 11 }
  12. 12 echo "</pre>";
  13. 13 ?>

 

 

 

 

 

0x04 cat命令打开txt文件,获取flag

0x05 收获与其他

(1)本次练习最重要的是理解了PHP语言的一些常用函数和Linux的一些命令,即0x01。

以此为例,多写记忆文章,方便后日。

(2)如有侵权,请留言说明,谢谢!

0x06 参考链接

(1)https://blog.csdn.net/qq_23329167/article/details/83856430

(2)https://www.php.net/manual/zh/function.exec.php

(3)https://blog.csdn.net/qq_42111373/article/details/106096108

 

 

版权声明:本文为tumei原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/tumei/p/14457794.html