- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/crypt.php
- Класс: CSteganos
- Вызов: CSteganos::__GetHiddenInfo
function __GetHiddenInfo()
{
if ($this->containerType == "bmp")
{
$this->level = -1;
$header = "";
for ($i = 0; $i < 12; $i++)
$header = chr(0);
for ($i = 55, $j = 7, $k = 0; $i < 151; $i++)
{
$header[$k] = chr(ord($header[$k]) | ((ord($this->containerData[$i]) & 1) << $j));
$j--;
if ($j < 0)
{
$j = 7;
$k++;
}
}
if (!strcmp(mb_substr($header, 0, 4), "BSAW"))
{
sscanf(mb_substr($header, 4, 8), "%x", $this->dataSize);
$this->level = 1;
$this->offset = 151;
}
if ($this->level == -1)
{
$header = "";
for ($i = 0; $i < 12; $i++)
$header = chr(0);
for ($i = 55, $j = 6, $k = 0; $i < 103; $i++)
{
$header[$k] = chr(ord($header[$k]) | ((ord($this->containerData[$i]) & 3) << $j));
$j -= 2;
if ($j < 0)
{
$j = 6;
$k++;
}
}
if (!strcmp(mb_substr($header, 0, 4), "BSAW"))
{
sscanf(mb_substr($header, 4, 8), "%x", $this->dataSize);
$this->level = 2;
$this->offset = 103;
}
}
if ($this->level == -1)
{
$header = "";
for ($i = 0; $i < 12; $i++)
$header = chr(0);
for ($i = 55, $j = 0; $i < 79; $i += 2, $j++)
{
for ($k = 0; $k < 2; $k++)
{
if ($k == 0)
$header[$j] = chr(ord($header[$j]) | ((ord($this->containerData[$i]) & 15) << 4));
else
$header[$j] = chr(ord($header[$j]) | (ord($this->containerData[$i+1]) & 15));
}
}
if (!strcmp(mb_substr($header, 0, 4), "BSAW"))
{
sscanf(mb_substr($header, 4, 8), "%x", $this->dataSize);
$this->level = 4;
$this->offset = 79;
}
}
if ($this->level == -1)
{
$this->errorMessage = "The bitmap file '".$this->containerFile."' contains no encrypted data";
return false;
}
$nBytes = (($this->level == 1) ? 8 : (($this->level == 2) ? 4 : 2));
if ($this->offset + $this->dataSize * $nBytes > mb_strlen($this->containerData))
{
$this->errorMessage = "The container file '".$this->containerFile."' contains no encrypted data";
return false;
}
}
elseif ($this->containerType == "txt")
{
$endStr = strrchr($this->containerData, "r");
if ($endStr === false || $endStr[1] != "n")
{
$this->errorMessage = "The container file '".$this->containerFile."' contains no encrypted data";
return false;
}
$bits = mb_substr($this->containerData, mb_strlen($this->containerData) - mb_strlen($endStr) - 32, 32);
$containerDataLength_bin = $this->__ConvertBitStringToBinary($bits);
if ($containerDataLength_bin == false)
{
$this->errorMessage = "The container file '".$this->containerFile."' contains no encrypted data";
return false;
}
$containerDataLength_hex = "";
for ($i = 3; $i >= 0; $i--)
$containerDataLength_hex .= sprintf("%02X", ord($containerDataLength_bin[$i]));
sscanf($containerDataLength_hex, "%X", $this->offset);
$this->dataSize = mb_strlen($this->containerData) - mb_strlen($endStr) - 32 - $this->offset;
}
return true;
}