2024-04-30

HObfus.inc.php emited the following error when it is used HTML Obfuscator.

--------------------------------------------------------------------------------------------------------
Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
--------------------------------------------------------------------------------------------------------

I found out that $__HOBFUS_PASSCODE__ is null in the following code:

--------------------------------------------------------------------------------------------------------
global $__HOBFUS_PASSCODE__;
echo str_replace('%-%-%-%-passcode-%-%-%-%',$__HOBFUS_PASSCODE__,
	str_replace('%-%-%-%-hexstr-%-%-%-%',$hexstr,
	str_replace('%-%-%-%-protocol-%-%-%-%',$protocol,
	str_replace('%-%-%-%-hostname-%-%-%-%',
		str_replace("'","\\'",
		str_replace("\\","",
		str_replace("/","",$hostname))),
	str_replace('%-%-%-%-rscript-%-%-%-%',$rscript,
	str_replace('%-%-%-%-rcomment-%-%-%-%',$rcomment,
	$javascript))))));
--------------------------------------------------------------------------------------------------------

$__HOBFUS_PASSCODE__ is decalred on the top page like

--------------------------------------------------------------------------------------------------------
$__HOBFUS_PASSCODE__='SLXJXXQJHEQHMDDHQYYOTMWSPTYEHINOROCNPHXVLJXSXBMANDHQAMECMBNENLO';
--------------------------------------------------------------------------------------------------------

Why doesn't it pass it to str_replace?

The reason is $__HOBFUS_PASSCODE__ was NOT really global because HObfus.inc.php was included from
some other function. When a file is included from a function, PHP make any classes and functions inside
the file global but not variables!!!

The solution is use $_GLOBALS function like

--------------------------------------------------------------------------------------------------------
$GLOBALS['__HOBFUS_PASSCODE__']='SLXJXXQJHEQHMDDHQYYOTMWSPTYEHINOROCNPHXVLJXSXBMANDHQAMECMBNENLO';
--------------------------------------------------------------------------------------------------------

and use it in str_replace like

--------------------------------------------------------------------------------------------------------
echo str_replace('%-%-%-%-passcode-%-%-%-%',$GLOBALS['__HOBFUS_PASSCODE__'],
	str_replace('%-%-%-%-hexstr-%-%-%-%',$hexstr,
	str_replace('%-%-%-%-protocol-%-%-%-%',$protocol,
	str_replace('%-%-%-%-hostname-%-%-%-%',
		str_replace("'","\\'",
		str_replace("\\","",
		str_replace("/","",$hostname))),
	str_replace('%-%-%-%-rscript-%-%-%-%',$rscript,
	str_replace('%-%-%-%-rcomment-%-%-%-%',$rcomment,
	$javascript))))));
--------------------------------------------------------------------------------------------------------

