[英]DangerousPhp inside phpseclib when checking with YARA
在使用YARA在 PHP 應用程序中進行惡意軟件掃描時,
yara -r./php.yar -s /myapp
DangerousPhp /myapp/phpseclib/Net/SSH2.php
0x1140c:$system: system
0x1083a:$: call_user_func
0x1671f:$: call_user_func
0x154:$: EXEC
里面使用的惡意軟件查找工具是https://github.com/nbs-system/php-malware-finder/
引發此錯誤的 phpseclib 庫文件是https://github.com/phpseclib/phpseclib/blob/master/phpseclib/Net/SSH2.php
任何幫助將不勝感激。
假陽性。 目前尚不清楚您使用的是哪個版本的 phpseclib,但我們假設您使用的是最新的 2.0 版本 (2.0.34)。 call_user_func
僅出現在第 2946 行:
https://github.com/phpseclib/phpseclib/blob/2.0.34/phpseclib/Net/SSH2.php#L2946
default:
if (is_callable($callback)) {
if (call_user_func($callback, $temp) === true) {
$this->_close_channel(self::CHANNEL_EXEC);
return true;
}
} else {
$output.= $temp;
}
它在 exec() 方法中。 $callback
是一個參數,其用途在https://phpseclib.com/docs/commands#callbacks中討論。 3.0 分支執行$callback($temp)
而不是callback_user_func($temp)
但它是相同的基本思想。 可能$callback($temp)
不適用於舊版本的 PHP 而callback_user_func($temp)
可以。
call_user_func_array
在 SSH2.php 中被調用了兩次。 一次在2227 行,一次在3375 行。
第 2227 行在login
方法中。 這是該方法的作用:
function login($username)
{
$args = func_get_args();
$this->auth[] = $args;
// try logging with 'none' as an authentication method first since that's what
// PuTTY does
if (substr($this->server_identifier, 0, 15) != 'SSH-2.0-CoreFTP' && $this->auth_methods_to_continue === null) {
if ($this->_login($username)) {
return true;
}
if (count($args) == 1) {
return false;
}
}
return call_user_func_array(array(&$this, '_login'), $args);
}
在 phpseclib 3.0.11 中,它正在執行return $this->sublogin($username, ...$args);
但基本思想是它獲取$args
的每個元素並將其作為單獨的參數傳遞給$this->_login
。 就像你做$this->_login($args)
那么_login
只會采用一個參數。 PHP 5.6 引入了 splat (...) 運算符,但 phpseclib 2 在 PHP 5.3 上運行,因此您必須執行call_user_func_array
或僅使用單個參數,僅此而已。
這是call_user_func_array
的另一個實例:
function _reconnect()
{
$this->_reset_connection(NET_SSH2_DISCONNECT_CONNECTION_LOST);
$this->retry_connect = true;
if (!$this->_connect()) {
return false;
}
foreach ($this->auth as $auth) {
$result = call_user_func_array(array(&$this, 'login'), $auth);
}
return $result;
}
所以同樣的事情。
所以就像我說的,這是一個沒有三明治的東西。 誤報。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.