Language: PHP
Label: vulnerable
CWE: CWE-77 \u2014 Improper Neutralization of Special Elements used in a Command ('Command Injection')
The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.

Code:
	public function processFind($search){
		$cmd = "ps -eo user,pid,ppid,args | grep '".$search."' | grep -v grep | awk '{print $2}'";
		if($GLOBALS['config']['systemOS'] != 'windows'){return trim(@shell_exec($cmd));}
		
		// windows 获取pid;
		$cmd = 'WMIC process where "Commandline like \'%%%'.$search.'%%%\'" get Caption,Processid,Commandline';
		$res = trim(@shell_exec($cmd));
		$resArr = explode("\n",trim($res));
		if(!$resArr || count($resArr) <= 3) return '';

		$lineFind = $resArr[count($resArr) - 3];// 最后两个一个为wmic,和cmd;
		$res = preg_match("/.*\s+(\d+)\s*$/",$lineFind,$match);
		if($res && is_array($match) && $match[1]){return $match[1];}
		return '';
	}