PHP实现office中宏的提取

WBOY
Release: 2016-06-23 13:58:59
Original
956 people have browsed it

其实是通过调用外部工具实现,外部工具为 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; //宏内容		}	}}?>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template