其实是通过调用外部工具实现,外部工具为 officemalscanner
php代码如下:
<?php$path = "e:\php\malware.xls"; //待判断文件位置$type = "bin"; //bin为常见二进制格式,xml为xml格式$officescanner = "e:\officemalscanner\officemalscanner.exe"; //officemalscanner.exe 所在路径if($type == "bin") { exec("$officescanner $path info"); //常见二进制格式文件}else { exec("$officescanner $path scan brute");//xml格式的文件}$dir = "$path-macros";if(!file_exists($dir)||!is_dir($dir)){ echo "the file don not include macro!"; }else { $dirList=array(); $dir=opendir($dir); $i=0; while($file=readdir($dir)){ if($file!=='.'&&$file!=='..'){ $dirList[$i]=$file; $i++; }; }; $num = $i; closedir($dir); for($i=0;$i<$num;$i++) { //echo $dirList[$i]; if(preg_match('/^((?!Sheet).)*$/',$dirList[$i]) && preg_match("/^((?!ThisDocument).)*$/",$dirList[$i])) { //排除其他文件 $text = "$path-macros\$dirList[$i]"; $result = file_get_contents($text, "r"); echo $result; //宏内容 } }}?>
全网最新最细最实用WPS零基础入门到精通全套教程!带你真正掌握WPS办公! 内含Excel基础操作、函数设计、数据透视表等
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号